| Index: chrome/renderer/content_settings_observer.cc
|
| diff --git a/chrome/renderer/content_settings_observer.cc b/chrome/renderer/content_settings_observer.cc
|
| index 1bfc461ea955394b4cb88e2cad4f782ae2fde5b4..33cac49afe9eb76689458355a0c8e0cf33afc996 100644
|
| --- a/chrome/renderer/content_settings_observer.cc
|
| +++ b/chrome/renderer/content_settings_observer.cc
|
| @@ -15,6 +15,7 @@
|
| #include "content/public/renderer/render_view.h"
|
| #include "extensions/common/constants.h"
|
| #include "extensions/renderer/dispatcher.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"
|
| @@ -27,7 +28,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 +154,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);
|
|
|
| @@ -207,6 +209,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)
|
| @@ -275,6 +279,31 @@ bool ContentSettingsObserver::allowFileSystem() {
|
| return result;
|
| }
|
|
|
| +void ContentSettingsObserver::requestFileSystemAccess(
|
| + const WebPermissionCallbacks& callbacks) {
|
| + WebFrame* frame = render_frame()->GetWebFrame();
|
| + if (frame->document().securityOrigin().isUnique() ||
|
| + frame->top()->document().securityOrigin().isUnique()) {
|
| + WebPermissionCallbacks permissionCallbacks(callbacks);
|
| + permissionCallbacks.doDeny();
|
| + return;
|
| + }
|
| + ++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.
|
| + bool inserted = insert_result.second;
|
| + DCHECK(inserted);
|
| +
|
| + Send(new ChromeViewHostMsg_RequestFileSystemAccess(
|
| + routing_id(),
|
| + current_request_id_,
|
| + GURL(frame->document().securityOrigin().toString()),
|
| + GURL(frame->top()->document().securityOrigin().toString())));
|
| +}
|
| +
|
| bool ContentSettingsObserver::allowImage(bool enabled_per_settings,
|
| const WebURL& image_url) {
|
| bool allow = enabled_per_settings;
|
| @@ -605,6 +634,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;
|
|
|