| 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/common/render_messages.h" | 5 #include "chrome/common/render_messages.h" |
| 6 #include "chrome/renderer/worker_permission_client_proxy.h" | 6 #include "chrome/renderer/worker_permission_client_proxy.h" |
| 7 #include "content/public/renderer/render_thread.h" | 7 #include "content/public/renderer/render_thread.h" |
| 8 #include "content/public/renderer/render_view.h" | 8 #include "content/public/renderer/render_view.h" |
| 9 #include "ipc/ipc_sync_message_filter.h" | 9 #include "ipc/ipc_sync_message_filter.h" |
| 10 #include "third_party/WebKit/public/web/WebDocument.h" | 10 #include "third_party/WebKit/public/web/WebDocument.h" |
| 11 #include "third_party/WebKit/public/web/WebFrame.h" | 11 #include "third_party/WebKit/public/web/WebFrame.h" |
| 12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 12 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
| 13 | 13 |
| 14 WorkerPermissionClientProxy::WorkerPermissionClientProxy( | 14 WorkerPermissionClientProxy::WorkerPermissionClientProxy( |
| 15 content::RenderView* render_view, | 15 content::RenderView* render_view, |
| 16 WebKit::WebFrame* frame) | 16 blink::WebFrame* frame) |
| 17 : routing_id_(render_view->GetRoutingID()), | 17 : routing_id_(render_view->GetRoutingID()), |
| 18 is_unique_origin_(false) { | 18 is_unique_origin_(false) { |
| 19 if (frame->document().securityOrigin().isUnique() || | 19 if (frame->document().securityOrigin().isUnique() || |
| 20 frame->top()->document().securityOrigin().isUnique()) | 20 frame->top()->document().securityOrigin().isUnique()) |
| 21 is_unique_origin_ = true; | 21 is_unique_origin_ = true; |
| 22 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); | 22 sync_message_filter_ = content::RenderThread::Get()->GetSyncMessageFilter(); |
| 23 document_origin_url_ = GURL(frame->document().securityOrigin().toString()); | 23 document_origin_url_ = GURL(frame->document().securityOrigin().toString()); |
| 24 top_frame_origin_url_ = GURL( | 24 top_frame_origin_url_ = GURL( |
| 25 frame->top()->document().securityOrigin().toString()); | 25 frame->top()->document().securityOrigin().toString()); |
| 26 } | 26 } |
| 27 | 27 |
| 28 WorkerPermissionClientProxy::~WorkerPermissionClientProxy() {} | 28 WorkerPermissionClientProxy::~WorkerPermissionClientProxy() {} |
| 29 | 29 |
| 30 bool WorkerPermissionClientProxy::allowDatabase( | 30 bool WorkerPermissionClientProxy::allowDatabase( |
| 31 const WebKit::WebString& name, | 31 const blink::WebString& name, |
| 32 const WebKit::WebString& display_name, | 32 const blink::WebString& display_name, |
| 33 unsigned long estimated_size) { | 33 unsigned long estimated_size) { |
| 34 if (is_unique_origin_) | 34 if (is_unique_origin_) |
| 35 return false; | 35 return false; |
| 36 | 36 |
| 37 bool result = false; | 37 bool result = false; |
| 38 sync_message_filter_->Send(new ChromeViewHostMsg_AllowDatabase( | 38 sync_message_filter_->Send(new ChromeViewHostMsg_AllowDatabase( |
| 39 routing_id_, document_origin_url_, top_frame_origin_url_, | 39 routing_id_, document_origin_url_, top_frame_origin_url_, |
| 40 name, display_name, &result)); | 40 name, display_name, &result)); |
| 41 return result; | 41 return result; |
| 42 } | 42 } |
| 43 | 43 |
| 44 bool WorkerPermissionClientProxy::allowFileSystem() { | 44 bool WorkerPermissionClientProxy::allowFileSystem() { |
| 45 if (is_unique_origin_) | 45 if (is_unique_origin_) |
| 46 return false; | 46 return false; |
| 47 | 47 |
| 48 bool result = false; | 48 bool result = false; |
| 49 sync_message_filter_->Send(new ChromeViewHostMsg_AllowFileSystem( | 49 sync_message_filter_->Send(new ChromeViewHostMsg_AllowFileSystem( |
| 50 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); | 50 routing_id_, document_origin_url_, top_frame_origin_url_, &result)); |
| 51 return result; | 51 return result; |
| 52 } | 52 } |
| 53 | 53 |
| 54 bool WorkerPermissionClientProxy::allowIndexedDB( | 54 bool WorkerPermissionClientProxy::allowIndexedDB( |
| 55 const WebKit::WebString& name) { | 55 const blink::WebString& name) { |
| 56 if (is_unique_origin_) | 56 if (is_unique_origin_) |
| 57 return false; | 57 return false; |
| 58 | 58 |
| 59 bool result = false; | 59 bool result = false; |
| 60 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( | 60 sync_message_filter_->Send(new ChromeViewHostMsg_AllowIndexedDB( |
| 61 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); | 61 routing_id_, document_origin_url_, top_frame_origin_url_, name, &result)); |
| 62 return result; | 62 return result; |
| 63 } | 63 } |
| OLD | NEW |