Upstreaming browser/ui/uikit_ui_util from iOS.
[chromium-blink-merge.git] / content / renderer / shared_worker_repository.cc
blob46dcb9151f27d834378a623977caf29c7aee256a
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
3 // found in the LICENSE file.
5 #include "content/renderer/shared_worker_repository.h"
7 #include "content/child/child_thread_impl.h"
8 #include "content/common/view_messages.h"
9 #include "content/renderer/render_frame_impl.h"
10 #include "content/renderer/websharedworker_proxy.h"
11 #include "third_party/WebKit/public/web/WebContentSecurityPolicy.h"
12 #include "third_party/WebKit/public/web/WebLocalFrame.h"
14 namespace content {
16 SharedWorkerRepository::SharedWorkerRepository(RenderFrameImpl* render_frame)
17 : RenderFrameObserver(render_frame) {
18 render_frame->GetWebFrame()->setSharedWorkerRepositoryClient(this);
21 SharedWorkerRepository::~SharedWorkerRepository() {}
23 blink::WebSharedWorkerConnector*
24 SharedWorkerRepository::createSharedWorkerConnector(
25 const blink::WebURL& url,
26 const blink::WebString& name,
27 DocumentID document_id,
28 const blink::WebString& content_security_policy,
29 blink::WebContentSecurityPolicyType security_policy_type) {
30 int route_id = MSG_ROUTING_NONE;
31 ViewHostMsg_CreateWorker_Params params;
32 params.url = url;
33 params.name = name;
34 params.content_security_policy = content_security_policy;
35 params.security_policy_type = security_policy_type;
36 params.document_id = document_id;
37 params.render_frame_route_id = render_frame()->GetRoutingID();
38 Send(new ViewHostMsg_CreateWorker(params, &route_id));
39 if (route_id == MSG_ROUTING_NONE)
40 return NULL;
41 documents_with_workers_.insert(document_id);
42 return new WebSharedWorkerProxy(ChildThreadImpl::current()->GetRouter(),
43 document_id,
44 route_id,
45 params.render_frame_route_id);
48 void SharedWorkerRepository::documentDetached(DocumentID document) {
49 std::set<DocumentID>::iterator iter = documents_with_workers_.find(document);
50 if (iter != documents_with_workers_.end()) {
51 // Notify the browser process that the document has shut down.
52 Send(new ViewHostMsg_DocumentDetached(document));
53 documents_with_workers_.erase(iter);
57 } // namespace content