Add testing/scripts/OWNERS
[chromium-blink-merge.git] / chrome / renderer / worker_permission_client_proxy.cc
blob983181cce709655b427d0fdc02e932024e60d917
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 "chrome/common/render_messages.h"
6 #include "chrome/renderer/worker_permission_client_proxy.h"
7 #include "content/public/renderer/render_frame.h"
8 #include "content/public/renderer/render_thread.h"
9 #include "ipc/ipc_sync_message_filter.h"
10 #include "third_party/WebKit/public/platform/WebPermissionCallbacks.h"
11 #include "third_party/WebKit/public/web/WebDocument.h"
12 #include "third_party/WebKit/public/web/WebFrame.h"
13 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
15 WorkerPermissionClientProxy::WorkerPermissionClientProxy(
16 content::RenderFrame* render_frame,
17 blink::WebFrame* frame)
18 : routing_id_(render_frame->GetRoutingID()),
19 is_unique_origin_(false) {
20 if (frame->document().securityOrigin().isUnique() ||
21 frame->top()->document().securityOrigin().isUnique())
22 is_unique_origin_ = true;
23 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter();
24 document_origin_url_ = GURL(frame->document().securityOrigin().toString());
25 top_frame_origin_url_ = GURL(
26 frame->top()->document().securityOrigin().toString());
29 WorkerPermissionClientProxy::~WorkerPermissionClientProxy() {}
31 bool WorkerPermissionClientProxy::allowDatabase(
32 const blink::WebString& name,
33 const blink::WebString& display_name,
34 unsigned long estimated_size) {
35 if (is_unique_origin_)
36 return false;
38 bool result = false;
39 sync_message_filter_->Send(new ChromeViewHostMsg_AllowDatabase(
40 routing_id_, document_origin_url_, top_frame_origin_url_,
41 name, display_name, &result));
42 return result;
45 bool WorkerPermissionClientProxy::requestFileSystemAccessSync() {
46 if (is_unique_origin_)
47 return false;
49 bool result = false;
50 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync(
51 routing_id_, document_origin_url_, top_frame_origin_url_, &result));
52 return result;
55 bool WorkerPermissionClientProxy::allowIndexedDB(
56 const blink::WebString& name) {
57 if (is_unique_origin_)
58 return false;
60 bool result = false;
61 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB(
62 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result));
63 return result;