2011-01-10  Adam Barth  <abarth@webkit.org>

        Reviewed by Darin Adler.

        Introduce the notion of a "display-isolated" URL scheme for use by
        Chrome-internal URLs
        https://bugs.webkit.org/show_bug.cgi?id=50182

        This patch adds a Chromium API for registering schemes as
        display-isolated.  In a subsequent patch, I'll change the "chrome"
        scheme in Chrome to be display isolated instead of local.  That will
        prevent file URLs from linking to chrome URLs.

        * public/WebSecurityPolicy.h:
        * src/WebSecurityPolicy.cpp:
        (WebKit::WebSecurityPolicy::registerURLSchemeAsDisplayIsolated):
2011-01-10  Adam Barth  <abarth@webkit.org>

        Reviewed by Darin Adler.

        Introduce the notion of a "display-isolated" URL scheme for use by
        Chrome-internal URLs
        https://bugs.webkit.org/show_bug.cgi?id=50182

        Update to new function name.

        * Api/qwebsecurityorigin.cpp:
        (QWebSecurityOrigin::localSchemes):
2011-01-10  Adam Barth  <abarth@webkit.org>

        Reviewed by Darin Adler.

        Introduce the notion of a "display-isolated" URL scheme for use by
        Chrome-internal URLs
        https://bugs.webkit.org/show_bug.cgi?id=50182

        This patch adds the basic plumbing for display-isolated URL schemes.
        Originally, this patch also had the functional change, but I've split
        that off into a separate patch because the original patch caused a
        performance regression.

        * page/SecurityOrigin.cpp:
        (WebCore::SecurityOrigin::canDisplay):
        * platform/SchemeRegistry.cpp:
        (WebCore::displayIsolatedURLSchemes):
        (WebCore::SchemeRegistry::registerURLSchemeAsLocal):
        (WebCore::SchemeRegistry::removeURLSchemeRegisteredAsLocal):
        (WebCore::SchemeRegistry::localSchemes):
        (WebCore::SchemeRegistry::deprecatedShouldTreatURLAsLocal):
        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsLocal):
        (WebCore::SchemeRegistry::registerURLSchemeAsDisplayIsolated):
        (WebCore::SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated):
        * platform/SchemeRegistry.h:


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75455 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/platform/SchemeRegistry.cpp b/Source/WebCore/platform/SchemeRegistry.cpp
index 58df51a..617acd3 100644
--- a/Source/WebCore/platform/SchemeRegistry.cpp
+++ b/Source/WebCore/platform/SchemeRegistry.cpp
@@ -45,6 +45,12 @@
     return localSchemes;
 }
 
+static URLSchemesMap& displayIsolatedURLSchemes()
+{
+    DEFINE_STATIC_LOCAL(URLSchemesMap, displayIsolatedSchemes, ());
+    return displayIsolatedSchemes;
+}
+
 static URLSchemesMap& secureSchemes()
 {
     DEFINE_STATIC_LOCAL(URLSchemesMap, secureSchemes, ());
@@ -82,7 +88,7 @@
 
 void SchemeRegistry::registerURLSchemeAsLocal(const String& scheme)
 {
-    WebCore::localURLSchemes().add(scheme);
+    localURLSchemes().add(scheme);
 }
 
 void SchemeRegistry::removeURLSchemeRegisteredAsLocal(const String& scheme)
@@ -93,15 +99,15 @@
     if (scheme == "applewebdata")
         return;
 #endif
-    WebCore::localURLSchemes().remove(scheme);
+    localURLSchemes().remove(scheme);
 }
 
-const URLSchemesMap& SchemeRegistry::localURLSchemes()
+const URLSchemesMap& SchemeRegistry::localSchemes()
 {
-    return WebCore::localURLSchemes();
+    return localURLSchemes();
 }
 
-bool SchemeRegistry::shouldTreatURLAsLocal(const String& url)
+bool SchemeRegistry::deprecatedShouldTreatURLAsLocal(const String& url)
 {
     // This avoids an allocation of another String and the HashSet contains()
     // call for the file: and http: schemes.
@@ -118,7 +124,7 @@
         return false;
 
     String scheme = url.left(loc);
-    return WebCore::localURLSchemes().contains(scheme);
+    return localURLSchemes().contains(scheme);
 }
 
 bool SchemeRegistry::shouldTreatURLSchemeAsLocal(const String& scheme)
@@ -136,7 +142,7 @@
     if (scheme.isEmpty())
         return false;
 
-    return WebCore::localURLSchemes().contains(scheme);
+    return localURLSchemes().contains(scheme);
 }
 
 void SchemeRegistry::registerURLSchemeAsNoAccess(const String& scheme)
@@ -149,6 +155,16 @@
     return schemesWithUniqueOrigins().contains(scheme);
 }
 
+void SchemeRegistry::registerURLSchemeAsDisplayIsolated(const String& scheme)
+{
+    displayIsolatedURLSchemes().add(scheme);
+}
+
+bool SchemeRegistry::shouldTreatURLSchemeAsDisplayIsolated(const String& scheme)
+{
+    return displayIsolatedURLSchemes().contains(scheme);
+}
+
 void SchemeRegistry::registerURLSchemeAsSecure(const String& scheme)
 {
     secureSchemes().add(scheme);