Changeset 83362 in webkit
- Timestamp:
- Apr 8, 2011 5:04:50 PM (13 years ago)
- Location:
- trunk/Source/WebKit2
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit2/ChangeLog
r83357 r83362 1 2011-04-08 Anders Carlsson <andersca@apple.com> 2 3 Reviewed by Dan Bernstein. 4 5 Sandboxing doesn't work if a local file is dropped on the content area 6 https://bugs.webkit.org/show_bug.cgi?id=58177 7 <rdar://problem/9019253> 8 9 When performing a drag and the dragging pasteboard contains a local file, create a 10 sandbox extension and pass it along. If we end up loading the file, the sandbox extension 11 tracker will consume the extension. 12 13 * UIProcess/API/mac/WKView.mm: 14 (maybeCreateSandboxExtensionFromPasteboard): 15 Add helper function. 16 17 (-[WKView performDragOperation:]): 18 Create a sandbox extension handle and pass it to performDrag. 19 20 * UIProcess/WebPageProxy.cpp: 21 (WebKit::WebPageProxy::dragEntered): 22 (WebKit::WebPageProxy::dragUpdated): 23 (WebKit::WebPageProxy::dragExited): 24 Pass an empty sandbox extension handle to performDragControllerAction. 25 26 (WebKit::WebPageProxy::performDrag): 27 Pass the sandbox extension handle along to performDragControllerAction. 28 29 (WebKit::WebPageProxy::performDragControllerAction): 30 Send along the sandbox extension handle. 31 32 * WebProcess/WebCoreSupport/WebDragClient.cpp: 33 (WebKit::WebDragClient::willPerformDragDestinationAction): 34 If the destination action is a load action, call WebPage::willPerformLoadDragDestinationAction. 35 36 * WebProcess/WebPage/WebPage.cpp: 37 (WebKit::WebPage::performDragControllerAction): 38 Create a sandbox extension. 39 40 (WebKit::WebPage::willPerformLoadDragDestinationAction): 41 If we have a sandbox extension, pass it along to the sandbox extension tracker. 42 43 (WebKit::WebPage::SandboxExtensionTracker::willPerformLoadDragDestinationAction): 44 Call setPendingProvisionalSandboxExtension. 45 46 (WebKit::WebPage::SandboxExtensionTracker::beginLoad): 47 Call setPendingProvisionalSandboxExtension. 48 49 (WebKit::WebPage::SandboxExtensionTracker::setPendingProvisionalSandboxExtension): 50 Factor code from beginLoad out into a separate function. 51 52 * WebProcess/WebPage/WebPage.messages.in: 53 PerformDragControllerAction now takes a sandbox extension handle. 54 1 55 2011-04-08 Alice Liu <alice.liu@apple.com> 2 56 -
trunk/Source/WebKit2/UIProcess/API/mac/WKView.mm
r83354 r83362 1464 1464 } 1465 1465 1466 // FIXME: This code is more or less copied from Pasteboard::getBestURL. 1467 // It would be nice to be able to share the code somehow. 1468 static void maybeCreateSandboxExtensionFromPasteboard(NSPasteboard *pasteboard, SandboxExtension::Handle& sandboxExtensionHandle) 1469 { 1470 NSArray *types = [pasteboard types]; 1471 if (![types containsObject:NSFilenamesPboardType]) 1472 return; 1473 1474 NSArray *files = [pasteboard propertyListForType:NSFilenamesPboardType]; 1475 if ([files count] != 1) 1476 return; 1477 1478 NSString *file = [files objectAtIndex:0]; 1479 BOOL isDirectory; 1480 if (![[NSFileManager defaultManager] fileExistsAtPath:file isDirectory:&isDirectory]) 1481 return; 1482 1483 if (isDirectory) 1484 return; 1485 1486 SandboxExtension::createHandle("/", SandboxExtension::ReadOnly, sandboxExtensionHandle); 1487 } 1488 1466 1489 - (BOOL)performDragOperation:(id <NSDraggingInfo>)draggingInfo 1467 1490 { … … 1469 1492 IntPoint global(globalPoint([draggingInfo draggingLocation], [self window])); 1470 1493 DragData dragData(draggingInfo, client, global, static_cast<DragOperation>([draggingInfo draggingSourceOperationMask]), [self applicationFlags:draggingInfo]); 1471 _data->_page->performDrag(&dragData, [[draggingInfo draggingPasteboard] name]); 1494 1495 SandboxExtension::Handle sandboxExtensionHandle; 1496 maybeCreateSandboxExtensionFromPasteboard([draggingInfo draggingPasteboard], sandboxExtensionHandle); 1497 1498 _data->_page->performDrag(&dragData, [[draggingInfo draggingPasteboard] name], sandboxExtensionHandle); 1499 1472 1500 return YES; 1473 1501 } -
trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp
r83354 r83362 701 701 void WebPageProxy::dragEntered(WebCore::DragData* dragData, const String& dragStorageName) 702 702 { 703 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName); 703 SandboxExtension::Handle sandboxExtensionHandle; 704 performDragControllerAction(DragControllerActionEntered, dragData, dragStorageName, sandboxExtensionHandle); 704 705 } 705 706 706 707 void WebPageProxy::dragUpdated(WebCore::DragData* dragData, const String& dragStorageName) 707 708 { 708 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName); 709 SandboxExtension::Handle sandboxExtensionHandle; 710 performDragControllerAction(DragControllerActionUpdated, dragData, dragStorageName, sandboxExtensionHandle); 709 711 } 710 712 711 713 void WebPageProxy::dragExited(WebCore::DragData* dragData, const String& dragStorageName) 712 714 { 713 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName); 714 } 715 716 void WebPageProxy::performDrag(WebCore::DragData* dragData, const String& dragStorageName) 717 { 718 performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName); 719 } 720 721 void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName) 715 SandboxExtension::Handle sandboxExtensionHandle; 716 performDragControllerAction(DragControllerActionExited, dragData, dragStorageName, sandboxExtensionHandle); 717 } 718 719 void WebPageProxy::performDrag(WebCore::DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle) 720 { 721 performDragControllerAction(DragControllerActionPerformDrag, dragData, dragStorageName, sandboxExtensionHandle); 722 } 723 724 void WebPageProxy::performDragControllerAction(DragControllerAction action, WebCore::DragData* dragData, const String& dragStorageName, const SandboxExtension::Handle& sandboxExtensionHandle) 722 725 { 723 726 if (!isValid()) … … 728 731 dragData->draggingSourceOperationMask(), dragData->dragDataMap(), dragData->flags()), m_pageID); 729 732 #else 730 process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags() ), m_pageID);733 process()->send(Messages::WebPage::PerformDragControllerAction(action, dragData->clientPosition(), dragData->globalPosition(), dragData->draggingSourceOperationMask(), dragStorageName, dragData->flags(), sandboxExtensionHandle), m_pageID); 731 734 #endif 732 735 } -
trunk/Source/WebKit2/UIProcess/WebPageProxy.h
r83354 r83362 385 385 void dragUpdated(WebCore::DragData*, const String& dragStorageName = String()); 386 386 void dragExited(WebCore::DragData*, const String& dragStorageName = String()); 387 void performDrag(WebCore::DragData*, const String& dragStorageName = String());387 void performDrag(WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&); 388 388 389 389 void didPerformDragControllerAction(uint64_t resultOperation); … … 697 697 void clearLoadDependentCallbacks(); 698 698 699 void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName );699 void performDragControllerAction(DragControllerAction, WebCore::DragData*, const String& dragStorageName, const SandboxExtension::Handle&); 700 700 701 701 PageClient* m_pageClient; -
trunk/Source/WebKit2/WebProcess/WebCoreSupport/WebDragClient.cpp
r79335 r83362 27 27 #include "WebDragClient.h" 28 28 29 #include <WebCore/NotImplemented.h>29 #include "WebPage.h" 30 30 31 31 using namespace WebCore; … … 33 33 namespace WebKit { 34 34 35 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction , DragData*)35 void WebDragClient::willPerformDragDestinationAction(DragDestinationAction action, DragData*) 36 36 { 37 if (action == DragDestinationActionLoad) 38 m_page->willPerformLoadDragDestinationAction(); 37 39 } 38 40 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp
r83081 r83362 1489 1489 } 1490 1490 #else 1491 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags )1491 void WebPage::performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const String& dragStorageName, uint32_t flags, const SandboxExtension::Handle& sandboxExtensionHandle) 1492 1492 { 1493 1493 if (!m_page) { … … 1510 1510 break; 1511 1511 1512 case DragControllerActionPerformDrag: 1512 case DragControllerActionPerformDrag: { 1513 ASSERT(!m_pendingDropSandboxExtension); 1514 1515 m_pendingDropSandboxExtension = SandboxExtension::create(sandboxExtensionHandle); 1516 1513 1517 m_page->dragController()->performDrag(&dragData); 1518 1519 // If we started loading a local file, the sandbox extension tracker would have adopted this 1520 // pending drop sandbox extension. If not, we'll play it safe and invalidate it. 1521 if (m_pendingDropSandboxExtension) { 1522 m_pendingDropSandboxExtension->invalidate(); 1523 m_pendingDropSandboxExtension = nullptr; 1524 } 1525 1514 1526 break; 1515 1527 } 1528 1516 1529 default: 1517 1530 ASSERT_NOT_REACHED(); … … 1535 1548 } 1536 1549 1550 void WebPage::willPerformLoadDragDestinationAction() 1551 { 1552 m_sandboxExtensionTracker.willPerformLoadDragDestinationAction(m_pendingDropSandboxExtension.release()); 1553 } 1554 1537 1555 WebEditCommand* WebPage::webEditCommand(uint64_t commandID) 1538 1556 { … … 1862 1880 } 1863 1881 1882 void WebPage::SandboxExtensionTracker::willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension) 1883 { 1884 setPendingProvisionalSandboxExtension(pendingDropSandboxExtension); 1885 } 1886 1864 1887 void WebPage::SandboxExtensionTracker::beginLoad(WebFrame* frame, const SandboxExtension::Handle& handle) 1865 1888 { 1866 1889 ASSERT(frame->isMainFrame()); 1867 1890 1891 setPendingProvisionalSandboxExtension(SandboxExtension::create(handle)); 1892 } 1893 1894 void WebPage::SandboxExtensionTracker::setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension> pendingProvisionalSandboxExtension) 1895 { 1868 1896 // If we get two beginLoad calls in succession, without a provisional load starting, then 1869 1897 // m_pendingProvisionalSandboxExtension will be non-null. Invalidate and null out the extension if that is the case. … … 1872 1900 m_pendingProvisionalSandboxExtension = nullptr; 1873 1901 } 1874 1875 m_pendingProvisionalSandboxExtension = SandboxExtension::create(handle);1902 1903 m_pendingProvisionalSandboxExtension = pendingProvisionalSandboxExtension; 1876 1904 } 1877 1905 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.h
r83204 r83362 291 291 292 292 void beginLoad(WebFrame*, const SandboxExtension::Handle& handle); 293 void willPerformLoadDragDestinationAction(PassRefPtr<SandboxExtension> pendingDropSandboxExtension); 293 294 void didStartProvisionalLoad(WebFrame*); 294 295 void didCommitProvisionalLoad(WebFrame*); 295 296 void didFailProvisionalLoad(WebFrame*); 297 296 298 private: 299 void setPendingProvisionalSandboxExtension(PassRefPtr<SandboxExtension>); 300 297 301 RefPtr<SandboxExtension> m_pendingProvisionalSandboxExtension; 298 302 RefPtr<SandboxExtension> m_provisionalSandboxExtension; … … 349 353 void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WebCore::DragDataMap&, uint32_t flags); 350 354 #else 351 void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags );355 void performDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, const WTF::String& dragStorageName, uint32_t flags, const SandboxExtension::Handle&); 352 356 #endif 353 357 void dragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation); 358 359 void willPerformLoadDragDestinationAction(); 354 360 355 361 void beginPrinting(uint64_t frameID, const PrintInfo&); … … 615 621 uint64_t m_pageID; 616 622 623 RefPtr<SandboxExtension> m_pendingDropSandboxExtension; 624 617 625 bool m_canRunBeforeUnloadConfirmPanel; 618 626 -
trunk/Source/WebKit2/WebProcess/WebPage/WebPage.messages.in
r83204 r83362 121 121 #endif 122 122 #if !PLATFORM(WIN) 123 PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags )123 PerformDragControllerAction(uint64_t action, WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t draggingSourceOperationMask, WTF::String dragStorageName, uint32_t flags, WebKit::SandboxExtension::Handle sandboxExtensionHandle) 124 124 #endif 125 125 DragEnded(WebCore::IntPoint clientPosition, WebCore::IntPoint globalPosition, uint64_t operation)
Note: See TracChangeset
for help on using the changeset viewer.