| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_andro
id.h" | 5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_andro
id.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/android/google_location_settings_helper.h" | 8 #include "chrome/browser/android/google_location_settings_helper.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
| 11 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
| 12 | 12 |
| 13 ChromeGeolocationPermissionContextAndroid:: | 13 ChromeGeolocationPermissionContextAndroid:: |
| 14 ChromeGeolocationPermissionContextAndroid(Profile* profile) | 14 ChromeGeolocationPermissionContextAndroid(Profile* profile) |
| 15 : ChromeGeolocationPermissionContext(profile), | 15 : ChromeGeolocationPermissionContext(profile), |
| 16 google_location_settings_helper_( | 16 google_location_settings_helper_( |
| 17 GoogleLocationSettingsHelper::Create()) { | 17 GoogleLocationSettingsHelper::Create()) { |
| 18 } | 18 } |
| 19 | 19 |
| 20 ChromeGeolocationPermissionContextAndroid:: | 20 ChromeGeolocationPermissionContextAndroid:: |
| 21 ~ChromeGeolocationPermissionContextAndroid() { | 21 ~ChromeGeolocationPermissionContextAndroid() { |
| 22 } | 22 } |
| 23 | 23 |
| 24 void ChromeGeolocationPermissionContextAndroid::DecidePermission( | 24 void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
| 25 const PermissionRequestID& id, | 25 const PermissionRequestID& id, |
| 26 const GURL& requesting_frame, | 26 const GURL& requesting_frame, |
| 27 const GURL& embedder, | 27 const GURL& embedder, |
| 28 base::Callback<void(bool)> callback) { | 28 base::Callback<void(bool)> callback) { |
| 29 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 30 | |
| 31 // Check to see if the feature in its entirety has been disabled. | 29 // Check to see if the feature in its entirety has been disabled. |
| 32 // This must happen before other services (e.g. tabs, extensions) | 30 // This must happen before other services (e.g. tabs, extensions) |
| 33 // get an opportunity to allow the geolocation request. | 31 // get an opportunity to allow the geolocation request. |
| 34 if (!google_location_settings_helper_->IsMasterLocationSettingEnabled()) { | 32 if (!google_location_settings_helper_->IsMasterLocationSettingEnabled()) { |
| 35 PermissionDecided(id, requesting_frame, embedder, callback, false); | 33 PermissionDecided(id, requesting_frame, embedder, callback, false); |
| 36 return; | 34 return; |
| 37 } | 35 } |
| 38 | 36 |
| 39 ChromeGeolocationPermissionContext::DecidePermission(id, requesting_frame, | 37 ChromeGeolocationPermissionContext::DecidePermission(id, requesting_frame, |
| 40 embedder, callback); | 38 embedder, callback); |
| 41 } | 39 } |
| 42 | 40 |
| 43 void ChromeGeolocationPermissionContextAndroid::PermissionDecided( | 41 void ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
| 44 const PermissionRequestID& id, | 42 const PermissionRequestID& id, |
| 45 const GURL& requesting_frame, | 43 const GURL& requesting_frame, |
| 46 const GURL& embedder, | 44 const GURL& embedder, |
| 47 base::Callback<void(bool)> callback, | 45 base::Callback<void(bool)> callback, |
| 48 bool allowed) { | 46 bool allowed) { |
| 49 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
| 50 // If Google Apps Location setting is turned off then we ignore | 47 // If Google Apps Location setting is turned off then we ignore |
| 51 // the 'allow' website setting for this site and instead show | 48 // the 'allow' website setting for this site and instead show |
| 52 // the infobar to go back to the 'settings' to turn it back on. | 49 // the infobar to go back to the 'settings' to turn it back on. |
| 53 if (allowed && | 50 if (allowed && |
| 54 !google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { | 51 !google_location_settings_helper_->IsGoogleAppsLocationSettingEnabled()) { |
| 55 QueueController()->CreateInfoBarRequest(id, requesting_frame, embedder, | 52 QueueController()->CreateInfoBarRequest(id, requesting_frame, embedder, |
| 56 callback); | 53 callback); |
| 57 return; | 54 return; |
| 58 } | 55 } |
| 59 | 56 |
| 60 ChromeGeolocationPermissionContext::PermissionDecided( | 57 ChromeGeolocationPermissionContext::PermissionDecided( |
| 61 id, requesting_frame, embedder, callback, allowed); | 58 id, requesting_frame, embedder, callback, allowed); |
| 62 } | 59 } |
| OLD | NEW |