Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ | 5 #ifndef CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
| 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ | 6 #define CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
| 7 | 7 |
| 8 // The flow for geolocation permissions on Android needs to take into account | 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 | 9 // the global geolocation settings so it differs from the desktop one. It |
| 10 // works as follows. | 10 // works as follows. |
| 11 // GeolocationPermissionContextAndroid::RequestPermission intercepts the flow | 11 // GeolocationPermissionContextAndroid::RequestPermission intercepts the flow |
| 12 // and proceeds to check the system location. | 12 // and proceeds to check the system location. |
| 13 // This will in fact check several possible settings | 13 // This will in fact check several possible settings |
| 14 // - The global system geolocation setting | 14 // - The global system geolocation setting |
| 15 // - The Google location settings on pre KK devices | 15 // - The Google location settings on pre KK devices |
| 16 // - An old internal Chrome setting on pre-JB MR1 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. | 17 // With all that information it will decide if system location is enabled. |
| 18 // If enabled, it proceeds with the per site flow via | 18 // If enabled, it proceeds with the per site flow via |
| 19 // GeolocationPermissionContext (which will check per site permissions, create | 19 // GeolocationPermissionContext (which will check per site permissions, create |
| 20 // infobars, etc.). | 20 // infobars, etc.). |
| 21 // | 21 // |
| 22 // Otherwise the permission is already decided. | 22 // Otherwise the permission is already decided. |
| 23 #include "base/memory/scoped_ptr.h" | 23 #include "base/memory/scoped_ptr.h" |
| 24 #include "base/memory/weak_ptr.h" | |
| 24 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 25 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 25 | 26 |
| 26 namespace content { | 27 namespace content { |
| 27 class WebContents; | 28 class WebContents; |
| 28 } | 29 } |
| 29 | 30 |
| 30 class LocationSettings; | 31 class LocationSettings; |
| 31 class GURL; | 32 class GURL; |
| 32 class PermissionRequestID; | 33 class PermissionRequestID; |
| 33 | 34 |
| 34 class GeolocationPermissionContextAndroid | 35 class GeolocationPermissionContextAndroid |
| 35 : public GeolocationPermissionContext { | 36 : public GeolocationPermissionContext { |
| 36 public: | 37 public: |
| 37 explicit GeolocationPermissionContextAndroid(Profile* profile); | 38 explicit GeolocationPermissionContextAndroid(Profile* profile); |
| 38 ~GeolocationPermissionContextAndroid() override; | 39 ~GeolocationPermissionContextAndroid() override; |
| 39 | 40 |
| 40 private: | 41 private: |
| 41 friend class GeolocationPermissionContextTests; | 42 friend class GeolocationPermissionContextTests; |
| 42 | 43 |
| 43 // GeolocationPermissionContext: | 44 // GeolocationPermissionContext: |
| 44 void RequestPermission( | 45 void RequestPermission( |
| 45 content::WebContents* web_contents, | 46 content::WebContents* web_contents, |
| 46 const PermissionRequestID& id, | 47 const PermissionRequestID& id, |
| 47 const GURL& requesting_frame_origin, | 48 const GURL& requesting_frame_origin, |
| 48 bool user_gesture, | 49 bool user_gesture, |
| 49 const BrowserPermissionCallback& callback) override; | 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); | |
| 50 | 57 |
| 51 // Overrides the LocationSettings object used to determine whether | 58 // Overrides the LocationSettings object used to determine whether |
| 52 // system and Chrome-wide location permissions are enabled. | 59 // system and Chrome-wide location permissions are enabled. |
| 53 void SetLocationSettingsForTesting(scoped_ptr<LocationSettings> settings); | 60 void SetLocationSettingsForTesting(scoped_ptr<LocationSettings> settings); |
| 54 | 61 |
| 55 scoped_ptr<LocationSettings> location_settings_; | 62 scoped_ptr<LocationSettings> location_settings_; |
| 56 | 63 |
| 64 // Must be the last member, to ensure that it will be | |
| 65 // destroyed first, which will invalidate weak pointers | |
|
gone
2015/07/17 17:41:39
nit: add period. wrap at 80.
Ted C
2015/07/17 20:37:18
Done. Silly me for copying blindly from other inf
| |
| 66 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; | |
| 67 | |
| 57 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); | 68 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); |
| 58 }; | 69 }; |
| 59 | 70 |
| 60 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ | 71 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
| OLD | NEW |