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/renderer/worker_content_settings_client_proxy.h"
7 #include "chrome/common/render_messages.h"
8 #include "components/content_settings/content/common/content_settings_messages.h"
9 #include "content/public/renderer/render_frame.h"
10 #include "content/public/renderer/render_thread.h"
11 #include "ipc/ipc_sync_message_filter.h"
12 #include "third_party/WebKit/public/web/WebDocument.h"
13 #include "third_party/WebKit/public/web/WebFrame.h"
14 #include "third_party/WebKit/public/web/WebSecurityOrigin.h"
16 WorkerContentSettingsClientProxy::WorkerContentSettingsClientProxy(
17 content::RenderFrame
* render_frame
,
18 blink::WebFrame
* frame
)
19 : routing_id_(render_frame
->GetRoutingID()),
20 is_unique_origin_(false) {
21 if (frame
->document().securityOrigin().isUnique() ||
22 frame
->top()->securityOrigin().isUnique())
23 is_unique_origin_
= true;
24 sync_message_filter_
= content::RenderThread::Get()->GetSyncMessageFilter();
25 document_origin_url_
= GURL(frame
->document().securityOrigin().toString());
26 top_frame_origin_url_
= GURL(frame
->top()->securityOrigin().toString());
29 WorkerContentSettingsClientProxy::~WorkerContentSettingsClientProxy() {}
31 bool WorkerContentSettingsClientProxy::allowDatabase(
32 const blink::WebString
& name
,
33 const blink::WebString
& display_name
,
34 unsigned long estimated_size
) {
35 if (is_unique_origin_
)
39 sync_message_filter_
->Send(new ChromeViewHostMsg_AllowDatabase(
40 routing_id_
, document_origin_url_
, top_frame_origin_url_
,
41 name
, display_name
, &result
));
45 bool WorkerContentSettingsClientProxy::requestFileSystemAccessSync() {
46 if (is_unique_origin_
)
50 sync_message_filter_
->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync(
51 routing_id_
, document_origin_url_
, top_frame_origin_url_
, &result
));
55 bool WorkerContentSettingsClientProxy::allowIndexedDB(
56 const blink::WebString
& name
) {
57 if (is_unique_origin_
)
61 sync_message_filter_
->Send(new ChromeViewHostMsg_AllowIndexedDB(
62 routing_id_
, document_origin_url_
, top_frame_origin_url_
, name
, &result
));