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

Unified Diff: chrome/browser/chrome_content_browser_client.cc

Issue 338353007: Implementation of shared worker code path for WebView file system permission. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master_sharedworker
Patch Set: Small changes are made. Created 6 years, 5 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
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/guest_view/web_view/web_view_guest.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chrome_content_browser_client.cc
diff --git a/chrome/browser/chrome_content_browser_client.cc b/chrome/browser/chrome_content_browser_client.cc
index 14511ccb2f4e6338d19183360e97712d99f0743c..1cf5c79c9bb111fe9a084475f714be8623e3eb96 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -232,6 +232,7 @@
#include "chrome/browser/guest_view/guest_view_constants.h"
#include "chrome/browser/guest_view/guest_view_manager.h"
#include "chrome/browser/guest_view/web_view/web_view_guest.h"
+#include "chrome/browser/guest_view/web_view/web_view_permission_helper.h"
#include "chrome/browser/guest_view/web_view/web_view_renderer_state.h"
#include "chrome/browser/renderer_host/chrome_extension_message_filter.h"
#include "chrome/browser/sync_file_system/local/sync_file_system_backend.h"
@@ -648,7 +649,8 @@ float GetDeviceScaleAdjustment() {
namespace chrome {
ChromeContentBrowserClient::ChromeContentBrowserClient()
- : prerender_tracker_(NULL) {
+ : prerender_tracker_(NULL),
+ weak_factory_(this) {
#if defined(ENABLE_PLUGINS)
for (size_t i = 0; i < arraysize(kPredefinedAllowedDevChannelOrigins); ++i)
allowed_dev_channel_origins_.insert(kPredefinedAllowedDevChannelOrigins[i]);
@@ -1819,25 +1821,97 @@ bool ChromeContentBrowserClient::AllowWorkerDatabase(
return allow;
}
-bool ChromeContentBrowserClient::AllowWorkerFileSystem(
+void ChromeContentBrowserClient::AllowWorkerFileSystem(
const GURL& url,
content::ResourceContext* context,
- const std::vector<std::pair<int, int> >& render_frames) {
+ const std::vector<std::pair<int, int> >& render_frames,
+ base::Callback<void(bool)> callback) {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
ProfileIOData* io_data = ProfileIOData::FromResourceContext(context);
CookieSettings* cookie_settings = io_data->GetCookieSettings();
bool allow = cookie_settings->IsSettingCookieAllowed(url, url);
+#if defined(ENABLE_EXTENSIONS)
+ GuestPermissionRequestHelper(url, render_frames, callback, allow);
+#else
+ FileSystemAccessed(url, render_frames, callback, allow);
+#endif
+}
+
+#if defined(ENABLE_EXTENSIONS)
+void ChromeContentBrowserClient::GuestPermissionRequestHelper(
+ const GURL& url,
+ const std::vector<std::pair<int, int> >& render_frames,
+ base::Callback<void(bool)> callback,
+ bool allow) {
+ DCHECK(BrowserThread:: CurrentlyOn(BrowserThread::IO));
+ std::vector<std::pair<int, int> >::const_iterator i;
+ std::map<int, int> process_map;
+ std::map<int, int>::const_iterator it;
+ bool has_web_view_guest = false;
+ // Record access to file system for potential display in UI.
+ for (i = render_frames.begin(); i != render_frames.end(); ++i) {
+ if (process_map.find(i->first) != process_map.end())
+ continue;
+
+ process_map.insert(std::pair<int, int>(i->first, i->second));
+
+ if (WebViewRendererState::GetInstance()->IsGuest(i->first))
+ has_web_view_guest = true;
+ }
+ if (!has_web_view_guest) {
+ FileSystemAccessed(url, render_frames, callback, allow);
+ return;
+ }
+ DCHECK(process_map.size() == 1);
+ it = process_map.begin();
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&ChromeContentBrowserClient::
+ RequestFileSystemPermissionOnUIThread,
+ it->first,
+ it->second,
+ url,
+ allow,
+ base::Bind(&ChromeContentBrowserClient::FileSystemAccessed,
+ weak_factory_.GetWeakPtr(),
+ url,
+ render_frames,
+ callback)));
+}
+
+void ChromeContentBrowserClient::RequestFileSystemPermissionOnUIThread(
+ int render_process_id,
+ int render_frame_id,
+ const GURL& url,
+ bool allowed_by_default,
+ const base::Callback<void(bool)>& callback) {
+ DCHECK(BrowserThread:: CurrentlyOn(BrowserThread::UI));
+ WebViewPermissionHelper* web_view_permission_helper =
+ WebViewPermissionHelper::FromFrameID(render_process_id,
+ render_frame_id);
+ web_view_permission_helper->RequestFileSystemPermission(url,
+ allowed_by_default,
+ callback);
+}
+#endif
+
+void ChromeContentBrowserClient::FileSystemAccessed(
+ const GURL& url,
+ const std::vector<std::pair<int, int> >& render_frames,
+ base::Callback<void(bool)> callback,
+ bool allow) {
// Record access to file system for potential display in UI.
std::vector<std::pair<int, int> >::const_iterator i;
for (i = render_frames.begin(); i != render_frames.end(); ++i) {
BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
+ BrowserThread::UI,
+ FROM_HERE,
base::Bind(&TabSpecificContentSettings::FileSystemAccessed,
i->first, i->second, url, !allow));
}
-
- return allow;
+ callback.Run(allow);
}
bool ChromeContentBrowserClient::AllowWorkerIndexedDB(
« no previous file with comments | « chrome/browser/chrome_content_browser_client.h ('k') | chrome/browser/guest_view/web_view/web_view_guest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698