Chromium Code Reviews| 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..fba4afcc290a0f168baaec77af1b9a32687afa1d 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,57 @@ ChromeGeolocationPermissionContextAndroid:: |
| ~ChromeGeolocationPermissionContextAndroid() { |
| } |
| -void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
| +void ChromeGeolocationPermissionContextAndroid::CallSuperDecidePermission( |
| 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(); |
| - ChromeGeolocationPermissionContext::DecidePermission(id, requesting_frame, |
| - embedder, callback); |
| + // Regardless of what the master setting is, we still need to |
| + // go back to the UI thread for the rest of the bookkeeping. |
| + if (enabled) { |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::UI, FROM_HERE, |
| + base::Bind( |
| + &ChromeGeolocationPermissionContextAndroid:: |
| + CallSuperDecidePermission, |
|
bulach
2013/09/04 18:48:53
is it possible to bind to DecidePermission directl
acleung1
2013/09/05 21:50:16
Yeah. I was struggling with this and couldn't find
|
| + base::Unretained(this), id, requesting_frame, embedder, callback)); |
| + } else { |
| + content::BrowserThread::PostTask(content::BrowserThread::UI, FROM_HERE, |
| + base::Bind(&ChromeGeolocationPermissionContextAndroid:: |
| + PermissionDecided, |
| + base::Unretained(this), id, |
| + requesting_frame, embedder, callback, false)); } |
|
bulach
2013/09/04 18:48:53
nit: move } to the next line..
it maybe slightly
acleung1
2013/09/05 21:50:16
Done.
|
| +} |
| + |
| +void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
| + const PermissionRequestID& id, |
| + const GURL& requesting_frame, |
| + const GURL& embedder, |
| + base::Callback<void(bool)> callback) { |
| + // The super class implementation requires this to be in the |
| + // UI thread. We would like the work done else where to avoid |
| + // strict mode violations. |
|
bulach
2013/09/04 18:48:53
rather than "the super class implementation requir
acleung1
2013/09/05 21:50:16
Done.
|
| + content::BrowserThread::PostBlockingPoolTask(FROM_HERE, |
| + base::Bind( |
| + &ChromeGeolocationPermissionContextAndroid::CheckMasterLocation, |
| + base::Unretained(this), id, requesting_frame, embedder, callback)); |
|
bulach
2013/09/04 18:48:53
nit: indentation
acleung1
2013/09/05 21:50:16
Done.
|
| } |
| void ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
| @@ -46,7 +81,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. |