Initialize new web processes with list of auto-start origins for plug-ins
authorjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 20:49:58 +0000 (20:49 +0000)
committerjonlee@apple.com <jonlee@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 11 Dec 2012 20:49:58 +0000 (20:49 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103219
<rdar://problem/12747219>

Reviewed by Anders Carlsson.

Serialize the set of hashes into a vector as a parameter in web process creation.

* Shared/WebProcessCreationParameters.h: Add a parameter for the origin hashes.

* Shared/WebProcessCreationParameters.cpp: Encode/decode that parameter.
(WebKit::WebProcessCreationParameters::encode):
(WebKit::WebProcessCreationParameters::decode):

* UIProcess/Plugins/PlugInAutoStartProvider.cpp:
(WebKit::PlugInAutoStartProvider::autoStartOriginsCopy): Return a vector copy with contents from the
hash set.
* UIProcess/Plugins/PlugInAutoStartProvider.h:
(PlugInAutoStartProvider):

* UIProcess/WebContext.cpp:
(WebKit::WebContext::createNewWebProcess): Populate the parameter with the contents of the set.
* WebProcess/WebProcess.cpp:
(WebKit::WebProcess::initializeWebProcess): Add the items in the vector to the web process' copy of the set.

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

Source/WebKit2/ChangeLog
Source/WebKit2/Shared/WebProcessCreationParameters.cpp
Source/WebKit2/Shared/WebProcessCreationParameters.h
Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.cpp
Source/WebKit2/UIProcess/Plugins/PlugInAutoStartProvider.h
Source/WebKit2/UIProcess/WebContext.cpp
Source/WebKit2/WebProcess/WebProcess.cpp

index 4ec9c5a..e71d473 100644 (file)
@@ -1,3 +1,30 @@
+2012-12-11  Jon Lee  <jonlee@apple.com>
+
+        Initialize new web processes with list of auto-start origins for plug-ins
+        https://bugs.webkit.org/show_bug.cgi?id=103219
+        <rdar://problem/12747219>
+
+        Reviewed by Anders Carlsson.
+
+        Serialize the set of hashes into a vector as a parameter in web process creation.
+
+        * Shared/WebProcessCreationParameters.h: Add a parameter for the origin hashes.
+
+        * Shared/WebProcessCreationParameters.cpp: Encode/decode that parameter.
+        (WebKit::WebProcessCreationParameters::encode):
+        (WebKit::WebProcessCreationParameters::decode):
+
+        * UIProcess/Plugins/PlugInAutoStartProvider.cpp:
+        (WebKit::PlugInAutoStartProvider::autoStartOriginsCopy): Return a vector copy with contents from the
+        hash set.
+        * UIProcess/Plugins/PlugInAutoStartProvider.h:
+        (PlugInAutoStartProvider):
+
+        * UIProcess/WebContext.cpp:
+        (WebKit::WebContext::createNewWebProcess): Populate the parameter with the contents of the set.
+        * WebProcess/WebProcess.cpp:
+        (WebKit::WebProcess::initializeWebProcess): Add the items in the vector to the web process' copy of the set.
+
 2012-12-11  Andreas Kling  <akling@apple.com>
 
         CoreIPC: ArgumentEncoder should have an inline buffer.
index 96fdd6c..5b55cb1 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -121,6 +121,8 @@ void WebProcessCreationParameters::encode(CoreIPC::ArgumentEncoder& encoder) con
 #if ENABLE(NETWORK_PROCESS)
     encoder << usesNetworkProcess;
 #endif
+
+    encoder << plugInAutoStartOrigins;
 }
 
 bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, WebProcessCreationParameters& parameters)
@@ -241,6 +243,9 @@ bool WebProcessCreationParameters::decode(CoreIPC::ArgumentDecoder* decoder, Web
         return false;
 #endif
 
+    if (!decoder->decode(parameters.plugInAutoStartOrigins))
+        return false;
+
     return true;
 }
 
index 64a699f..cda8e45 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2010, 2011, 2012 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -135,6 +135,8 @@ struct WebProcessCreationParameters {
 #if ENABLE(NETWORK_PROCESS)
     bool usesNetworkProcess;
 #endif
+
+    Vector<unsigned> plugInAutoStartOrigins;
 };
 
 } // namespace WebKit
index ff96213..20ff173 100644 (file)
@@ -52,4 +52,11 @@ void PlugInAutoStartProvider::addAutoStartOrigin(const String& pageOrigin, unsig
     m_context->sendToAllProcesses(Messages::WebProcess::DidAddPlugInAutoStartOrigin(plugInOriginHash));
 }
 
+Vector<unsigned> PlugInAutoStartProvider::autoStartOriginsCopy() const
+{
+    Vector<unsigned> copyVector;
+    copyToVector(m_autoStartHashes, copyVector);
+    return copyVector;
+}
+
 } // namespace WebKit
index 22a9d58..15cbe9c 100644 (file)
@@ -41,6 +41,7 @@ public:
     explicit PlugInAutoStartProvider(WebContext*);
 
     void addAutoStartOrigin(const String& pageOrigin, unsigned plugInOriginHash);
+    Vector<unsigned> autoStartOriginsCopy() const;
 
 private:
     WebContext* m_context;
index bd06ffa..dcec5bc 100644 (file)
@@ -465,6 +465,8 @@ WebProcessProxy* WebContext::createNewWebProcess()
     parameters.usesNetworkProcess = m_usesNetworkProcess;
 #endif
 
+    parameters.plugInAutoStartOrigins = m_plugInAutoStartProvider.autoStartOriginsCopy();
+
     // Add any platform specific parameters
     platformInitializeWebProcess(parameters);
 
index c74c315..09df889 100644 (file)
@@ -304,6 +304,9 @@ void WebProcess::initializeWebProcess(const WebProcessCreationParameters& parame
     ensureNetworkProcessConnection();
 #endif
     setTerminationTimeout(parameters.terminationTimeout);
+
+    for (size_t i = 0; i < parameters.plugInAutoStartOrigins.size(); ++i)
+        didAddPlugInAutoStartOrigin(parameters.plugInAutoStartOrigins[i]);
 }
 
 #if ENABLE(NETWORK_PROCESS)