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