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/geolocation/geolocation_infobar_queue_controller_androi
d.h" | 8 #include "chrome/browser/geolocation/geolocation_infobar_queue_controller_androi
d.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/common/pref_names.h" | 11 #include "chrome/common/pref_names.h" |
11 #include "content/public/browser/browser_thread.h" | 12 #include "content/public/browser/browser_thread.h" |
12 | 13 |
13 ChromeGeolocationPermissionContext* ChromeGeolocationPermissionContext::Create( | 14 ChromeGeolocationPermissionContext* ChromeGeolocationPermissionContext::Create( |
14 Profile *profile) { | 15 Profile *profile) { |
15 return new ChromeGeolocationPermissionContextAndroid(profile); | 16 return new ChromeGeolocationPermissionContextAndroid(profile); |
16 } | 17 } |
17 | 18 |
18 void ChromeGeolocationPermissionContext::RegisterUserPrefs( | 19 void ChromeGeolocationPermissionContext::RegisterUserPrefs( |
19 PrefService *user_prefs) { | 20 PrefService *user_prefs) { |
20 user_prefs->RegisterBooleanPref(prefs::kGeolocationEnabled, | 21 user_prefs->RegisterBooleanPref(prefs::kGeolocationEnabled, |
21 true, | 22 true, |
22 PrefService::UNSYNCABLE_PREF); | 23 PrefService::UNSYNCABLE_PREF); |
23 } | 24 } |
24 | 25 |
25 ChromeGeolocationPermissionContextAndroid:: | 26 ChromeGeolocationPermissionContextAndroid:: |
26 ChromeGeolocationPermissionContextAndroid(Profile* profile) | 27 ChromeGeolocationPermissionContextAndroid(Profile* profile) |
27 : ChromeGeolocationPermissionContext(profile) { | 28 : ChromeGeolocationPermissionContext(profile), |
| 29 google_location_settings_helper_(new GoogleLocationSettingsHelper()) { |
28 } | 30 } |
29 | 31 |
30 void ChromeGeolocationPermissionContextAndroid::DecidePermission( | 32 void ChromeGeolocationPermissionContextAndroid::DecidePermission( |
31 int render_process_id, | 33 int render_process_id, |
32 int render_view_id, | 34 int render_view_id, |
33 int bridge_id, | 35 int bridge_id, |
34 const GURL& requesting_frame, | 36 const GURL& requesting_frame, |
35 const GURL& embedder, | 37 const GURL& embedder, |
36 base::Callback<void(bool)> callback) { | 38 base::Callback<void(bool)> callback) { |
37 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 39 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
(...skipping 14 matching lines...) Expand all Loading... |
52 | 54 |
53 void ChromeGeolocationPermissionContextAndroid::PermissionDecided( | 55 void ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
54 int render_process_id, | 56 int render_process_id, |
55 int render_view_id, | 57 int render_view_id, |
56 int bridge_id, | 58 int bridge_id, |
57 const GURL& requesting_frame, | 59 const GURL& requesting_frame, |
58 const GURL& embedder, | 60 const GURL& embedder, |
59 base::Callback<void(bool)> callback, | 61 base::Callback<void(bool)> callback, |
60 bool allowed) { | 62 bool allowed) { |
61 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 63 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 64 // If Google Apps Location setting is turned off then we ignore |
| 65 // the 'allow' website setting for this site and instead show |
| 66 // the infobar to go back to the 'settings' to turn it back on. |
| 67 if (allowed && |
| 68 !google_location_settings_helper_->IsPlatformSettingEnabled()) { |
| 69 QueueController()->CreateInfoBarRequest( |
| 70 render_process_id, render_view_id, bridge_id, requesting_frame, |
| 71 embedder, callback); |
| 72 return; |
| 73 } |
| 74 |
62 ChromeGeolocationPermissionContextAndroid::PermissionDecided( | 75 ChromeGeolocationPermissionContextAndroid::PermissionDecided( |
63 render_process_id, render_view_id, bridge_id, | 76 render_process_id, render_view_id, bridge_id, |
64 requesting_frame, embedder, callback, true); | 77 requesting_frame, embedder, callback, true); |
65 } | 78 } |
66 | 79 |
67 GeolocationInfoBarQueueController* | 80 GeolocationInfoBarQueueController* |
68 ChromeGeolocationPermissionContextAndroid::CreateQueueController() { | 81 ChromeGeolocationPermissionContextAndroid::CreateQueueController() { |
69 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 82 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
70 return new GeolocationInfoBarQueueControllerAndroid( | 83 return new GeolocationInfoBarQueueControllerAndroid( |
71 profile()); | 84 profile(), |
| 85 google_location_settings_helper_.get()); |
72 } | 86 } |
OLD | NEW |