OLD | NEW |
---|---|
1 // Copyright (c) 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 | |
9 // the global geolocation settings so it differs from the desktop one. It | |
10 // works as follows. | |
11 // GeolocationPermissionContextAndroid::DecidePermissionintercepts the flow in | |
Michael van Ouwerkerk
2014/08/06 10:47:44
Nit: add a space between Permission and intercepts
Miguel Garcia
2014/08/06 12:56:59
Done.
| |
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.). | |
21 // | |
22 // Otherwise the permission is already decided. | |
23 | |
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. | |
27 | |
8 #include "chrome/browser/content_settings/permission_request_id.h" | 28 #include "chrome/browser/content_settings/permission_request_id.h" |
9 #include "chrome/browser/geolocation/geolocation_permission_context.h" | 29 #include "chrome/browser/geolocation/geolocation_permission_context.h" |
10 #include "url/gurl.h" | 30 #include "url/gurl.h" |
11 | 31 |
12 namespace content { | 32 namespace content { |
13 class WebContents; | 33 class WebContents; |
14 } | 34 } |
15 | 35 |
16 class GoogleLocationSettingsHelper; | 36 class GoogleLocationSettingsHelper; |
17 | 37 |
18 // Android-specific geolocation permission flow, taking into account the | 38 |
19 // Google Location Settings, if available. | |
20 class GeolocationPermissionContextAndroid | 39 class GeolocationPermissionContextAndroid |
21 : public GeolocationPermissionContext { | 40 : public GeolocationPermissionContext { |
22 public: | 41 public: |
23 explicit GeolocationPermissionContextAndroid(Profile* profile); | 42 explicit GeolocationPermissionContextAndroid(Profile* profile); |
24 | 43 |
25 private: | 44 private: |
26 struct PermissionRequestInfo { | 45 struct PermissionRequestInfo { |
27 PermissionRequestInfo(); | 46 PermissionRequestInfo(); |
28 | 47 |
29 PermissionRequestID id; | 48 PermissionRequestID id; |
30 GURL requesting_frame; | 49 GURL requesting_frame; |
31 bool user_gesture; | 50 bool user_gesture; |
32 GURL embedder; | 51 GURL embedder; |
33 }; | 52 }; |
34 | 53 |
35 friend class GeolocationPermissionContext; | 54 friend class GeolocationPermissionContext; |
36 | 55 |
37 virtual ~GeolocationPermissionContextAndroid(); | 56 virtual ~GeolocationPermissionContextAndroid(); |
38 | 57 |
39 // GeolocationPermissionContext implementation: | 58 // GeolocationPermissionContext implementation: |
40 virtual void DecidePermission(content::WebContents* web_contents, | 59 virtual void DecidePermission(content::WebContents* web_contents, |
41 const PermissionRequestID& id, | 60 const PermissionRequestID& id, |
42 const GURL& requesting_frame, | 61 const GURL& requesting_frame, |
43 bool user_gesture, | 62 bool user_gesture, |
44 const GURL& embedder, | 63 const GURL& embedder, |
45 const std::string& accept_button_label, | |
46 base::Callback<void(bool)> callback) OVERRIDE; | 64 base::Callback<void(bool)> callback) OVERRIDE; |
47 | 65 |
48 virtual void PermissionDecided(const PermissionRequestID& id, | |
49 const GURL& requesting_frame, | |
50 const GURL& embedder, | |
51 base::Callback<void(bool)> callback, | |
52 bool allowed) OVERRIDE; | |
53 | |
54 void ProceedDecidePermission(content::WebContents* web_contents, | 66 void ProceedDecidePermission(content::WebContents* web_contents, |
55 const PermissionRequestInfo& info, | 67 const PermissionRequestInfo& info, |
56 const std::string& accept_button_label, | |
57 base::Callback<void(bool)> callback); | 68 base::Callback<void(bool)> callback); |
58 | 69 |
59 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_; | 70 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_; |
60 | 71 |
61 private: | 72 private: |
62 void CheckMasterLocation(content::WebContents* web_contents, | 73 void CheckSystemLocation(content::WebContents* web_contents, |
63 const PermissionRequestInfo& info, | 74 const PermissionRequestInfo& info, |
64 base::Callback<void(bool)> callback); | 75 base::Callback<void(bool)> callback); |
65 | 76 |
66 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); | 77 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); |
67 }; | 78 }; |
68 | 79 |
69 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ | 80 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ |
OLD | NEW |