Add ability for WK2 to set domain relaxation forbidden for a URL scheme.
authorjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Oct 2010 14:42:35 +0000 (14:42 +0000)
committerjberlin@webkit.org <jberlin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 Oct 2010 14:42:35 +0000 (14:42 +0000)
https://bugs.webkit.org/show_bug.cgi?id=47562

Reviewed by Jon Honeycutt.

Add the schemes for which domain relaxation is forbidden to the
WebProcessCreationParameters.
* Shared/WebProcessCreationParameters.cpp:
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):
* Shared/WebProcessCreationParameters.h:

* UIProcess/API/C/WKContext.cpp:
(WKContextSetDomainRelaxationForbiddenForURLScheme):
* UIProcess/API/C/WKContextPrivate.h:

* UIProcess/WebContext.cpp:
(WebKit::WebContext::ensureWebProcess):
Copy over the schemes for which domain relaxation is forbidden to
WebProcessCreationParameters.
(WebKit::WebContext::setDomainRelaxationForbiddenForURLScheme):
Only send a message to the WebProcess if it is valid.
* UIProcess/WebContext.h:

* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess):
Set domain relaxation forbidden for the schemes in
WebProcesCreationParameters.urlSchemesForWhichDomainRelaxationIsForbidden.
(WebKit::WebProcess::setDomainRelaxationForbiddenForURLScheme):
* WebProcess/WebProcess.h:

* WebProcess/WebProcess.messages.in:
Add the SetDomainRelaxationFobiddenForURLScheme message.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69661 268f45cc-cd09-0410-ab3c-d52691b4dbfc

WebKit2/ChangeLog
WebKit2/Shared/WebProcessCreationParameters.cpp
WebKit2/Shared/WebProcessCreationParameters.h
WebKit2/UIProcess/API/C/WKContext.cpp
WebKit2/UIProcess/API/C/WKContextPrivate.h
WebKit2/UIProcess/WebContext.cpp
WebKit2/UIProcess/WebContext.h
WebKit2/WebProcess/WebProcess.cpp
WebKit2/WebProcess/WebProcess.h
WebKit2/WebProcess/WebProcess.messages.in

index b4393c8..36eb7fd 100644 (file)
@@ -1,3 +1,39 @@
+2010-10-12  Jessie Berlin  <jberlin@apple.com>
+
+        Reviewed by Jon Honeycutt.
+
+        Add ability for WK2 to set domain relaxation forbidden for a URL scheme.
+        https://bugs.webkit.org/show_bug.cgi?id=47562
+
+        Add the schemes for which domain relaxation is forbidden to the
+        WebProcessCreationParameters.
+        * Shared/WebProcessCreationParameters.cpp:
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+        * Shared/WebProcessCreationParameters.h:
+
+        * UIProcess/API/C/WKContext.cpp:
+        (WKContextSetDomainRelaxationForbiddenForURLScheme):
+        * UIProcess/API/C/WKContextPrivate.h:
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::ensureWebProcess):
+        Copy over the schemes for which domain relaxation is forbidden to
+        WebProcessCreationParameters.
+        (WebKit::WebContext::setDomainRelaxationForbiddenForURLScheme):
+        Only send a message to the WebProcess if it is valid.
+        * UIProcess/WebContext.h:
+
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess):
+        Set domain relaxation forbidden for the schemes in
+        WebProcesCreationParameters.urlSchemesForWhichDomainRelaxationIsForbidden.
+        (WebKit::WebProcess::setDomainRelaxationForbiddenForURLScheme):
+        * WebProcess/WebProcess.h:
+
+        * WebProcess/WebProcess.messages.in:
+        Add the SetDomainRelaxationFobiddenForURLScheme message.
+
 2010-10-13  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Reviewed by Kenneth Rohde Christiansen.
index 57f1b2b..3d24fa0 100644 (file)
@@ -47,6 +47,7 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder* encoder) con
     encoder->encode(applicationCacheDirectory);
     encoder->encode(urlSchemesRegistererdAsEmptyDocument);
     encoder->encode(urlSchemesRegisteredAsSecure);
+    encoder->encode(urlSchemesForWhichDomainRelaxationIsForbidden);
     encoder->encode(static_cast<uint32_t>(cacheModel));
     encoder->encode(shouldTrackVisitedLinks);
 
@@ -72,6 +73,8 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
     if (!decoder->decode(parameters.urlSchemesRegisteredAsSecure))
         return false;
+    if (!decoder->decode(parameters.urlSchemesForWhichDomainRelaxationIsForbidden))
+        return false;
 
     uint32_t cacheModel;
     if (!decoder->decode(cacheModel))
index a4aba7f..b524a81 100644 (file)
@@ -55,6 +55,7 @@ struct WebProcessCreationParameters {
     String applicationCacheDirectory;
     Vector<String> urlSchemesRegistererdAsEmptyDocument;
     Vector<String> urlSchemesRegisteredAsSecure;
+    Vector<String> urlSchemesForWhichDomainRelaxationIsForbidden;
 
     CacheModel cacheModel;
     bool shouldTrackVisitedLinks;
index b820946..e53275e 100644 (file)
@@ -125,3 +125,8 @@ void WKContextRegisterURLSchemeAsSecure(WKContextRef contextRef, WKStringRef url
 {
     toImpl(contextRef)->registerURLSchemeAsSecure(toImpl(urlScheme)->string());
 }
+
+void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef contextRef, WKStringRef urlScheme)
+{
+    toImpl(contextRef)->setDomainRelaxationForbiddenForURLScheme(toImpl(urlScheme)->string());
+}
index 80024f1..0151e9d 100644 (file)
@@ -50,6 +50,8 @@ WK_EXPORT void _WKContextRegisterURLSchemeAsEmptyDocument(WKContextRef context,
 
 WK_EXPORT void WKContextRegisterURLSchemeAsSecure(WKContextRef context, WKStringRef urlScheme);
 
+WK_EXPORT void WKContextSetDomainRelaxationForbiddenForURLScheme(WKContextRef context, WKStringRef urlScheme);
+
 #ifdef __cplusplus
 }
 #endif
index 9c28232..c94c0f3 100644 (file)
@@ -153,6 +153,7 @@ void WebContext::ensureWebProcess()
     
     copyToVector(m_schemesToRegisterAsEmptyDocument, parameters.urlSchemesRegistererdAsEmptyDocument);
     copyToVector(m_schemesToRegisterAsSecure, parameters.urlSchemesRegisteredAsSecure);
+    copyToVector(m_schemesToSetDomainRelaxationForbiddenFor, parameters.urlSchemesForWhichDomainRelaxationIsForbidden);
 
     // Add any platform specific parameters
     platformInitializeWebProcess(parameters);
@@ -321,6 +322,16 @@ void WebContext::registerURLSchemeAsSecure(const String& urlScheme)
     m_process->send(Messages::WebProcess::RegisterURLSchemeAsSecure(urlScheme), 0);
 }
 
+void WebContext::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme)
+{
+    m_schemesToSetDomainRelaxationForbiddenFor.add(urlScheme);
+
+    if (!hasValidProcess())
+        return;
+
+    m_process->send(Messages::WebProcess::SetDomainRelaxationForbiddenForURLScheme(urlScheme), 0);
+}
+
 void WebContext::addVisitedLink(const String& visitedURL)
 {
     if (visitedURL.isEmpty())
index 0364faf..314eb20 100644 (file)
@@ -103,7 +103,8 @@ public:
     
     void registerURLSchemeAsEmptyDocument(const String&);
     void registerURLSchemeAsSecure(const String&);
-    
+    void setDomainRelaxationForbiddenForURLScheme(const String&);
+
     void addVisitedLink(const String&);
     void addVisitedLink(WebCore::LinkHash);
 
@@ -144,6 +145,8 @@ private:
         
     HashSet<String> m_schemesToRegisterAsEmptyDocument;
     HashSet<String> m_schemesToRegisterAsSecure;
+    HashSet<String> m_schemesToSetDomainRelaxationForbiddenFor;
+
     Vector<pair<String, RefPtr<APIObject> > > m_pendingMessagesToPostToInjectedBundle;
 
     CacheModel m_cacheModel;
index ed9e5cb..9a7f489 100644 (file)
@@ -41,6 +41,7 @@
 #include <WebCore/Page.h>
 #include <WebCore/PageGroup.h>
 #include <WebCore/SchemeRegistry.h>
+#include <WebCore/SecurityOrigin.h>
 #include <WebCore/Settings.h>
 #include <wtf/PassRefPtr.h>
 #include <wtf/RandomNumber.h>
@@ -139,6 +140,9 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
     for (size_t i = 0; i < parameters.urlSchemesRegisteredAsSecure.size(); ++i)
         registerURLSchemeAsSecure(parameters.urlSchemesRegisteredAsSecure[i]);
 
+    for (size_t i = 0; i < parameters.urlSchemesForWhichDomainRelaxationIsForbidden.size(); ++i)
+        setDomainRelaxationForbiddenForURLScheme(parameters.urlSchemesForWhichDomainRelaxationIsForbidden[i]);
+
 #if USE(ACCELERATED_COMPOSITING) && PLATFORM(MAC)
     m_compositingRenderServerPort = parameters.acceleratedCompositingPort.port();
 #endif
@@ -162,6 +166,11 @@ void WebProcess::registerURLSchemeAsSecure(const String& urlScheme) const
     SchemeRegistry::registerURLSchemeAsSecure(urlScheme);
 }
 
+void WebProcess::setDomainRelaxationForbiddenForURLScheme(const String& urlScheme) const
+{
+    SecurityOrigin::setDomainRelaxationForbiddenForURLScheme(true, urlScheme);
+}
+
 void WebProcess::setVisitedLinkTable(const SharedMemory::Handle& handle)
 {
     RefPtr<SharedMemory> sharedMemory = SharedMemory::create(handle, SharedMemory::ReadOnly);
index 26ff1df..b0d3703 100644 (file)
@@ -91,6 +91,7 @@ private:
     void setShouldTrackVisitedLinks(bool);
     void registerURLSchemeAsEmptyDocument(const String&);
     void registerURLSchemeAsSecure(const String&) const;
+    void setDomainRelaxationForbiddenForURLScheme(const String&) const;
 #if PLATFORM(WIN)
     void setShouldPaintNativeControls(bool);
 #endif
index 291e11c..50b8afb 100644 (file)
@@ -37,6 +37,7 @@ messages -> WebProcess {
     SetCacheModel(uint32_t cacheModel)
     RegisterURLSchemeAsEmptyDocument(WTF::String scheme)
     RegisterURLSchemeAsSecure(WTF::String scheme)
+    SetDomainRelaxationForbiddenForURLScheme(WTF::String scheme)
 #if PLATFORM(WIN)
     SetShouldPaintNativeControls(bool shouldPaintNativeControls)
 #endif