1 // Copyright 2014 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.
4
5 #include "content/renderer/shared_worker/embedded_shared_worker_permission_client_proxy.h"
6
7 #include "content/child/thread_safe_sender.h"
8 #include "content/common/worker_messages.h"
9 #include "third_party/WebKit/public/platform/WebString.h"
10 #include "url/gurl.h"
11
12 namespace content {
13
14 EmbeddedSharedWorkerPermissionClientProxy::
EmbeddedSharedWorkerPermissionClientProxy(const GURL & origin_url,bool is_unique_origin,int routing_id,ThreadSafeSender * thread_safe_sender)15 EmbeddedSharedWorkerPermissionClientProxy(
16 const GURL& origin_url,
17 bool is_unique_origin,
18 int routing_id,
19 ThreadSafeSender* thread_safe_sender)
20 : origin_url_(origin_url),
21 is_unique_origin_(is_unique_origin),
22 routing_id_(routing_id),
23 thread_safe_sender_(thread_safe_sender) {
24 }
25
26 EmbeddedSharedWorkerPermissionClientProxy::
~EmbeddedSharedWorkerPermissionClientProxy()27 ~EmbeddedSharedWorkerPermissionClientProxy() {
28 }
29
allowDatabase(const blink::WebString & name,const blink::WebString & display_name,unsigned long estimated_size)30 bool EmbeddedSharedWorkerPermissionClientProxy::allowDatabase(
31 const blink::WebString& name,
32 const blink::WebString& display_name,
33 unsigned long estimated_size) {
34 if (is_unique_origin_)
35 return false;
36 bool result = false;
37 thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowDatabase(
38 routing_id_, origin_url_, name, display_name, estimated_size, &result));
39 return result;
40 }
41
requestFileSystemAccessSync()42 bool EmbeddedSharedWorkerPermissionClientProxy::requestFileSystemAccessSync() {
43 if (is_unique_origin_)
44 return false;
45 bool result = false;
46 thread_safe_sender_->Send(
47 new WorkerProcessHostMsg_RequestFileSystemAccessSync(
48 routing_id_, origin_url_, &result));
49 return result;
50 }
51
allowIndexedDB(const blink::WebString & name)52 bool EmbeddedSharedWorkerPermissionClientProxy::allowIndexedDB(
53 const blink::WebString& name) {
54 if (is_unique_origin_)
55 return false;
56 bool result = false;
57 thread_safe_sender_->Send(new WorkerProcessHostMsg_AllowIndexedDB(
58 routing_id_, origin_url_, name, &result));
59 return result;
60 }
61
62 } // namespace content
63