Remove SchemeRegistry and WebSecurityPolicy.

Mojo handles the security of our network layer, so we don't need
SchemeRegistry, and WebSecurityPolicy was just a wrapper around it.

R=eseidel@google.com

Review URL: https://codereview.chromium.org/758233004
This commit is contained in:
Elliott Sprehn 2014-12-03 16:24:36 -08:00
parent e929430811
commit 1771ec30ea
12 changed files with 0 additions and 510 deletions

View File

@ -134,7 +134,6 @@
#include "sky/engine/platform/network/HTTPParsers.h"
#include "sky/engine/platform/scroll/Scrollbar.h"
#include "sky/engine/platform/text/SegmentedString.h"
#include "sky/engine/platform/weborigin/SchemeRegistry.h"
#include "sky/engine/public/platform/Platform.h"
#include "sky/engine/core/inspector/ScriptCallStack.h"
#include "sky/engine/wtf/CurrentTime.h"

View File

@ -606,8 +606,6 @@ component("platform") {
"weborigin/KURLHash.h",
"weborigin/Referrer.h",
"weborigin/ReferrerPolicy.h",
"weborigin/SchemeRegistry.cpp",
"weborigin/SchemeRegistry.h",
"weborigin/SecurityPolicy.cpp",
"weborigin/SecurityPolicy.h",
"WebThread.cpp",

View File

@ -1,253 +0,0 @@
/*
* Copyright (C) 2010 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``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 APPLE COMPUTER, INC. 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 "sky/engine/config.h"
#include "sky/engine/platform/weborigin/SchemeRegistry.h"
#include "sky/engine/wtf/MainThread.h"
#include "sky/engine/wtf/text/StringBuilder.h"
namespace blink {
static URLSchemesMap& localURLSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, localSchemes, ());
if (localSchemes.isEmpty())
localSchemes.add("file");
return localSchemes;
}
static URLSchemesMap& displayIsolatedURLSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, displayIsolatedSchemes, ());
return displayIsolatedSchemes;
}
static URLSchemesMap& secureSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, secureSchemes, ());
if (secureSchemes.isEmpty()) {
secureSchemes.add("https");
secureSchemes.add("about");
secureSchemes.add("data");
secureSchemes.add("wss");
}
return secureSchemes;
}
static URLSchemesMap& schemesWithUniqueOrigins()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, schemesWithUniqueOrigins, ());
if (schemesWithUniqueOrigins.isEmpty()) {
schemesWithUniqueOrigins.add("about");
schemesWithUniqueOrigins.add("javascript");
// This is a willful violation of HTML5.
// See https://bugs.webkit.org/show_bug.cgi?id=11885
schemesWithUniqueOrigins.add("data");
}
return schemesWithUniqueOrigins;
}
static URLSchemesMap& emptyDocumentSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, emptyDocumentSchemes, ());
if (emptyDocumentSchemes.isEmpty())
emptyDocumentSchemes.add("about");
return emptyDocumentSchemes;
}
static HashSet<String>& schemesForbiddenFromDomainRelaxation()
{
DEFINE_STATIC_LOCAL(HashSet<String>, schemes, ());
return schemes;
}
static URLSchemesMap& canDisplayOnlyIfCanRequestSchemes()
{
DEFINE_STATIC_LOCAL(URLSchemesMap, canDisplayOnlyIfCanRequestSchemes, ());
if (canDisplayOnlyIfCanRequestSchemes.isEmpty()) {
canDisplayOnlyIfCanRequestSchemes.add("blob");
canDisplayOnlyIfCanRequestSchemes.add("filesystem");
}
return canDisplayOnlyIfCanRequestSchemes;
}
void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme)
{
localURLSchemes().add(scheme);
}
void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
{
if (scheme == "file")
return;
localURLSchemes().remove(scheme);
}
const URLSchemesMap& SchemeRegistry::localSchemes()
{
return localURLSchemes();
}
static URLSchemesMap& CORSEnabledSchemes()
{
// FIXME: http://bugs.webkit.org/show_bug.cgi?id=77160
DEFINE_STATIC_LOCAL(URLSchemesMap, CORSEnabledSchemes, ());
if (CORSEnabledSchemes.isEmpty()) {
CORSEnabledSchemes.add("http");
CORSEnabledSchemes.add("https");
CORSEnabledSchemes.add("data");
}
return CORSEnabledSchemes;
}
bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
{
if (scheme.isEmpty())
return false;
return localURLSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme)
{
schemesWithUniqueOrigins().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsNoAccess(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesWithUniqueOrigins().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme)
{
displayIsolatedURLSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme)
{
if (scheme.isEmpty())
return false;
return displayIsolatedURLSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme)
{
secureSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsSecure(const String& scheme)
{
if (scheme.isEmpty())
return false;
return secureSchemes().contains(scheme);
}
void SchemeRegistry::registerURLSchemeAsEmptyDocument(const String& scheme)
{
emptyDocumentSchemes().add(scheme);
}
bool SchemeRegistry::shouldLoadURLSchemeAsEmptyDocument(const String& scheme)
{
if (scheme.isEmpty())
return false;
return emptyDocumentSchemes().contains(scheme);
}
void SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String& scheme)
{
if (scheme.isEmpty())
return;
if (forbidden)
schemesForbiddenFromDomainRelaxation().add(scheme);
else
schemesForbiddenFromDomainRelaxation().remove(scheme);
}
bool SchemeRegistry::isDomainRelaxationForbiddenForURLScheme(const String& scheme)
{
if (scheme.isEmpty())
return false;
return schemesForbiddenFromDomainRelaxation().contains(scheme);
}
bool SchemeRegistry::canDisplayOnlyIfCanRequest(const String& scheme)
{
if (scheme.isEmpty())
return false;
return canDisplayOnlyIfCanRequestSchemes().contains(scheme);
}
void SchemeRegistry::registerAsCanDisplayOnlyIfCanRequest(const String& scheme)
{
canDisplayOnlyIfCanRequestSchemes().add(scheme);
}
void SchemeRegistry::registerURLSchemeAsCORSEnabled(const String& scheme)
{
CORSEnabledSchemes().add(scheme);
}
bool SchemeRegistry::shouldTreatURLSchemeAsCORSEnabled(const String& scheme)
{
if (scheme.isEmpty())
return false;
return CORSEnabledSchemes().contains(scheme);
}
String SchemeRegistry::listOfCORSEnabledURLSchemes()
{
StringBuilder builder;
const URLSchemesMap& corsEnabledSchemes = CORSEnabledSchemes();
bool addSeparator = false;
for (URLSchemesMap::const_iterator it = corsEnabledSchemes.begin(); it != corsEnabledSchemes.end(); ++it) {
if (addSeparator)
builder.appendLiteral(", ");
else
addSeparator = true;
builder.append(*it);
}
return builder.toString();
}
} // namespace blink

View File

@ -1,82 +0,0 @@
/*
* Copyright (C) 2010 Apple 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:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. 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.
*
* THIS SOFTWARE IS PROVIDED BY APPLE, INC. ``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 APPLE COMPUTER, INC. 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 SKY_ENGINE_PLATFORM_WEBORIGIN_SCHEMEREGISTRY_H_
#define SKY_ENGINE_PLATFORM_WEBORIGIN_SCHEMEREGISTRY_H_
#include "sky/engine/platform/PlatformExport.h"
#include "sky/engine/wtf/HashSet.h"
#include "sky/engine/wtf/text/StringHash.h"
#include "sky/engine/wtf/text/WTFString.h"
namespace blink {
typedef HashSet<String, CaseFoldingHash> URLSchemesMap;
class PLATFORM_EXPORT SchemeRegistry {
public:
static void registerURLSchemeAsLocal(const String&);
static void removeURLSchemeRegisteredAsLocal(const String&);
static const URLSchemesMap& localSchemes();
static bool shouldTreatURLSchemeAsLocal(const String&);
// Secure schemes do not trigger mixed content warnings. For example,
// https and data are secure schemes because they cannot be corrupted by
// active network attackers.
static void registerURLSchemeAsSecure(const String&);
static bool shouldTreatURLSchemeAsSecure(const String&);
static void registerURLSchemeAsNoAccess(const String&);
static bool shouldTreatURLSchemeAsNoAccess(const String&);
// Display-isolated schemes can only be displayed (in the sense of
// SecurityOrigin::canDisplay) by documents from the same scheme.
static void registerURLSchemeAsDisplayIsolated(const String&);
static bool shouldTreatURLSchemeAsDisplayIsolated(const String&);
static void registerURLSchemeAsEmptyDocument(const String&);
static bool shouldLoadURLSchemeAsEmptyDocument(const String&);
static void setDomainRelaxationForbiddenForURLScheme(bool forbidden, const String&);
static bool isDomainRelaxationForbiddenForURLScheme(const String&);
// Such schemes should delegate to SecurityOrigin::canRequest for any URL
// passed to SecurityOrigin::canDisplay.
static bool canDisplayOnlyIfCanRequest(const String& scheme);
static void registerAsCanDisplayOnlyIfCanRequest(const String& scheme);
// Allow non-HTTP schemes to be registered to allow CORS requests.
static void registerURLSchemeAsCORSEnabled(const String& scheme);
static bool shouldTreatURLSchemeAsCORSEnabled(const String& scheme);
// Serialize the registered schemes in a comma-separated list.
static String listOfCORSEnabledURLSchemes();
};
} // namespace blink
#endif // SKY_ENGINE_PLATFORM_WEBORIGIN_SCHEMEREGISTRY_H_

View File

@ -135,7 +135,6 @@ source_set("web_headers") {
"web/WebScriptBindings.h",
"web/WebScriptController.h",
"web/WebScriptSource.h",
"web/WebSecurityPolicy.h",
"web/WebSettings.h",
"web/WebSpellCheckClient.h",
"web/WebTestingSupport.h",

View File

@ -1,82 +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 SKY_ENGINE_PUBLIC_WEB_WEBSECURITYPOLICY_H_
#define SKY_ENGINE_PUBLIC_WEB_WEBSECURITYPOLICY_H_
#include "../platform/WebCommon.h"
#include "../platform/WebReferrerPolicy.h"
namespace blink {
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.
BLINK_EXPORT 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.
BLINK_EXPORT static void registerURLSchemeAsNoAccess(const WebString&);
// Registers a URL scheme to be treated as display-isolated. This means
// that pages cannot display these URLs unless they are from the same
// scheme. For example, pages in other origin cannot create iframes or
// hyperlinks to URLs with the scheme.
BLINK_EXPORT static void registerURLSchemeAsDisplayIsolated(const WebString&);
// Registers a URL scheme to not generate mixed content warnings when
// included by an HTTPS page.
BLINK_EXPORT static void registerURLSchemeAsSecure(const WebString&);
// Registers a non-HTTP URL scheme which can be sent CORS requests.
BLINK_EXPORT static void registerURLSchemeAsCORSEnabled(const WebString&);
// Registers a URL scheme as strictly empty documents, allowing them to
// commit synchronously.
BLINK_EXPORT static void registerURLSchemeAsEmptyDocument(const WebString&);
// Returns the referrer modified according to the referrer policy for a
// navigation to a given URL. If the referrer returned is empty, the
// referrer header should be omitted.
BLINK_EXPORT static WebString generateReferrerHeader(WebReferrerPolicy, const WebURL&, const WebString& referrer);
private:
WebSecurityPolicy();
};
} // namespace blink
#endif // SKY_ENGINE_PUBLIC_WEB_WEBSECURITYPOLICY_H_

View File

@ -105,9 +105,6 @@ public:
virtual bool isActive() const = 0;
virtual void setIsActive(bool) = 0;
// Allows disabling domain relaxation.
virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) = 0;
// Frames --------------------------------------------------------------
virtual WebFrame* mainFrame() = 0;

View File

@ -79,7 +79,6 @@ component("web") {
"WebScopedUserGesture.cpp",
"WebScriptBindings.cpp",
"WebScriptController.cpp",
"WebSecurityPolicy.cpp",
"WebSettingsImpl.cpp",
"WebSettingsImpl.h",
"WebTextCheckingCompletionImpl.cpp",

View File

@ -124,7 +124,6 @@
#include "sky/engine/platform/scroll/ScrollTypes.h"
#include "sky/engine/platform/scroll/Scrollbar.h"
#include "sky/engine/platform/weborigin/KURL.h"
#include "sky/engine/platform/weborigin/SchemeRegistry.h"
#include "sky/engine/platform/weborigin/SecurityPolicy.h"
#include "sky/engine/public/platform/Platform.h"
#include "sky/engine/public/platform/WebFloatPoint.h"

View File

@ -1,77 +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 "sky/engine/config.h"
#include "sky/engine/public/web/WebSecurityPolicy.h"
#include "sky/engine/platform/weborigin/KURL.h"
#include "sky/engine/platform/weborigin/SchemeRegistry.h"
#include "sky/engine/platform/weborigin/SecurityPolicy.h"
#include "sky/engine/public/platform/WebString.h"
#include "sky/engine/public/platform/WebURL.h"
namespace blink {
void WebSecurityPolicy::registerURLSchemeAsLocal(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsLocal(scheme);
}
void WebSecurityPolicy::registerURLSchemeAsNoAccess(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsNoAccess(scheme);
}
void WebSecurityPolicy::registerURLSchemeAsDisplayIsolated(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsDisplayIsolated(scheme);
}
void WebSecurityPolicy::registerURLSchemeAsSecure(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsSecure(scheme);
}
void WebSecurityPolicy::registerURLSchemeAsCORSEnabled(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsCORSEnabled(scheme);
}
void WebSecurityPolicy::registerURLSchemeAsEmptyDocument(const WebString& scheme)
{
SchemeRegistry::registerURLSchemeAsEmptyDocument(scheme);
}
WebString WebSecurityPolicy::generateReferrerHeader(WebReferrerPolicy referrerPolicy, const WebURL& url, const WebString& referrer)
{
return SecurityPolicy::generateReferrerHeader(static_cast<ReferrerPolicy>(referrerPolicy), url, referrer);
}
} // namespace blink

View File

@ -76,7 +76,6 @@
#include "sky/engine/platform/graphics/Image.h"
#include "sky/engine/platform/graphics/ImageBuffer.h"
#include "sky/engine/platform/scroll/Scrollbar.h"
#include "sky/engine/platform/weborigin/SchemeRegistry.h"
#include "sky/engine/public/platform/Platform.h"
#include "sky/engine/public/platform/WebFloatPoint.h"
#include "sky/engine/public/platform/WebGestureCurve.h"
@ -1355,11 +1354,6 @@ bool WebViewImpl::isActive() const
return page() ? page()->focusController().isActive() : false;
}
void WebViewImpl::setDomainRelaxationForbidden(bool forbidden, const WebString& scheme)
{
SchemeRegistry::setDomainRelaxationForbiddenForURLScheme(forbidden, String(scheme));
}
void WebViewImpl::didCommitLoad(bool isNewNavigation, bool isNavigationWithinPage)
{
endActiveFlingAnimation();

View File

@ -114,7 +114,6 @@ public:
virtual void setTabKeyCyclesThroughElements(bool value) override;
virtual bool isActive() const override;
virtual void setIsActive(bool value) override;
virtual void setDomainRelaxationForbidden(bool, const WebString& scheme) override;
virtual WebFrame* mainFrame() override;
virtual WebFrame* focusedFrame() override;
virtual void setFocusedFrame(WebFrame*) override;