OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/renderer/shared_worker_repository.h" | 5 #include "content/renderer/shared_worker_repository.h" |
6 | 6 |
7 #include "content/child/child_thread.h" | 7 #include "content/child/child_thread.h" |
8 #include "content/common/view_messages.h" | 8 #include "content/common/view_messages.h" |
9 #include "content/renderer/render_frame_impl.h" | 9 #include "content/renderer/render_frame_impl.h" |
10 #include "content/renderer/websharedworker_proxy.h" | 10 #include "content/renderer/websharedworker_proxy.h" |
11 #include "third_party/WebKit/public/web/WebFrame.h" | 11 #include "third_party/WebKit/public/web/WebFrame.h" |
12 | 12 |
13 namespace content { | 13 namespace content { |
14 | 14 |
15 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) | 15 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame) |
16 : RenderFrameObserver(render_frame) { | 16 : RenderFrameObserver(render_frame) { |
17 } | 17 } |
18 | 18 |
19 SharedWorkerRepository::~SharedWorkerRepository() {} | 19 SharedWorkerRepository::~SharedWorkerRepository() {} |
20 | 20 |
21 void SharedWorkerRepository::WebFrameCreated(blink::WebFrame* frame) { | 21 void SharedWorkerRepository::WebFrameCreated(blink::WebFrame* frame) { |
22 frame->setSharedWorkerRepositoryClient(this); | 22 frame->setSharedWorkerRepositoryClient(this); |
23 } | 23 } |
24 | 24 |
25 blink::WebSharedWorkerConnector* | 25 blink::WebSharedWorkerConnector* |
26 SharedWorkerRepository::createSharedWorkerConnector( | 26 SharedWorkerRepository::createSharedWorkerConnector( |
27 const blink::WebURL& url, | 27 const blink::WebURL& url, |
28 const blink::WebString& name, | 28 const blink::WebString& name, |
29 DocumentID document_id) { | 29 DocumentID document_id, |
| 30 const blink::WebString& content_security_policy, |
| 31 blink::WebContentSecurityPolicyType security_policy_type) { |
30 int route_id = MSG_ROUTING_NONE; | 32 int route_id = MSG_ROUTING_NONE; |
31 bool exists = false; | 33 bool exists = false; |
32 bool url_mismatch = false; | 34 bool url_mismatch = false; |
33 ViewHostMsg_CreateWorker_Params params; | 35 ViewHostMsg_CreateWorker_Params params; |
34 params.url = url; | 36 params.url = url; |
35 params.name = name; | 37 params.name = name; |
| 38 params.content_security_policy = content_security_policy; |
| 39 params.security_policy_type = security_policy_type; |
36 params.document_id = document_id; | 40 params.document_id = document_id; |
37 params.render_frame_route_id = render_frame()->GetRoutingID(); | 41 params.render_frame_route_id = render_frame()->GetRoutingID(); |
38 params.route_id = MSG_ROUTING_NONE; | 42 params.route_id = MSG_ROUTING_NONE; |
39 params.script_resource_appcache_id = 0; | 43 params.script_resource_appcache_id = 0; |
40 Send(new ViewHostMsg_LookupSharedWorker( | 44 Send(new ViewHostMsg_LookupSharedWorker( |
41 params, &exists, &route_id, &url_mismatch)); | 45 params, &exists, &route_id, &url_mismatch)); |
42 if (url_mismatch) | 46 if (url_mismatch) |
43 return NULL; | 47 return NULL; |
44 documents_with_workers_.insert(document_id); | 48 documents_with_workers_.insert(document_id); |
45 return new WebSharedWorkerProxy(ChildThread::current(), | 49 return new WebSharedWorkerProxy(ChildThread::current(), |
46 document_id, | 50 document_id, |
47 exists, | 51 exists, |
48 route_id, | 52 route_id, |
49 params.render_frame_route_id); | 53 params.render_frame_route_id); |
50 } | 54 } |
51 | 55 |
52 void SharedWorkerRepository::documentDetached(DocumentID document) { | 56 void SharedWorkerRepository::documentDetached(DocumentID document) { |
53 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); | 57 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document); |
54 if (iter != documents_with_workers_.end()) { | 58 if (iter != documents_with_workers_.end()) { |
55 // Notify the browser process that the document has shut down. | 59 // Notify the browser process that the document has shut down. |
56 Send(new ViewHostMsg_DocumentDetached(document)); | 60 Send(new ViewHostMsg_DocumentDetached(document)); |
57 documents_with_workers_.erase(iter); | 61 documents_with_workers_.erase(iter); |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 } // namespace content | 65 } // namespace content |
OLD | NEW |