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

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: Fix a callback bug. Created 6 years, 6 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/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 ff8dd621b5b04a52568a2a918acd10c40f64d33c..4a5d119645d11acecb66e8d79e397bd7367546fa 100644
--- a/chrome/browser/chrome_content_browser_client.cc
+++ b/chrome/browser/chrome_content_browser_client.cc
@@ -648,7 +648,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]);
@@ -1818,25 +1819,63 @@ 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) {
Xi Han 2014/07/03 15:02:51 With this implementation, we will guaranty the cal
+ bool is_web_view_guest =
+ WebViewRendererState::GetInstance()->IsGuest(i->first);
+ if (is_web_view_guest) {
+ BrowserThread::PostTask(
+ BrowserThread::UI,
+ FROM_HERE,
+ base::Bind(&WebViewGuest::RequestFileSystemAccessPermission,
Fady Samuel 2014/07/08 14:42:46 RequestFileSystemPermissionFromIOThread
Xi Han 2014/07/08 21:28:24 I declare a static function in ChromeContentBrowse
+ 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
+
+}
+
+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(

Powered by Google App Engine
This is Rietveld 408576698