Changeset 87597 in webkit
- Timestamp:
- May 27, 2011 8:27:16 PM (13 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r87590 r87597 1 2011-05-27 Jochen Eisinger <jochen@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Check access policy on all storage operations 6 https://bugs.webkit.org/show_bug.cgi?id=61581 7 8 * platform/chromium/permissionclient/storage-permission-expected.txt: Added. 9 * platform/chromium/permissionclient/storage-permission.html: Added. 10 1 11 2011-05-27 Adam Klein <adamk@chromium.org> 2 12 -
trunk/Source/WebCore/ChangeLog
r87595 r87597 1 2011-05-27 Jochen Eisinger <jochen@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Add Frame parameter to all StorageArea methods. The chromium 6 embedder uses the Frame as context to decide whether or not 7 to allow usage of the storage API. 8 https://bugs.webkit.org/show_bug.cgi?id=61581 9 10 Test: platform/chromium/permissionclient/storage-permission.html 11 12 * storage/Storage.cpp: 13 (WebCore::Storage::length): 14 (WebCore::Storage::key): 15 (WebCore::Storage::getItem): 16 (WebCore::Storage::contains): 17 * storage/StorageArea.h: 18 * storage/StorageAreaImpl.cpp: 19 (WebCore::StorageAreaImpl::length): 20 (WebCore::StorageAreaImpl::key): 21 (WebCore::StorageAreaImpl::getItem): 22 (WebCore::StorageAreaImpl::contains): 23 * storage/StorageAreaImpl.h: 24 1 25 2011-05-27 Nate Chapin <japhet@chromium.org> 2 26 -
trunk/Source/WebCore/storage/Storage.cpp
r73015 r87597 60 60 return 0; 61 61 62 return m_storageArea->length( );62 return m_storageArea->length(m_frame); 63 63 } 64 64 … … 68 68 return String(); 69 69 70 return m_storageArea->key(index );70 return m_storageArea->key(index, m_frame); 71 71 } 72 72 … … 76 76 return String(); 77 77 78 return m_storageArea->getItem(key );78 return m_storageArea->getItem(key, m_frame); 79 79 } 80 80 … … 109 109 return false; 110 110 111 return m_storageArea->contains(key );111 return m_storageArea->contains(key, m_frame); 112 112 } 113 113 -
trunk/Source/WebCore/storage/StorageArea.h
r53710 r87597 48 48 49 49 // The HTML5 DOM Storage API 50 virtual unsigned length() const = 0; 51 virtual String key(unsigned index) const = 0; 52 virtual String getItem(const String& key) const = 0; 50 // FIXME: We should pass Document instead of Frame. Also, that parameter should go first. 51 virtual unsigned length(Frame* sourceFrame) const = 0; 52 virtual String key(unsigned index, Frame* sourceFrame) const = 0; 53 virtual String getItem(const String& key, Frame* sourceFrame) const = 0; 53 54 virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame) = 0; 54 55 virtual String removeItem(const String& key, Frame* sourceFrame) = 0; 55 56 virtual bool clear(Frame* sourceFrame) = 0; 56 virtual bool contains(const String& key ) const = 0;57 virtual bool contains(const String& key, Frame* sourceFrame) const = 0; 57 58 }; 58 59 -
trunk/Source/WebCore/storage/StorageAreaImpl.cpp
r87114 r87597 108 108 } 109 109 110 unsigned StorageAreaImpl::length( ) const110 unsigned StorageAreaImpl::length(Frame*) const 111 111 { 112 112 ASSERT(!m_isShutdown); … … 116 116 } 117 117 118 String StorageAreaImpl::key(unsigned index ) const118 String StorageAreaImpl::key(unsigned index, Frame*) const 119 119 { 120 120 ASSERT(!m_isShutdown); … … 124 124 } 125 125 126 String StorageAreaImpl::getItem(const String& key ) const126 String StorageAreaImpl::getItem(const String& key, Frame*) const 127 127 { 128 128 ASSERT(!m_isShutdown); … … 205 205 } 206 206 207 bool StorageAreaImpl::contains(const String& key ) const207 bool StorageAreaImpl::contains(const String& key, Frame*) const 208 208 { 209 209 ASSERT(!m_isShutdown); -
trunk/Source/WebCore/storage/StorageAreaImpl.h
r80892 r87597 46 46 47 47 // The HTML5 DOM Storage API (and contains) 48 virtual unsigned length( ) const;49 virtual String key(unsigned index ) const;50 virtual String getItem(const String& key ) const;48 virtual unsigned length(Frame* sourceFrame) const; 49 virtual String key(unsigned index, Frame* sourceFrame) const; 50 virtual String getItem(const String& key, Frame* sourceFrame) const; 51 51 virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); 52 52 virtual String removeItem(const String& key, Frame* sourceFrame); 53 53 virtual bool clear(Frame* sourceFrame); 54 virtual bool contains(const String& key ) const;54 virtual bool contains(const String& key, Frame* sourceFrame) const; 55 55 56 56 PassRefPtr<StorageAreaImpl> copy(); -
trunk/Source/WebKit/chromium/ChangeLog
r87525 r87597 1 2011-05-27 Jochen Eisinger <jochen@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Check access policy on all storage operations 6 https://bugs.webkit.org/show_bug.cgi?id=61581 7 8 * src/StorageAreaProxy.cpp: 9 (WebCore::StorageAreaProxy::length): 10 (WebCore::StorageAreaProxy::key): 11 (WebCore::StorageAreaProxy::getItem): 12 (WebCore::StorageAreaProxy::setItem): 13 (WebCore::StorageAreaProxy::removeItem): 14 (WebCore::StorageAreaProxy::clear): 15 (WebCore::StorageAreaProxy::contains): 16 (WebCore::StorageAreaProxy::canAccessStorage): 17 * src/StorageAreaProxy.h: 18 * src/WebStorageAreaImpl.cpp: 19 (WebKit::WebStorageAreaImpl::length): 20 (WebKit::WebStorageAreaImpl::key): 21 (WebKit::WebStorageAreaImpl::getItem): 22 1 23 2011-05-27 Jochen Eisinger <jochen@chromium.org> 2 24 -
trunk/Source/WebKit/chromium/src/StorageAreaProxy.cpp
r87525 r87597 64 64 } 65 65 66 unsigned StorageAreaProxy::length( ) const66 unsigned StorageAreaProxy::length(Frame* frame) const 67 67 { 68 return m_storageArea->length(); 68 if (canAccessStorage(frame)) 69 return m_storageArea->length(); 70 return 0; 69 71 } 70 72 71 String StorageAreaProxy::key(unsigned index ) const73 String StorageAreaProxy::key(unsigned index, Frame* frame) const 72 74 { 73 return m_storageArea->key(index); 75 if (canAccessStorage(frame)) 76 return m_storageArea->key(index); 77 return String(); 74 78 } 75 79 76 String StorageAreaProxy::getItem(const String& key ) const80 String StorageAreaProxy::getItem(const String& key, Frame* frame) const 77 81 { 78 return m_storageArea->getItem(key); 82 if (canAccessStorage(frame)) 83 return m_storageArea->getItem(key); 84 return String(); 79 85 } 80 86 … … 83 89 WebKit::WebStorageArea::Result result = WebKit::WebStorageArea::ResultOK; 84 90 WebKit::WebString oldValue; 85 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); 86 WebKit::WebViewImpl* webView = webFrame->viewImpl(); 87 if (webView->permissionClient() && !webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage)) 91 if (!canAccessStorage(frame)) 88 92 ec = QUOTA_EXCEEDED_ERR; 89 93 else { … … 99 103 String StorageAreaProxy::removeItem(const String& key, Frame* frame) 100 104 { 105 if (!canAccessStorage(frame)) 106 return String(); 101 107 WebKit::WebString oldValue; 102 108 m_storageArea->removeItem(key, frame->document()->url(), oldValue); … … 108 114 bool StorageAreaProxy::clear(Frame* frame) 109 115 { 116 if (!canAccessStorage(frame)) 117 return false; 110 118 bool clearedSomething; 111 119 m_storageArea->clear(frame->document()->url(), clearedSomething); … … 115 123 } 116 124 117 bool StorageAreaProxy::contains(const String& key ) const125 bool StorageAreaProxy::contains(const String& key, Frame* frame) const 118 126 { 119 return !getItem(key ).isNull();127 return !getItem(key, frame).isNull(); 120 128 } 121 129 … … 163 171 } 164 172 173 bool StorageAreaProxy::canAccessStorage(Frame* frame) const 174 { 175 WebKit::WebFrameImpl* webFrame = WebKit::WebFrameImpl::fromFrame(frame); 176 WebKit::WebViewImpl* webView = webFrame->viewImpl(); 177 return !webView->permissionClient() || webView->permissionClient()->allowStorage(webFrame, m_storageType == LocalStorage); 178 } 179 165 180 } // namespace WebCore 166 181 -
trunk/Source/WebKit/chromium/src/StorageAreaProxy.h
r53710 r87597 44 44 45 45 // The HTML5 DOM Storage API 46 virtual unsigned length( ) const;47 virtual String key(unsigned index ) const;48 virtual String getItem(const String& key ) const;46 virtual unsigned length(Frame* sourceFrame) const; 47 virtual String key(unsigned index, Frame* sourceFrame) const; 48 virtual String getItem(const String& key, Frame* sourceFrame) const; 49 49 virtual String setItem(const String& key, const String& value, ExceptionCode& ec, Frame* sourceFrame); 50 50 virtual String removeItem(const String& key, Frame* sourceFrame); 51 51 virtual bool clear(Frame* sourceFrame); 52 virtual bool contains(const String& key ) const;52 virtual bool contains(const String& key, Frame* sourceFrame) const; 53 53 54 54 private: 55 55 void storageEvent(const String& key, const String& oldValue, const String& newValue, StorageType, SecurityOrigin*, Frame* sourceFrame); 56 bool canAccessStorage(Frame*) const; 56 57 57 58 OwnPtr<WebKit::WebStorageArea> m_storageArea; -
trunk/Source/WebKit/chromium/src/WebStorageAreaImpl.cpp
r87525 r87597 54 54 unsigned WebStorageAreaImpl::length() 55 55 { 56 return m_storageArea->length( );56 return m_storageArea->length(0); 57 57 } 58 58 59 59 WebString WebStorageAreaImpl::key(unsigned index) 60 60 { 61 return m_storageArea->key(index );61 return m_storageArea->key(index, 0); 62 62 } 63 63 64 64 WebString WebStorageAreaImpl::getItem(const WebString& key) 65 65 { 66 return m_storageArea->getItem(key );66 return m_storageArea->getItem(key, 0); 67 67 } 68 68 -
trunk/Tools/ChangeLog
r87596 r87597 1 2011-05-27 Jochen Eisinger <jochen@chromium.org> 2 3 Reviewed by Adam Barth. 4 5 Add layoutTestController.setStorageAllowed() to control whether access 6 to the localStorage API is enabled via the WebPermissionClient 7 https://bugs.webkit.org/show_bug.cgi?id=61581 8 9 * DumpRenderTree/chromium/LayoutTestController.cpp: 10 (LayoutTestController::LayoutTestController): 11 (LayoutTestController::setStorageAllowed): 12 * DumpRenderTree/chromium/LayoutTestController.h: 13 * DumpRenderTree/chromium/TestShell.cpp: 14 (TestShell::TestShell): 15 (TestShell::createNewWindow): 16 * DumpRenderTree/chromium/TestShell.h: 17 * DumpRenderTree/chromium/WebPermissions.h: Added. 18 (WebPermissions::WebPermissions): 19 (WebPermissions::allowStorage): 20 (WebPermissions::setStorageAllowed): 21 (WebPermissions::reset): 22 1 23 2011-05-27 Dirk Pranke <dpranke@chromium.org> 2 24 -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.cpp
r87423 r87597 48 48 #include "WebKit.h" 49 49 #include "WebNotificationPresenter.h" 50 #include "WebPermissions.h" 50 51 #include "WebScriptSource.h" 51 52 #include "WebSecurityPolicy.h" … … 215 216 bindMethod("observeStorageTrackerNotifications", &LayoutTestController::observeStorageTrackerNotifications); 216 217 bindMethod("syncLocalStorage", &LayoutTestController::syncLocalStorage); 218 bindMethod("setStorageAllowed", &LayoutTestController::setStorageAllowed); 217 219 218 220 // The fallback method is called when an unknown method is invoked. … … 1821 1823 } 1822 1824 1825 void LayoutTestController::setStorageAllowed(const CppArgumentList& arguments, CppVariant* result) 1826 { 1827 if (arguments.size() > 0 && arguments[0].isBool()) 1828 m_shell->webPermissions()->setStorageAllowed(arguments[0].toBoolean()); 1829 result->setNull(); 1830 } 1831 1823 1832 void LayoutTestController::setPluginsEnabled(const CppArgumentList& arguments, CppVariant* result) 1824 1833 { -
trunk/Tools/DumpRenderTree/chromium/LayoutTestController.h
r87423 r87597 370 370 void observeStorageTrackerNotifications(const CppArgumentList&, CppVariant*); 371 371 void syncLocalStorage(const CppArgumentList&, CppVariant*); 372 void setStorageAllowed(const CppArgumentList&, CppVariant*); 372 373 373 374 // Enable or disable plugins. -
trunk/Tools/DumpRenderTree/chromium/TestShell.cpp
r86930 r87597 41 41 #include "WebHistoryItem.h" 42 42 #include "WebKit.h" 43 #include "WebPermissions.h" 43 44 #include "WebRuntimeFeatures.h" 44 45 #include "WebScriptController.h" … … 114 115 WebRuntimeFeatures::enableFileSystem(true); 115 116 WebRuntimeFeatures::enableJavaScriptI18NAPI(true); 117 m_webPermissions = adoptPtr(new WebPermissions()); 116 118 m_accessibilityController = adoptPtr(new AccessibilityController(this)); 117 119 m_layoutTestController = adoptPtr(new LayoutTestController(this)); … … 243 245 { 244 246 resetWebSettings(*webView()); 247 m_webPermissions->reset(); 245 248 m_accessibilityController->reset(); 246 249 m_layoutTestController->reset(); … … 597 600 WebViewHost* host = new WebViewHost(this); 598 601 WebView* view = WebView::create(host); 602 view->setPermissionClient(webPermissions()); 599 603 view->setDevToolsAgentClient(devToolsAgent); 600 604 host->setWebWidget(view); -
trunk/Tools/DumpRenderTree/chromium/TestShell.h
r86930 r87597 59 59 class DRTDevToolsCallArgs; 60 60 class DRTDevToolsClient; 61 class WebPermissions; 61 62 62 63 struct TestParams { … … 97 98 void applyPreferences() { m_prefs.applyTo(m_webView); } 98 99 100 WebPermissions* webPermissions() { return m_webPermissions.get(); } 101 99 102 void bindJSObjectsToWindow(WebKit::WebFrame*); 100 103 void runFileTest(const TestParams&); … … 192 195 WebViewHost* m_webViewHost; 193 196 WebViewHost* m_devTools; 197 OwnPtr<WebPermissions> m_webPermissions; 194 198 OwnPtr<DRTDevToolsAgent> m_drtDevToolsAgent; 195 199 OwnPtr<DRTDevToolsClient> m_drtDevToolsClient;
Note: See TracChangeset
for help on using the changeset viewer.