Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(10164)

Unified Diff: chrome/renderer/content_settings_observer.cc

Issue 170733004: Avoid sync IPCs for FileSystem API (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added missing early exit failure Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;

Powered by Google App Engine
This is Rietveld 408576698