Index: chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc |
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc |
index afb213cf34353c11985c078dda19866207ee32e1..33b3df66afab2e629ac2048214d7234f2cf32a5c 100644 |
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc |
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_android.cc |
@@ -6,6 +6,7 @@ |
#include "base/prefs/pref_service.h" |
#include "chrome/browser/android/google_location_settings_helper.h" |
+#include "chrome/browser/content_settings/permission_request_id.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/pref_names.h" |
#include "content/public/browser/browser_thread.h" |
@@ -21,23 +22,61 @@ ChromeGeolocationPermissionContextAndroid:: |
~ChromeGeolocationPermissionContextAndroid() { |
} |
-void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
+void ChromeGeolocationPermissionContextAndroid::CallSuperDecidePermission( |
bulach
2013/09/12 09:18:29
thanks for the explanation!
how about "ProceedDeci
acleung1
2013/09/17 00:08:45
Done.
|
const PermissionRequestID& id, |
const GURL& requesting_frame, |
const GURL& embedder, |
base::Callback<void(bool)> callback) { |
+ // Super class implementation expects everything in UI thread instead. |
DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ ChromeGeolocationPermissionContext::DecidePermission( |
+ id, requesting_frame, embedder, callback); |
+} |
+void ChromeGeolocationPermissionContextAndroid::CheckMasterLocation( |
+ const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ base::Callback<void(bool)> callback) { |
// Check to see if the feature in its entirety has been disabled. |
// This must happen before other services (e.g. tabs, extensions) |
// get an opportunity to allow the geolocation request. |
- if (!google_location_settings_helper_->IsMasterLocationSettingEnabled()) { |
- PermissionDecided(id, requesting_frame, embedder, callback, false); |
- return; |
+ bool enabled = |
+ google_location_settings_helper_->IsMasterLocationSettingEnabled(); |
+ |
+ // Regardless of what the master setting is, we still need to |
+ // go back to the UI thread for the rest of the bookkeeping. |
bulach
2013/09/12 09:18:29
Perhaps a more detailed explanation would help cla
acleung1
2013/09/17 00:08:45
Done.
|
+ base::Closure ui_closure; |
+ if (enabled) { |
+ ui_closure = base::Bind( |
+ &ChromeGeolocationPermissionContextAndroid::CallSuperDecidePermission, |
bulach
2013/09/12 09:18:29
so if you agree with the comment above, I think "P
acleung1
2013/09/17 00:08:45
Done.
|
+ base::Unretained(this), id, requesting_frame, embedder, callback); |
+ } else { |
+ ui_closure = base::Bind( |
+ &ChromeGeolocationPermissionContextAndroid::PermissionDecided, |
+ base::Unretained(this), id, |
+ requesting_frame, embedder, callback, false); |
} |
- ChromeGeolocationPermissionContext::DecidePermission(id, requesting_frame, |
- embedder, callback); |
+ // This method is executed from the BlockingPool, post the result |
+ // back to the UI thread. |
+ content::BrowserThread::PostTask( |
+ content::BrowserThread::UI, FROM_HERE,ui_closure); |
bulach
2013/09/12 09:18:29
nit: space after comma, s/,ui_clo/, ui_clo/
acleung1
2013/09/17 00:08:45
Done.
|
+} |
+ |
+void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
+ const PermissionRequestID& id, |
+ const GURL& requesting_frame, |
+ const GURL& embedder, |
+ base::Callback<void(bool)> callback) { |
+ |
+ // Called on the UI thread. However, do the work on a separate thread |
+ // to avoid strict mode violation. |
+ DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
+ content::BrowserThread::PostBlockingPoolTask(FROM_HERE, |
+ base::Bind( |
+ &ChromeGeolocationPermissionContextAndroid::CheckMasterLocation, |
+ base::Unretained(this), id, requesting_frame, embedder, callback)); |
bulach
2013/09/12 09:18:29
nit: indent
acleung1
2013/09/17 00:08:45
Done.
|
} |
void ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
@@ -46,7 +85,6 @@ void ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
const GURL& embedder, |
base::Callback<void(bool)> callback, |
bool allowed) { |
- DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
// If Google Apps Location setting is turned off then we ignore |
// the 'allow' website setting for this site and instead show |
// the infobar to go back to the 'settings' to turn it back on. |