diff options
author | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 14:09:27 +0000 |
---|---|---|
committer | mhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-21 14:09:27 +0000 |
commit | 9e5be41af9f9946ae195920c13a6cdebddc989c2 (patch) | |
tree | 1b39d0900c7b463e43bf2ef5f381bf2610bc5da2 /webkit | |
parent | 762a91816bcce1e9d406251ec0db132e645bacad (diff) | |
download | chromium_src-9e5be41af9f9946ae195920c13a6cdebddc989c2.zip chromium_src-9e5be41af9f9946ae195920c13a6cdebddc989c2.tar.gz chromium_src-9e5be41af9f9946ae195920c13a6cdebddc989c2.tar.bz2 |
TBR: darin
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@29642 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r-- | webkit/api/public/WebKit.h | 18 | ||||
-rwxr-xr-x | webkit/api/public/WebSecurityPolicy.h | 64 | ||||
-rw-r--r-- | webkit/api/src/WebKit.cpp | 28 | ||||
-rwxr-xr-x | webkit/api/src/WebSecurityPolicy.cpp | 69 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 12 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_shell_webkit_init.h | 5 | ||||
-rw-r--r-- | webkit/webkit.gyp | 2 |
7 files changed, 53 insertions, 145 deletions
diff --git a/webkit/api/public/WebKit.h b/webkit/api/public/WebKit.h index 3be1abe5..cf2cea1 100644 --- a/webkit/api/public/WebKit.h +++ b/webkit/api/public/WebKit.h @@ -32,9 +32,11 @@ #define WebKit_h #include "WebCommon.h" +#include "WebURL.h" namespace WebKit { class WebKitClient; + class WebString; // Must be called on the thread that will be the main WebKit thread before // using any other WebKit APIs. The provided WebKitClient must be non-null @@ -54,6 +56,16 @@ namespace WebKit { WEBKIT_API void setLayoutTestMode(bool); WEBKIT_API bool layoutTestMode(); + // Registers a URL scheme to be treated as a local scheme (i.e., with the + // same security rules as those applied to "file" URLs). This means that + // normal pages cannot link to or access URLs of this scheme. + WEBKIT_API void registerURLSchemeAsLocal(const WebString&); + + // Registers a URL scheme to be treated as a noAccess scheme. This means + // that pages loaded with this URL scheme cannot access pages loaded with + // any other URL scheme. + WEBKIT_API void registerURLSchemeAsNoAccess(const WebString&); + // Enables HTML5 media support. WEBKIT_API void enableMediaPlayer(); @@ -65,6 +77,12 @@ namespace WebKit { WEBKIT_API void enableDatabases(); WEBKIT_API bool databasesEnabled(); + // Support for whitelisting access to origins beyond the same-origin policy. + WEBKIT_API void whiteListAccessFromOrigin( + const WebURL& sourceOrigin, const WebString& destinationProtocol, + const WebString& destinationHost, bool allowDestinationSubdomains); + WEBKIT_API void resetOriginAccessWhiteLists(); + // Enables HTML5 Web Sockets support. WEBKIT_API void enableWebSockets(); WEBKIT_API bool webSocketsEnabled(); diff --git a/webkit/api/public/WebSecurityPolicy.h b/webkit/api/public/WebSecurityPolicy.h deleted file mode 100755 index b0c0ad7..0000000 --- a/webkit/api/public/WebSecurityPolicy.h +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#ifndef WebSecurityPolicy_h -#define WebSecurityPolicy_h - -#include "WebCommon.h" - -namespace WebKit { - class WebString; - class WebURL; - - class WebSecurityPolicy { - public: - // Registers a URL scheme to be treated as a local scheme (i.e., with the - // same security rules as those applied to "file" URLs). This means that - // normal pages cannot link to or access URLs of this scheme. - WEBKIT_API static void registerURLSchemeAsLocal(const WebString&); - - // Registers a URL scheme to be treated as a noAccess scheme. This means - // that pages loaded with this URL scheme cannot access pages loaded with - // any other URL scheme. - WEBKIT_API static void registerURLSchemeAsNoAccess(const WebString&); - - // Support for whitelisting access to origins beyond the same-origin policy. - WEBKIT_API static void whiteListAccessFromOrigin( - const WebURL& sourceOrigin, const WebString& destinationProtocol, - const WebString& destinationHost, bool allowDestinationSubdomains); - WEBKIT_API static void resetOriginAccessWhiteLists(); - - private: - WebSecurityPolicy(); - }; - -} // namespace WebKit - -#endif diff --git a/webkit/api/src/WebKit.cpp b/webkit/api/src/WebKit.cpp index 7a04fe6..c0ea7a3 100644 --- a/webkit/api/src/WebKit.cpp +++ b/webkit/api/src/WebKit.cpp @@ -32,10 +32,13 @@ #include "WebKit.h" #include "WebMediaPlayerClientImpl.h" +#include "WebString.h" #include "AtomicString.h" #include "DOMTimer.h" +#include "FrameLoader.h" #include "Page.h" +#include "SecurityOrigin.h" #include "TextEncoding.h" #include "WebSocket.h" #include "WorkerContextExecutionProxy.h" @@ -94,6 +97,16 @@ bool layoutTestMode() return s_layoutTestMode; } +void registerURLSchemeAsLocal(const WebString& scheme) +{ + WebCore::SecurityOrigin::registerURLSchemeAsLocal(scheme); +} + +void registerURLSchemeAsNoAccess(const WebString& scheme) +{ + WebCore::SecurityOrigin::registerURLSchemeAsNoAccess(scheme); +} + void enableMediaPlayer() { #if ENABLE(VIDEO) @@ -118,6 +131,21 @@ bool databasesEnabled() return s_databasesEnabled; } +void whiteListAccessFromOrigin(const WebURL& sourceOrigin, + const WebString& destinationProtocol, + const WebString& destinationHost, + bool allowDestinationSubdomains) +{ + WebCore::SecurityOrigin::whiteListAccessFromOrigin( + *WebCore::SecurityOrigin::create(sourceOrigin), destinationProtocol, + destinationHost, allowDestinationSubdomains); +} + +void resetOriginAccessWhiteLists() +{ + WebCore::SecurityOrigin::resetOriginAccessWhiteLists(); +} + void enableWebSockets() { #if ENABLE(WEB_SOCKETS) diff --git a/webkit/api/src/WebSecurityPolicy.cpp b/webkit/api/src/WebSecurityPolicy.cpp deleted file mode 100755 index 8218381..0000000 --- a/webkit/api/src/WebSecurityPolicy.cpp +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Copyright (C) 2009 Google Inc. All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ - -#include "config.h" -#include "WebSecurityPolicy.h" - -#include "WebString.h" -#include "WebURL.h" - -#include "FrameLoader.h" -#include "SecurityOrigin.h" - -using namespace WebCore; - -namespace WebKit { - -void WebSecurityPolicy::registerURLSchemeAsLocal(const WebString& scheme) -{ - SecurityOrigin::registerURLSchemeAsLocal(scheme); -} - -void WebSecurityPolicy::registerURLSchemeAsNoAccess(const WebString& scheme) -{ - SecurityOrigin::registerURLSchemeAsNoAccess(scheme); -} - -void WebSecurityPolicy::whiteListAccessFromOrigin(const WebURL& sourceOrigin, - const WebString& destinationProtocol, - const WebString& destinationHost, - bool allowDestinationSubdomains) -{ - SecurityOrigin::whiteListAccessFromOrigin( - *SecurityOrigin::create(sourceOrigin), destinationProtocol, - destinationHost, allowDestinationSubdomains); -} - -void WebSecurityPolicy::resetOriginAccessWhiteLists() -{ - SecurityOrigin::resetOriginAccessWhiteLists(); -} - -} // namespace WebKit diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index db50fac..48ec6f0 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -18,7 +18,6 @@ #include "webkit/api/public/WebFrame.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptSource.h" -#include "webkit/api/public/WebSecurityPolicy.h" #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebView.h" #include "webkit/glue/dom_operations.h" @@ -33,7 +32,6 @@ using std::wstring; using WebKit::WebConsoleMessage; using WebKit::WebScriptSource; -using WebKit::WebSecurityPolicy; using WebKit::WebString; TestShell* LayoutTestController::shell_ = NULL; @@ -441,7 +439,7 @@ void LayoutTestController::Reset() { webHistoryItemCount_.Set(0); SimpleResourceLoaderBridge::SetAcceptAllCookies(false); - WebSecurityPolicy::resetOriginAccessWhiteLists(); + WebKit::resetOriginAccessWhiteLists(); setlocale(LC_ALL, ""); @@ -971,10 +969,10 @@ void LayoutTestController::whiteListAccessFromOrigin( if (!url.isValid()) return; - WebSecurityPolicy::whiteListAccessFromOrigin(url, - WebString::fromUTF8(args[1].ToString()), - WebString::fromUTF8(args[2].ToString()), - args[3].ToBoolean()); + WebKit::whiteListAccessFromOrigin(url, + WebString::fromUTF8(args[1].ToString()), + WebString::fromUTF8(args[2].ToString()), + args[3].ToBoolean()); } void LayoutTestController::clearAllDatabases( diff --git a/webkit/tools/test_shell/test_shell_webkit_init.h b/webkit/tools/test_shell/test_shell_webkit_init.h index 98b0602..6363523 100644 --- a/webkit/tools/test_shell/test_shell_webkit_init.h +++ b/webkit/tools/test_shell/test_shell_webkit_init.h @@ -14,7 +14,6 @@ #include "webkit/api/public/WebData.h" #include "webkit/api/public/WebKit.h" #include "webkit/api/public/WebScriptController.h" -#include "webkit/api/public/WebSecurityPolicy.h" #include "webkit/api/public/WebStorageArea.h" #include "webkit/api/public/WebStorageEventDispatcher.h" #include "webkit/api/public/WebStorageNamespace.h" @@ -46,9 +45,9 @@ class TestShellWebKitInit : public webkit_glue::WebKitClientImpl { WebKit::initialize(this); WebKit::setLayoutTestMode(layout_test_mode); - WebKit::WebSecurityPolicy::registerURLSchemeAsLocal( + WebKit::registerURLSchemeAsLocal( ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); - WebKit::WebSecurityPolicy::registerURLSchemeAsNoAccess( + WebKit::registerURLSchemeAsNoAccess( ASCIIToUTF16(webkit_glue::GetUIResourceProtocol())); WebKit::enableV8SingleThreadMode(); WebKit::registerExtension(extensions_v8::GearsExtension::Get()); diff --git a/webkit/webkit.gyp b/webkit/webkit.gyp index 34fe489..927463a 100644 --- a/webkit/webkit.gyp +++ b/webkit/webkit.gyp @@ -135,7 +135,6 @@ 'api/public/WebScriptController.h', 'api/public/WebScriptSource.h', 'api/public/WebSecurityOrigin.h', - 'api/public/WebSecurityPolicy.h', 'api/public/WebSettings.h', 'api/public/WebSize.h', 'api/public/WebSocketStreamError.h', @@ -231,7 +230,6 @@ 'api/src/WebRange.cpp', 'api/src/WebScriptController.cpp', 'api/src/WebSecurityOrigin.cpp', - 'api/src/WebSecurityPolicy.cpp', 'api/src/WebSettingsImpl.cpp', 'api/src/WebSettingsImpl.h', 'api/src/WebStorageAreaImpl.cpp', |