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

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: Update thread hops. 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 3d3c3c2b0fff4cd4668a4d070380bb47cda6b8d8..3113e43c540c87455f36b07af4d08b6d7c0e04c5 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -646,7 +646,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]);
@@ -1817,25 +1818,77 @@ 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)
+ // 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) {
+ bool is_web_view_guest =
+ WebViewRendererState::GetInstance()->IsGuest(i->first);
Fady Samuel 2014/07/08 21:49:11 This code doesn't make sense to me. If there are t
Xi Han 2014/07/09 15:28:33 Done.
+ if (is_web_view_guest) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&ChromeContentBrowserClient::
+ RequestFileSystemPermissionOnUIThread,
+ i->first,
+ i->second,
+ url,
+ allow,
+ base::Bind(&ChromeContentBrowserClient::FileSystemAccessed,
+ weak_factory_.GetWeakPtr(),
+ url,
+ render_frames,
+ callback)));
+ break;
+ }
+ }
+#else
+ FileSystemAccessed(url, render_frames, callback, allow);
+#endif
+}
+
+#if defined(ENABLE_EXTENSIONS)
+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));
+ WebViewGuest* guest = WebViewGuest::FromFrameID(render_process_id,
+ render_frame_id);
+ guest->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));
+ 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