| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/renderer/worker_content_settings_client_proxy.h" |
| 6 |
| 5 #include "chrome/common/render_messages.h" | 7 #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_frame.h" |
| 8 #include "content/public/renderer/render_thread.h" | 9 #include "content/public/renderer/render_thread.h" |
| 9 #include "ipc/ipc_sync_message_filter.h" | 10 #include "ipc/ipc_sync_message_filter.h" |
| 10 #include "third_party/WebKit/public/platform/WebPermissionCallbacks.h" | 11 #include "third_party/WebKit/public/platform/WebPermissionCallbacks.h" |
| 11 #include "third_party/WebKit/public/web/WebDocument.h" | 12 #include "third_party/WebKit/public/web/WebDocument.h" |
| 12 #include "third_party/WebKit/public/web/WebFrame.h" | 13 #include "third_party/WebKit/public/web/WebFrame.h" |
| 13 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 14 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 14 | 15 |
| 15 WorkerPermissionClientProxy::WorkerPermissionClientProxy( | 16 WorkerContentSettingsClientProxy::WorkerContentSettingsClientProxy( |
| 16 content::RenderFrame* render_frame, | 17 content::RenderFrame* render_frame, |
| 17 blink::WebFrame* frame) | 18 blink::WebFrame* frame) |
| 18 : routing_id_(render_frame->GetRoutingID()), | 19 : routing_id_(render_frame->GetRoutingID()), |
| 19 is_unique_origin_(false) { | 20 is_unique_origin_(false) { |
| 20 if (frame->document().securityOrigin().isUnique() || | 21 if (frame->document().securityOrigin().isUnique() || |
| 21 frame->top()->document().securityOrigin().isUnique()) | 22 frame->top()->document().securityOrigin().isUnique()) |
| 22 is_unique_origin_ = true; | 23 is_unique_origin_ = true; |
| 23 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); | 24 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); |
| 24 document_origin_url_ = GURL(frame->document().securityOrigin().toString()); | 25 document_origin_url_ = GURL(frame->document().securityOrigin().toString()); |
| 25 top_frame_origin_url_ = GURL( | 26 top_frame_origin_url_ = GURL( |
| 26 frame->top()->document().securityOrigin().toString()); | 27 frame->top()->document().securityOrigin().toString()); |
| 27 } | 28 } |
| 28 | 29 |
| 29 WorkerPermissionClientProxy::~WorkerPermissionClientProxy() {} | 30 WorkerContentSettingsClientProxy::~WorkerContentSettingsClientProxy() {} |
| 30 | 31 |
| 31 bool WorkerPermissionClientProxy::allowDatabase( | 32 bool WorkerContentSettingsClientProxy::allowDatabase( |
| 32 const blink::WebString& name, | 33 const blink::WebString& name, |
| 33 const blink::WebString& display_name, | 34 const blink::WebString& display_name, |
| 34 unsigned long estimated_size) { | 35 unsigned long estimated_size) { |
| 35 if (is_unique_origin_) | 36 if (is_unique_origin_) |
| 36 return false; | 37 return false; |
| 37 | 38 |
| 38 bool result = false; | 39 bool result = false; |
| 39 sync_message_filter_->Send(new ChromeViewHostMsg_AllowDatabase( | 40 sync_message_filter_->Send(new ChromeViewHostMsg_AllowDatabase( |
| 40 routing_id_, document_origin_url_, top_frame_origin_url_, | 41 routing_id_, document_origin_url_, top_frame_origin_url_, |
| 41 name, display_name, &result)); | 42 name, display_name, &result)); |
| 42 return result; | 43 return result; |
| 43 } | 44 } |
| 44 | 45 |
| 45 bool WorkerPermissionClientProxy::requestFileSystemAccessSync() { | 46 bool WorkerContentSettingsClientProxy::requestFileSystemAccessSync() { |
| 46 if (is_unique_origin_) | 47 if (is_unique_origin_) |
| 47 return false; | 48 return false; |
| 48 | 49 |
| 49 bool result = false; | 50 bool result = false; |
| 50 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync( | 51 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync( |
| 51 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); | 52 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); |
| 52 return result; | 53 return result; |
| 53 } | 54 } |
| 54 | 55 |
| 55 bool WorkerPermissionClientProxy::allowIndexedDB( | 56 bool WorkerContentSettingsClientProxy::allowIndexedDB( |
| 56 const blink::WebString& name) { | 57 const blink::WebString& name) { |
| 57 if (is_unique_origin_) | 58 if (is_unique_origin_) |
| 58 return false; | 59 return false; |
| 59 | 60 |
| 60 bool result = false; | 61 bool result = false; |
| 61 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( | 62 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( |
| 62 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); | 63 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); |
| 63 return result; | 64 return result; |
| 64 } | 65 } |
| OLD | NEW |