Only grant permissions to new extensions from sync if they have the expected version
[chromium-blink-merge.git] / chrome / browser / geolocation / geolocation_permission_context_android.h
blob23918318936489709a85cc3ef1e62fd7862aecdd
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::RequestPermission intercepts the flow
12 // and proceeds to check the system location.
13 // This 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.
23 #include "base/memory/scoped_ptr.h"
24 #include "base/memory/weak_ptr.h"
25 #include "chrome/browser/geolocation/geolocation_permission_context.h"
27 namespace content {
28 class WebContents;
31 class LocationSettings;
32 class GURL;
33 class PermissionRequestID;
35 class GeolocationPermissionContextAndroid
36 : public GeolocationPermissionContext {
37 public:
38 explicit GeolocationPermissionContextAndroid(Profile* profile);
39 ~GeolocationPermissionContextAndroid() override;
41 private:
42 friend class GeolocationPermissionContextTests;
44 // GeolocationPermissionContext:
45 void RequestPermission(
46 content::WebContents* web_contents,
47 const PermissionRequestID& id,
48 const GURL& requesting_frame_origin,
49 bool user_gesture,
50 const BrowserPermissionCallback& callback) override;
52 void HandleUpdateAndroidPermissions(const PermissionRequestID& id,
53 const GURL& requesting_frame_origin,
54 const GURL& embedding_origin,
55 const BrowserPermissionCallback& callback,
56 bool permissions_updated);
58 // Overrides the LocationSettings object used to determine whether
59 // system and Chrome-wide location permissions are enabled.
60 void SetLocationSettingsForTesting(scoped_ptr<LocationSettings> settings);
62 scoped_ptr<LocationSettings> location_settings_;
64 // Must be the last member, to ensure that it will be destroyed first, which
65 // will invalidate weak pointers.
66 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
68 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
71 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_