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 "chrome/browser/android/google_location_settings_helper.h" | |
7 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
8 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
9 #include "chrome/common/pref_names.h" | 10 #include "chrome/common/pref_names.h" |
10 #include "content/public/browser/browser_thread.h" | 11 #include "content/public/browser/browser_thread.h" |
11 | 12 |
12 ChromeGeolocationPermissionContextAndroid:: | 13 ChromeGeolocationPermissionContextAndroid:: |
13 ChromeGeolocationPermissionContextAndroid(Profile* profile) | 14 ChromeGeolocationPermissionContextAndroid(Profile* profile) |
14 : ChromeGeolocationPermissionContext(profile) { | 15 : ChromeGeolocationPermissionContext(profile), |
16 google_location_settings_helper_(new GoogleLocationSettingsHelper()) { | |
15 } | 17 } |
16 | 18 |
17 void ChromeGeolocationPermissionContextAndroid::DecidePermission( | 19 void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
18 int render_process_id, | 20 int render_process_id, |
19 int render_view_id, | 21 int render_view_id, |
20 int bridge_id, | 22 int bridge_id, |
21 const GURL& requesting_frame, | 23 const GURL& requesting_frame, |
22 const GURL& embedder, | 24 const GURL& embedder, |
23 base::Callback<void(bool)> callback) { | 25 base::Callback<void(bool)> callback) { |
24 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 26 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
25 | 27 |
26 // Check to see if the feature in its entirety has been disabled. | 28 // Check to see if the feature in its entirety has been disabled. |
27 // This must happen before other services (e.g. tabs, extensions) | 29 // This must happen before other services (e.g. tabs, extensions) |
28 // get an opportunity to allow the geolocation request. | 30 // get an opportunity to allow the geolocation request. |
29 if (!profile()->GetPrefs()->GetBoolean(prefs::kGeolocationEnabled)) { | 31 if (!profile()->GetPrefs()->GetBoolean(prefs::kGeolocationEnabled)) { |
John Knottenbelt
2012/10/22 12:58:35
If the Google Location Settings are available, wil
Ramya
2012/10/22 23:57:11
This is set to the same boolean value as master lo
| |
30 PermissionDecided(render_process_id, render_view_id, bridge_id, | 32 PermissionDecided(render_process_id, render_view_id, bridge_id, |
31 requesting_frame, embedder, callback, false); | 33 requesting_frame, embedder, callback, false); |
32 return; | 34 return; |
33 } | 35 } |
34 | 36 |
35 ChromeGeolocationPermissionContext::DecidePermission( | 37 ChromeGeolocationPermissionContext::DecidePermission( |
36 render_process_id, render_view_id, bridge_id, | 38 render_process_id, render_view_id, bridge_id, |
37 requesting_frame, embedder, callback); | 39 requesting_frame, embedder, callback); |
38 } | 40 } |
41 | |
42 void ChromeGeolocationPermissionContextAndroid::PermissionDecided( | |
43 int render_process_id, | |
44 int render_view_id, | |
45 int bridge_id, | |
46 const GURL& requesting_frame, | |
47 const GURL& embedder, | |
48 base::Callback<void(bool)> callback, | |
49 bool allowed) { | |
50 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | |
51 // If Google Apps Location setting is turned off then we ignore | |
52 // the 'allow' website setting for this site and instead show | |
53 // the infobar to go back to the 'settings' to turn it back on. | |
54 if (allowed && | |
55 !google_location_settings_helper_->IsPlatformSettingEnabled()) { | |
56 QueueController()->CreateInfoBarRequest( | |
57 render_process_id, render_view_id, bridge_id, requesting_frame, | |
58 embedder, callback); | |
59 return; | |
60 } | |
61 | |
62 ChromeGeolocationPermissionContext::PermissionDecided( | |
63 render_process_id, render_view_id, bridge_id, | |
64 requesting_frame, embedder, callback, allowed); | |
65 } | |
OLD | NEW |