| 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" | 5 #include "chrome/renderer/worker_content_settings_client_proxy.h" |
| 6 | 6 |
| 7 #include "chrome/common/render_messages.h" | 7 #include "chrome/common/render_messages.h" |
| 8 #include "components/content_settings/content/common/content_settings_messages.h
" | 8 #include "components/content_settings/content/common/content_settings_messages.h
" |
| 9 #include "content/public/renderer/render_frame.h" | 9 #include "content/public/renderer/render_frame.h" |
| 10 #include "content/public/renderer/render_thread.h" | 10 #include "content/public/renderer/render_thread.h" |
| 11 #include "ipc/ipc_sync_message_filter.h" | 11 #include "ipc/ipc_sync_message_filter.h" |
| 12 #include "third_party/WebKit/public/platform/URLConversion.h" | 12 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 13 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
| 14 #include "third_party/WebKit/public/web/WebDocument.h" | 14 #include "third_party/WebKit/public/web/WebDocument.h" |
| 15 #include "third_party/WebKit/public/web/WebFrame.h" | 15 #include "third_party/WebKit/public/web/WebFrame.h" |
| 16 #include "url/origin.h" |
| 16 | 17 |
| 17 WorkerContentSettingsClientProxy::WorkerContentSettingsClientProxy( | 18 WorkerContentSettingsClientProxy::WorkerContentSettingsClientProxy( |
| 18 content::RenderFrame* render_frame, | 19 content::RenderFrame* render_frame, |
| 19 blink::WebFrame* frame) | 20 blink::WebFrame* frame) |
| 20 : routing_id_(render_frame->GetRoutingID()), | 21 : routing_id_(render_frame->GetRoutingID()), |
| 21 is_unique_origin_(false) { | 22 is_unique_origin_(false) { |
| 22 if (frame->document().getSecurityOrigin().isUnique() || | 23 if (frame->document().getSecurityOrigin().isUnique() || |
| 23 frame->top()->getSecurityOrigin().isUnique()) | 24 frame->top()->getSecurityOrigin().isUnique()) |
| 24 is_unique_origin_ = true; | 25 is_unique_origin_ = true; |
| 25 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); | 26 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); |
| 26 document_origin_url_ = | 27 document_origin_url_ = |
| 27 blink::WebStringToGURL(frame->document().getSecurityOrigin().toString()); | 28 url::Origin(frame->document().getSecurityOrigin()).GetURL(); |
| 28 top_frame_origin_url_ = | 29 top_frame_origin_url_ = |
| 29 blink::WebStringToGURL(frame->top()->getSecurityOrigin().toString()); | 30 url::Origin(frame->top()->getSecurityOrigin()).GetURL(); |
| 30 } | 31 } |
| 31 | 32 |
| 32 WorkerContentSettingsClientProxy::~WorkerContentSettingsClientProxy() {} | 33 WorkerContentSettingsClientProxy::~WorkerContentSettingsClientProxy() {} |
| 33 | 34 |
| 34 bool WorkerContentSettingsClientProxy::requestFileSystemAccessSync() { | 35 bool WorkerContentSettingsClientProxy::requestFileSystemAccessSync() { |
| 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_RequestFileSystemAccessSync( | 40 sync_message_filter_->Send(new ChromeViewHostMsg_RequestFileSystemAccessSync( |
| 40 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); | 41 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); |
| 41 return result; | 42 return result; |
| 42 } | 43 } |
| 43 | 44 |
| 44 bool WorkerContentSettingsClientProxy::allowIndexedDB( | 45 bool WorkerContentSettingsClientProxy::allowIndexedDB( |
| 45 const blink::WebString& name) { | 46 const blink::WebString& name) { |
| 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_AllowIndexedDB( | 51 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( |
| 51 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); | 52 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); |
| 52 return result; | 53 return result; |
| 53 } | 54 } |
| OLD | NEW |