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
3 // found in the LICENSE file.
5 #include "chrome/browser/geolocation/chrome_geolocation_permission_context_android.h"
7 #include "base/prefs/pref_service.h"
8 #include "chrome/browser/android/google_location_settings_helper.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/pref_names.h"
11 #include "content/public/browser/browser_thread.h"
12 #include "content/public/browser/web_contents.h"
14 ChromeGeolocationPermissionContextAndroid::
15 ChromeGeolocationPermissionContextAndroid(Profile
* profile
)
16 : ChromeGeolocationPermissionContext(profile
),
17 google_location_settings_helper_(
18 GoogleLocationSettingsHelper::Create()) {
21 ChromeGeolocationPermissionContextAndroid::
22 ~ChromeGeolocationPermissionContextAndroid() {
25 void ChromeGeolocationPermissionContextAndroid::DecidePermission(
26 content::WebContents
* web_contents
,
27 const PermissionRequestID
& id
,
28 const GURL
& requesting_frame
,
30 base::Callback
<void(bool)> callback
) {
31 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
33 // Check to see if the feature in its entirety has been disabled.
34 // This must happen before other services (e.g. tabs, extensions)
35 // get an opportunity to allow the geolocation request.
36 if (!google_location_settings_helper_
->IsMasterLocationSettingEnabled()) {
37 PermissionDecided(id
, requesting_frame
, embedder
, callback
, false);
41 ChromeGeolocationPermissionContext::DecidePermission(
42 web_contents
, id
, requesting_frame
, embedder
, callback
);
45 void ChromeGeolocationPermissionContextAndroid::PermissionDecided(
46 const PermissionRequestID
& id
,
47 const GURL
& requesting_frame
,
49 base::Callback
<void(bool)> callback
,
51 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI
));
52 // If Google Apps Location setting is turned off then we ignore
53 // the 'allow' website setting for this site and instead show
54 // the infobar to go back to the 'settings' to turn it back on.
56 !google_location_settings_helper_
->IsGoogleAppsLocationSettingEnabled()) {
57 QueueController()->CreateInfoBarRequest(id
, requesting_frame
, embedder
,
62 ChromeGeolocationPermissionContext::PermissionDecided(
63 id
, requesting_frame
, embedder
, callback
, allowed
);