summaryrefslogtreecommitdiffstats
path: root/content/worker
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 05:38:17 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-11-01 05:38:17 +0000
commit44fb3fe66e0bad06ed5da0e930bba8e0d34d1667 (patch)
tree569300704710f79d961ebaaca1ae20c0a48f11ac /content/worker
parent4814ed220f72cdf35d40e22b0afa66d8cf1ee044 (diff)
downloadchromium_src-44fb3fe66e0bad06ed5da0e930bba8e0d34d1667.zip
chromium_src-44fb3fe66e0bad06ed5da0e930bba8e0d34d1667.tar.gz
chromium_src-44fb3fe66e0bad06ed5da0e930bba8e0d34d1667.tar.bz2
Send Allow{Database,FileSystem,IndexedDB} sync IPCs directly from worker thread
- To deprecate the notorious WorkerAllowMainThreadBridge & runInMode code in Blink - To simplify the worker class inheritance chain Blink-side change: https://codereview.chromium.org/50773002/ BUG=none Review URL: https://codereview.chromium.org/46583005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@232302 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/worker')
-rw-r--r--content/worker/shared_worker_permission_client_proxy.cc52
-rw-r--r--content/worker/shared_worker_permission_client_proxy.h45
-rw-r--r--content/worker/websharedworkerclient_proxy.cc35
-rw-r--r--content/worker/websharedworkerclient_proxy.h6
4 files changed, 118 insertions, 20 deletions
diff --git a/content/worker/shared_worker_permission_client_proxy.cc b/content/worker/shared_worker_permission_client_proxy.cc
new file mode 100644
index 0000000..dae30ff
--- /dev/null
+++ b/content/worker/shared_worker_permission_client_proxy.cc
@@ -0,0 +1,52 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/worker/shared_worker_permission_client_proxy.h"
+
+#include "content/child/thread_safe_sender.h"
+#include "content/common/worker_messages.h"
+#include "third_party/WebKit/public/platform/WebString.h"
+#include "url/gurl.h"
+
+namespace content {
+
+SharedWorkerPermissionClientProxy::SharedWorkerPermissionClientProxy(
+ const GURL& origin_url,
+ int routing_id,
+ ThreadSafeSender* thread_safe_sender)
+ : origin_url_(origin_url),
+ routing_id_(routing_id),
+ thread_safe_sender_(thread_safe_sender) {
+}
+
+SharedWorkerPermissionClientProxy::~SharedWorkerPermissionClientProxy() {
+}
+
+bool SharedWorkerPermissionClientProxy::allowDatabase(
+ const WebKit::WebString& name,
+ const WebKit::WebString& display_name,
+ unsigned long estimated_size) {
+ bool result = false;
+ thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowDatabase(
+ routing_id_, origin_url_, name, display_name,
+ estimated_size, &result));
+ return result;
+}
+
+bool SharedWorkerPermissionClientProxy::allowFileSystem() {
+ bool result = false;
+ thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowFileSystem(
+ routing_id_, origin_url_, &result));
+ return result;
+}
+
+bool SharedWorkerPermissionClientProxy::allowIndexedDB(
+ const WebKit::WebString& name) {
+ bool result = false;
+ thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowIndexedDB(
+ routing_id_, origin_url_, name, &result));
+ return result;
+}
+
+} // namespace content
diff --git a/content/worker/shared_worker_permission_client_proxy.h b/content/worker/shared_worker_permission_client_proxy.h
new file mode 100644
index 0000000..0a4fdc8
--- /dev/null
+++ b/content/worker/shared_worker_permission_client_proxy.h
@@ -0,0 +1,45 @@
+// Copyright 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_
+#define CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_
+
+#include "base/basictypes.h"
+#include "base/memory/ref_counted.h"
+#include "third_party/WebKit/public/web/WebWorkerPermissionClientProxy.h"
+#include "url/gurl.h"
+
+namespace content {
+
+class ThreadSafeSender;
+
+// This proxy is created on the main renderer thread then passed onto
+// the blink's worker thread.
+class SharedWorkerPermissionClientProxy
+ : public WebKit::WebWorkerPermissionClientProxy {
+ public:
+ SharedWorkerPermissionClientProxy(
+ const GURL& origin_url,
+ int routing_id,
+ ThreadSafeSender* thread_safe_sender);
+ virtual ~SharedWorkerPermissionClientProxy();
+
+ // WebWorkerPermissionClientProxy overrides.
+ virtual bool allowDatabase(const WebKit::WebString& name,
+ const WebKit::WebString& display_name,
+ unsigned long estimated_size);
+ virtual bool allowFileSystem();
+ virtual bool allowIndexedDB(const WebKit::WebString& name);
+
+ private:
+ const GURL origin_url_;
+ const int routing_id_;
+ scoped_refptr<ThreadSafeSender> thread_safe_sender_;
+
+ DISALLOW_COPY_AND_ASSIGN(SharedWorkerPermissionClientProxy);
+};
+
+} // namespace content
+
+#endif // CONTENT_WORKER_SHARED_WORKER_PERMISSION_CLIENT_PROXY_H_
diff --git a/content/worker/websharedworkerclient_proxy.cc b/content/worker/websharedworkerclient_proxy.cc
index 21182b0..29b977b 100644
--- a/content/worker/websharedworkerclient_proxy.cc
+++ b/content/worker/websharedworkerclient_proxy.cc
@@ -11,6 +11,7 @@
#include "content/common/worker_messages.h"
#include "content/public/common/content_switches.h"
#include "content/worker/shared_worker_devtools_agent.h"
+#include "content/worker/shared_worker_permission_client_proxy.h"
#include "content/worker/websharedworker_stub.h"
#include "content/worker/worker_thread.h"
#include "content/worker/worker_webapplicationcachehost_impl.h"
@@ -77,36 +78,30 @@ WebApplicationCacheHost* WebSharedWorkerClientProxy::createApplicationCacheHost(
return host;
}
-// TODO(abarth): Security checks should use WebDocument or WebSecurityOrigin,
-// not WebFrame as the context object because WebFrames can contain different
-// WebDocuments at different times.
+WebKit::WebWorkerPermissionClientProxy*
+WebSharedWorkerClientProxy::createWorkerPermissionClientProxy(
+ const WebKit::WebSecurityOrigin& origin) {
+ if (origin.isUnique())
+ return NULL;
+ return new SharedWorkerPermissionClientProxy(
+ GURL(origin.toString()), route_id_,
+ ChildThread::current()->thread_safe_sender());
+}
+
+// TODO(kinuko): Deprecate these methods.
bool WebSharedWorkerClientProxy::allowDatabase(WebFrame* frame,
const WebString& name,
const WebString& display_name,
unsigned long estimated_size) {
- WebSecurityOrigin origin = frame->document().securityOrigin();
- if (origin.isUnique())
- return false;
-
- bool result = false;
- Send(new WorkerProcessHostMsg_AllowDatabase(
- route_id_, GURL(origin.toString().utf8()), name, display_name,
- estimated_size, &result));
- return result;
+ return false;
}
bool WebSharedWorkerClientProxy::allowFileSystem() {
- bool result = false;
- Send(new WorkerProcessHostMsg_AllowFileSystem(
- route_id_, stub_->url().GetOrigin(), &result));
- return result;
+ return false;
}
bool WebSharedWorkerClientProxy::allowIndexedDB(const WebKit::WebString& name) {
- bool result = false;
- Send(new WorkerProcessHostMsg_AllowIndexedDB(
- route_id_, stub_->url().GetOrigin(), name, &result));
- return result;
+ return false;
}
void WebSharedWorkerClientProxy::dispatchDevToolsMessage(
diff --git a/content/worker/websharedworkerclient_proxy.h b/content/worker/websharedworkerclient_proxy.h
index aef978c..bb51323 100644
--- a/content/worker/websharedworkerclient_proxy.h
+++ b/content/worker/websharedworkerclient_proxy.h
@@ -14,6 +14,7 @@ namespace WebKit {
class WebApplicationCacheHost;
class WebApplicationCacheHostClient;
class WebFrame;
+class WebSecurityOrigin;
}
namespace content {
@@ -39,13 +40,18 @@ class WebSharedWorkerClientProxy : public WebKit::WebSharedWorkerClient {
virtual WebKit::WebApplicationCacheHost* createApplicationCacheHost(
WebKit::WebApplicationCacheHostClient* client);
+ virtual WebKit::WebWorkerPermissionClientProxy*
+ createWorkerPermissionClientProxy(
+ const WebKit::WebSecurityOrigin& origin);
+ // TODO(kinuko): Deprecate these methods.
virtual bool allowDatabase(WebKit::WebFrame* frame,
const WebKit::WebString& name,
const WebKit::WebString& display_name,
unsigned long estimated_size);
virtual bool allowFileSystem();
virtual bool allowIndexedDB(const WebKit::WebString&);
+
virtual void dispatchDevToolsMessage(const WebKit::WebString&);
virtual void saveDevToolsAgentState(const WebKit::WebString&);