[email protected] | c31d804 | 2014-08-06 16:35:39 | [diff] [blame] | 1 | // Copyright 2012 The Chromium Authors. All rights reserved. |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 5 | #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
| 6 | #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 7 | |
[email protected] | c31d804 | 2014-08-06 16:35:39 | [diff] [blame] | 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. |
miguelg | e10a825 | 2015-01-16 14:24:09 | [diff] [blame] | 11 | // GeolocationPermissionContextAndroid::RequestPermission intercepts the flow |
| 12 | // and proceeds to check the system location. |
| 13 | // This will in fact check several possible settings |
[email protected] | c31d804 | 2014-08-06 16:35:39 | [diff] [blame] | 14 | // - The global system geolocation setting |
| 15 | // - The Google location settings on pre KK devices |
finnur | dd71613 | 2014-12-11 15:07:53 | [diff] [blame] | 16 | // - An old internal Chrome setting on pre-JB MR1 devices |
[email protected] | c31d804 | 2014-08-06 16:35:39 | [diff] [blame] | 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.). |
| 21 | // |
| 22 | // Otherwise the permission is already decided. |
miguelg | fa05207 | 2014-09-29 15:31:38 | [diff] [blame] | 23 | #include "base/memory/scoped_ptr.h" |
tedchoc | 76bf812 | 2015-07-22 19:52:06 | [diff] [blame] | 24 | #include "base/memory/weak_ptr.h" |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 25 | #include "chrome/browser/geolocation/geolocation_permission_context.h" |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 26 | |
[email protected] | f068ad0e | 2014-02-11 13:48:23 | [diff] [blame] | 27 | namespace content { |
| 28 | class WebContents; |
| 29 | } |
| 30 | |
newt | e587c6d | 2015-01-21 20:45:12 | [diff] [blame] | 31 | class LocationSettings; |
miguelg | e10a825 | 2015-01-16 14:24:09 | [diff] [blame] | 32 | class GURL; |
| 33 | class PermissionRequestID; |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 34 | |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 35 | class GeolocationPermissionContextAndroid |
| 36 | : public GeolocationPermissionContext { |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 37 | public: |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 38 | explicit GeolocationPermissionContextAndroid(Profile* profile); |
newt | ad75c73 | 2015-01-13 20:21:37 | [diff] [blame] | 39 | ~GeolocationPermissionContextAndroid() override; |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 40 | |
| 41 | private: |
newt | ad75c73 | 2015-01-13 20:21:37 | [diff] [blame] | 42 | friend class GeolocationPermissionContextTests; |
| 43 | |
miguelg | e10a825 | 2015-01-16 14:24:09 | [diff] [blame] | 44 | // GeolocationPermissionContext: |
newt | ad75c73 | 2015-01-13 20:21:37 | [diff] [blame] | 45 | void RequestPermission( |
miguelg | fa05207 | 2014-09-29 15:31:38 | [diff] [blame] | 46 | content::WebContents* web_contents, |
tedchoc | 76bf812 | 2015-07-22 19:52:06 | [diff] [blame] | 47 | const PermissionRequestID& id, |
| 48 | const GURL& requesting_frame_origin, |
| 49 | bool user_gesture, |
| 50 | const BrowserPermissionCallback& callback) override; |
| 51 | |
| 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); |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 57 | |
newt | e587c6d | 2015-01-21 20:45:12 | [diff] [blame] | 58 | // Overrides the LocationSettings object used to determine whether |
newt | ad75c73 | 2015-01-13 20:21:37 | [diff] [blame] | 59 | // system and Chrome-wide location permissions are enabled. |
newt | e587c6d | 2015-01-21 20:45:12 | [diff] [blame] | 60 | void SetLocationSettingsForTesting(scoped_ptr<LocationSettings> settings); |
newt | ad75c73 | 2015-01-13 20:21:37 | [diff] [blame] | 61 | |
newt | e587c6d | 2015-01-21 20:45:12 | [diff] [blame] | 62 | scoped_ptr<LocationSettings> location_settings_; |
[email protected] | cc19a326 | 2014-02-27 13:02:59 | [diff] [blame] | 63 | |
tedchoc | 76bf812 | 2015-07-22 19:52:06 | [diff] [blame] | 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_; |
| 67 | |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 68 | DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); |
[email protected] | b2cf452 | 2012-10-23 00:11:57 | [diff] [blame] | 69 | }; |
| 70 | |
[email protected] | 487974a | 2014-06-13 16:49:01 | [diff] [blame] | 71 | #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |