seccomp-bpf: Remove legacy SandboxBPFPolicy class
[chromium-blink-merge.git] / chrome / browser / geolocation / geolocation_permission_context_android.h
blobea02ca6e7c559495e9c672a5f8d3ec676e8fd1fe
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
10 // works as follows.
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
20 // infobars, etc.).
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 "base/memory/scoped_ptr.h"
29 #include "base/memory/weak_ptr.h"
30 #include "chrome/browser/geolocation/geolocation_permission_context.h"
31 #include "components/content_settings/core/common/permission_request_id.h"
32 #include "url/gurl.h"
34 namespace content {
35 class WebContents;
38 class GoogleLocationSettingsHelper;
40 class GeolocationPermissionContextAndroid
41 : public GeolocationPermissionContext {
42 public:
43 explicit GeolocationPermissionContextAndroid(Profile* profile);
44 virtual ~GeolocationPermissionContextAndroid();
46 private:
47 struct PermissionRequestInfo {
48 PermissionRequestInfo();
50 PermissionRequestID id;
51 GURL requesting_origin;
52 GURL embedder_origin;
53 bool user_gesture;
56 // PermissionContextBase:
57 virtual void RequestPermission(
58 content::WebContents* web_contents,
59 const PermissionRequestID& id,
60 const GURL& requesting_frame_origin,
61 bool user_gesture,
62 const BrowserPermissionCallback& callback) override;
64 void CheckMasterLocation(content::WebContents* web_contents,
65 const PermissionRequestInfo& info,
66 const BrowserPermissionCallback& callback);
68 void ProceedDecidePermission(content::WebContents* web_contents,
69 const PermissionRequestInfo& info,
70 base::Callback<void(bool)> callback);
72 // Will perform a final check on the system location settings before
73 // granting the permission.
74 void InterceptPermissionCheck(const BrowserPermissionCallback& callback,
75 bool granted);
77 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_;
78 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
80 private:
81 void CheckSystemLocation(content::WebContents* web_contents,
82 const PermissionRequestInfo& info,
83 base::Callback<void(bool)> callback);
85 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
88 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_