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. |
(...skipping 27 matching lines...) Expand all Loading... |
38 class InfoBar; | 38 class InfoBar; |
39 } | 39 } |
40 | 40 |
41 class GURL; | 41 class GURL; |
42 class PermissionRequestID; | 42 class PermissionRequestID; |
43 class PrefRegistrySimple; | 43 class PrefRegistrySimple; |
44 | 44 |
45 class GeolocationPermissionContextAndroid | 45 class GeolocationPermissionContextAndroid |
46 : public GeolocationPermissionContext { | 46 : public GeolocationPermissionContext { |
47 public: | 47 public: |
| 48 // This enum is used in histograms, thus is append only. Do not re-order or |
| 49 // remove any entries, or add any except at the end. |
| 50 enum class LocationSettingsDialogBackOff { |
| 51 kNoBackOff, |
| 52 kOneWeek, |
| 53 kOneMonth, |
| 54 kThreeMonths, |
| 55 kCount, |
| 56 }; |
| 57 |
48 static void RegisterProfilePrefs(PrefRegistrySimple* registry); | 58 static void RegisterProfilePrefs(PrefRegistrySimple* registry); |
49 | 59 |
50 explicit GeolocationPermissionContextAndroid(Profile* profile); | 60 explicit GeolocationPermissionContextAndroid(Profile* profile); |
51 ~GeolocationPermissionContextAndroid() override; | 61 ~GeolocationPermissionContextAndroid() override; |
52 | 62 |
53 protected: | 63 protected: |
54 // GeolocationPermissionContext: | 64 // GeolocationPermissionContext: |
55 ContentSetting GetPermissionStatusInternal( | 65 ContentSetting GetPermissionStatusInternal( |
56 content::RenderFrameHost* render_frame_host, | 66 content::RenderFrameHost* render_frame_host, |
57 const GURL& requesting_origin, | 67 const GURL& requesting_origin, |
(...skipping 23 matching lines...) Expand all Loading... |
81 const GURL& embedding_origin, | 91 const GURL& embedding_origin, |
82 const BrowserPermissionCallback& callback, | 92 const BrowserPermissionCallback& callback, |
83 bool persist, | 93 bool persist, |
84 ContentSetting content_setting) override; | 94 ContentSetting content_setting) override; |
85 PermissionResult UpdatePermissionStatusWithDeviceStatus( | 95 PermissionResult UpdatePermissionStatusWithDeviceStatus( |
86 PermissionResult result, | 96 PermissionResult result, |
87 const GURL& requesting_origin, | 97 const GURL& requesting_origin, |
88 const GURL& embedding_origin) const override; | 98 const GURL& embedding_origin) const override; |
89 | 99 |
90 // Functions to handle back off for showing the Location Settings Dialog. | 100 // Functions to handle back off for showing the Location Settings Dialog. |
91 std::string GetLocationSettingsBackOffLevelPref( | 101 std::string GetLocationSettingsBackOffLevelPref(bool is_default_search) const; |
92 const GURL& requesting_origin) const; | 102 std::string GetLocationSettingsNextShowPref(bool is_default_search) const; |
93 std::string GetLocationSettingsNextShowPref( | 103 bool IsInLocationSettingsBackOff(bool is_default_search) const; |
94 const GURL& requesting_origin) const; | 104 void ResetLocationSettingsBackOff(bool is_default_search); |
95 bool IsInLocationSettingsBackOff(const GURL& requesting_origin) const; | 105 void UpdateLocationSettingsBackOff(bool is_default_search); |
96 void ResetLocationSettingsBackOff(const GURL& requesting_origin); | 106 LocationSettingsDialogBackOff LocationSettingsBackOffLevel( |
97 void UpdateLocationSettingsBackOff(const GURL& requesting_origin); | 107 bool is_default_search) const; |
98 | 108 |
99 // Returns whether location access is possible for the given origin. Ignores | 109 // Returns whether location access is possible for the given origin. Ignores |
100 // Location Settings Dialog backoff, as the backoff is ignored if the user | 110 // Location Settings Dialog backoff, as the backoff is ignored if the user |
101 // will be prompted for permission. | 111 // will be prompted for permission. |
102 bool IsLocationAccessPossible(content::WebContents* web_contents, | 112 bool IsLocationAccessPossible(content::WebContents* web_contents, |
103 const GURL& requesting_origin, | 113 const GURL& requesting_origin, |
104 bool user_gesture); | 114 bool user_gesture); |
105 | 115 |
106 bool IsRequestingOriginDSE(const GURL& requesting_origin) const; | 116 bool IsRequestingOriginDSE(const GURL& requesting_origin) const; |
107 | 117 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
146 infobars::InfoBar* permission_update_infobar_; | 156 infobars::InfoBar* permission_update_infobar_; |
147 | 157 |
148 // Must be the last member, to ensure that it will be destroyed first, which | 158 // Must be the last member, to ensure that it will be destroyed first, which |
149 // will invalidate weak pointers. | 159 // will invalidate weak pointers. |
150 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; | 160 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; |
151 | 161 |
152 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); | 162 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); |
153 }; | 163 }; |
154 | 164 |
155 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ | 165 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
OLD | NEW |