| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "content/worker/websharedworkerclient_proxy.h" | 5 #include "content/worker/websharedworkerclient_proxy.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "content/child/webmessageportchannel_impl.h" | 10 #include "content/child/webmessageportchannel_impl.h" |
| 11 #include "content/common/worker_messages.h" | 11 #include "content/common/worker_messages.h" |
| 12 #include "content/public/common/content_switches.h" | 12 #include "content/public/common/content_switches.h" |
| 13 #include "content/worker/shared_worker_devtools_agent.h" | 13 #include "content/worker/shared_worker_devtools_agent.h" |
| 14 #include "content/worker/websharedworker_stub.h" | 14 #include "content/worker/websharedworker_stub.h" |
| 15 #include "content/worker/worker_permission_client_proxy.h" |
| 15 #include "content/worker/worker_thread.h" | 16 #include "content/worker/worker_thread.h" |
| 16 #include "content/worker/worker_webapplicationcachehost_impl.h" | 17 #include "content/worker/worker_webapplicationcachehost_impl.h" |
| 17 #include "ipc/ipc_logging.h" | 18 #include "ipc/ipc_logging.h" |
| 18 #include "third_party/WebKit/public/platform/WebString.h" | 19 #include "third_party/WebKit/public/platform/WebString.h" |
| 19 #include "third_party/WebKit/public/platform/WebURL.h" | 20 #include "third_party/WebKit/public/platform/WebURL.h" |
| 20 #include "third_party/WebKit/public/web/WebDocument.h" | 21 #include "third_party/WebKit/public/web/WebDocument.h" |
| 21 #include "third_party/WebKit/public/web/WebFrame.h" | 22 #include "third_party/WebKit/public/web/WebFrame.h" |
| 22 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 23 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 23 | 24 |
| 24 using WebKit::WebApplicationCacheHost; | 25 using WebKit::WebApplicationCacheHost; |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 70 WebKit::WebApplicationCacheHostClient* client) { | 71 WebKit::WebApplicationCacheHostClient* client) { |
| 71 WorkerWebApplicationCacheHostImpl* host = | 72 WorkerWebApplicationCacheHostImpl* host = |
| 72 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), | 73 new WorkerWebApplicationCacheHostImpl(stub_->appcache_init_info(), |
| 73 client); | 74 client); |
| 74 // Remember the id of the instance we create so we have access to that | 75 // Remember the id of the instance we create so we have access to that |
| 75 // value when creating nested dedicated workers in createWorker. | 76 // value when creating nested dedicated workers in createWorker. |
| 76 appcache_host_id_ = host->host_id(); | 77 appcache_host_id_ = host->host_id(); |
| 77 return host; | 78 return host; |
| 78 } | 79 } |
| 79 | 80 |
| 80 // TODO(abarth): Security checks should use WebDocument or WebSecurityOrigin, | 81 WebKit::WebWorkerPermissionClientProxy* |
| 81 // not WebFrame as the context object because WebFrames can contain different | 82 WebSharedWorkerClientProxy::createWorkerPermissionClientProxy( |
| 82 // WebDocuments at different times. | 83 const WebKit::WebSecurityOrigin& origin) { |
| 84 if (origin.isUnique()) |
| 85 return NULL; |
| 86 return new WorkerPermissionClientProxy( |
| 87 GURL(origin.toString()), route_id_, |
| 88 ChildThread::current()->thread_safe_sender()); |
| 89 } |
| 90 |
| 91 // TODO(kinuko): Deprecate these methods. |
| 83 bool WebSharedWorkerClientProxy::allowDatabase(WebFrame* frame, | 92 bool WebSharedWorkerClientProxy::allowDatabase(WebFrame* frame, |
| 84 const WebString& name, | 93 const WebString& name, |
| 85 const WebString& display_name, | 94 const WebString& display_name, |
| 86 unsigned long estimated_size) { | 95 unsigned long estimated_size) { |
| 87 WebSecurityOrigin origin = frame->document().securityOrigin(); | 96 return false; |
| 88 if (origin.isUnique()) | |
| 89 return false; | |
| 90 | |
| 91 bool result = false; | |
| 92 Send(new WorkerProcessHostMsg_AllowDatabase( | |
| 93 route_id_, GURL(origin.toString().utf8()), name, display_name, | |
| 94 estimated_size, &result)); | |
| 95 return result; | |
| 96 } | 97 } |
| 97 | 98 |
| 98 bool WebSharedWorkerClientProxy::allowFileSystem() { | 99 bool WebSharedWorkerClientProxy::allowFileSystem() { |
| 99 bool result = false; | 100 return false; |
| 100 Send(new WorkerProcessHostMsg_AllowFileSystem( | |
| 101 route_id_, stub_->url().GetOrigin(), &result)); | |
| 102 return result; | |
| 103 } | 101 } |
| 104 | 102 |
| 105 bool WebSharedWorkerClientProxy::allowIndexedDB(const WebKit::WebString& name) { | 103 bool WebSharedWorkerClientProxy::allowIndexedDB(const WebKit::WebString& name) { |
| 106 bool result = false; | 104 return false; |
| 107 Send(new WorkerProcessHostMsg_AllowIndexedDB( | |
| 108 route_id_, stub_->url().GetOrigin(), name, &result)); | |
| 109 return result; | |
| 110 } | 105 } |
| 111 | 106 |
| 112 void WebSharedWorkerClientProxy::dispatchDevToolsMessage( | 107 void WebSharedWorkerClientProxy::dispatchDevToolsMessage( |
| 113 const WebString& message) { | 108 const WebString& message) { |
| 114 if (devtools_agent_) | 109 if (devtools_agent_) |
| 115 devtools_agent_->SendDevToolsMessage(message); | 110 devtools_agent_->SendDevToolsMessage(message); |
| 116 } | 111 } |
| 117 | 112 |
| 118 void WebSharedWorkerClientProxy::saveDevToolsAgentState( | 113 void WebSharedWorkerClientProxy::saveDevToolsAgentState( |
| 119 const WebKit::WebString& state) { | 114 const WebKit::WebString& state) { |
| (...skipping 11 matching lines...) Expand all Loading... |
| 131 // page. It's ok to post several of theese, because the first executed task | 126 // page. It's ok to post several of theese, because the first executed task |
| 132 // will exit the message loop and subsequent ones won't be executed. | 127 // will exit the message loop and subsequent ones won't be executed. |
| 133 base::MessageLoop::current()->PostDelayedTask( | 128 base::MessageLoop::current()->PostDelayedTask( |
| 134 FROM_HERE, | 129 FROM_HERE, |
| 135 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, | 130 base::Bind(&WebSharedWorkerClientProxy::workerContextDestroyed, |
| 136 weak_factory_.GetWeakPtr()), | 131 weak_factory_.GetWeakPtr()), |
| 137 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); | 132 base::TimeDelta::FromSeconds(kMaxTimeForRunawayWorkerSeconds)); |
| 138 } | 133 } |
| 139 | 134 |
| 140 } // namespace content | 135 } // namespace content |
| OLD | NEW |