1 // Copyright 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 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
8 // The flow for geolocation permissions on Android needs to take into account
9 // the global geolocation settings so it differs from the desktop one. It
11 // GeolocationPermissionContextAndroid::DecidePermission intercepts the flow in
12 // the UI thread, and posts a task to the blocking pool to CheckSystemLocation.
13 // CheckSystemLocation will in fact check several possible settings
14 // - The global system geolocation setting
15 // - The Google location settings on pre KK devices
16 // - An old internal Chrome setting on pre-JB MR1 devices
17 // With all that information it will decide if system location is enabled.
18 // If enabled, it proceeds with the per site flow via
19 // GeolocationPermissionContext (which will check per site permissions, create
22 // Otherwise the permission is already decided.
24 // There is a bit of thread jumping since some of the permissions (like the
25 // per site settings) are queried on the UI thread while the system level
26 // permissions are considered I/O and thus checked in the blocking thread pool.
28 #include "chrome/browser/content_settings/permission_request_id.h"
29 #include "chrome/browser/geolocation/geolocation_permission_context.h"
36 class GoogleLocationSettingsHelper
;
39 class GeolocationPermissionContextAndroid
40 : public GeolocationPermissionContext
{
42 explicit GeolocationPermissionContextAndroid(Profile
* profile
);
45 struct PermissionRequestInfo
{
46 PermissionRequestInfo();
48 PermissionRequestID id
;
49 GURL requesting_frame
;
54 friend class GeolocationPermissionContext
;
56 virtual ~GeolocationPermissionContextAndroid();
58 // GeolocationPermissionContext implementation:
59 virtual void DecidePermission(content::WebContents
* web_contents
,
60 const PermissionRequestID
& id
,
61 const GURL
& requesting_frame
,
64 base::Callback
<void(bool)> callback
) OVERRIDE
;
66 void ProceedDecidePermission(content::WebContents
* web_contents
,
67 const PermissionRequestInfo
& info
,
68 base::Callback
<void(bool)> callback
);
70 scoped_ptr
<GoogleLocationSettingsHelper
> google_location_settings_helper_
;
73 void CheckSystemLocation(content::WebContents
* web_contents
,
74 const PermissionRequestInfo
& info
,
75 base::Callback
<void(bool)> callback
);
77 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid
);
80 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_