Index: chrome/renderer/content_settings_observer.cc |
diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc |
index f5489a07f70d2ccaa399358f20f14dfad50041af..4953b6aea77602591c2ebb137e06445727b9ecec 100644 |
--- a/chrome/renderer/content_settings_observer.cc |
+++ b/chrome/renderer/content_settings_observer.cc |
@@ -15,6 +15,7 @@ |
#include "content/public/renderer/render_frame.h" |
#include "content/public/renderer/render_view.h" |
#include "extensions/common/constants.h" |
+#include "third_party/WebKit/public/platform/WebPermissionCallbacks.h" |
#include "third_party/WebKit/public/platform/WebURL.h" |
#include "third_party/WebKit/public/web/WebDataSource.h" |
#include "third_party/WebKit/public/web/WebDocument.h" |
@@ -28,6 +29,7 @@ using blink::WebDataSource; |
using blink::WebDocument; |
using blink::WebFrame; |
using blink::WebFrameClient; |
+using blink::WebPermissionCallbacks; |
using blink::WebSecurityOrigin; |
using blink::WebString; |
using blink::WebURL; |
@@ -153,7 +155,8 @@ ContentSettingsObserver::ContentSettingsObserver( |
allow_running_insecure_content_(false), |
content_setting_rules_(NULL), |
is_interstitial_page_(false), |
- npapi_plugins_blocked_(false) { |
+ npapi_plugins_blocked_(false), |
+ current_request_id_(0) { |
ClearBlockedContentSettings(); |
render_frame->GetWebFrame()->setPermissionClient(this); |
} |
@@ -194,6 +197,8 @@ bool ContentSettingsObserver::OnMessageReceived(const IPC::Message& message) { |
IPC_MESSAGE_HANDLER(ChromeViewMsg_SetAllowRunningInsecureContent, |
OnSetAllowRunningInsecureContent) |
IPC_MESSAGE_HANDLER(ChromeViewMsg_ReloadFrame, OnReloadFrame); |
+ IPC_MESSAGE_HANDLER(ChromeViewMsg_RequestFileSystemAccessResponse, |
+ OnRequestFileSystemAccessResponse) |
IPC_MESSAGE_UNHANDLED(handled = false) |
IPC_END_MESSAGE_MAP() |
if (handled) |
@@ -261,6 +266,30 @@ bool ContentSettingsObserver::allowFileSystem(WebFrame* frame) { |
return result; |
} |
+void ContentSettingsObserver::requestFileSystemAccess( |
+ WebFrame* frame, const WebPermissionCallbacks& callbacks) { |
+ ++current_request_id_; |
+ std::pair<PermissionRequestMap::iterator, bool> insert_result = |
+ permission_requests_.insert( |
+ std::make_pair(current_request_id_, callbacks)); |
+ |
+ // Verify there are no duplicate insertions. |
+ DCHECK(insert_result.second); |
+ |
+ if (frame->document().securityOrigin().isUnique() || |
+ frame->top()->document().securityOrigin().isUnique()) { |
+ insert_result.first->second.doDeny(); |
+ permission_requests_.erase(insert_result.first); |
kinuko
2014/03/07 08:22:29
I feel this could be checked before you insert the
|
+ return; |
+ } |
+ |
+ Send(new ChromeViewHostMsg_RequestFileSystemAccess( |
+ routing_id(), |
+ current_request_id_, |
+ GURL(frame->document().securityOrigin().toString()), |
+ GURL(frame->top()->document().securityOrigin().toString()))); |
+} |
+ |
bool ContentSettingsObserver::allowImage(WebFrame* frame, |
bool enabled_per_settings, |
const WebURL& image_url) { |
@@ -589,6 +618,22 @@ void ContentSettingsObserver::OnReloadFrame() { |
render_frame()->GetWebFrame()->reload(); |
} |
+void ContentSettingsObserver::OnRequestFileSystemAccessResponse(int request_id, |
+ bool allowed) { |
+ PermissionRequestMap::iterator it = permission_requests_.find(request_id); |
+ if (it == permission_requests_.end()) |
+ return; |
+ |
+ WebPermissionCallbacks callbacks = it->second; |
+ permission_requests_.erase(it); |
+ |
+ if (allowed) { |
+ callbacks.doAllow(); |
+ return; |
+ } |
+ callbacks.doDeny(); |
+} |
+ |
void ContentSettingsObserver::ClearBlockedContentSettings() { |
for (size_t i = 0; i < arraysize(content_blocked_); ++i) |
content_blocked_[i] = false; |