Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(358)

Side by Side Diff: chrome/browser/geolocation/geolocation_permission_context_android.h

Issue 459953002: Migrate geolocation permissions to the new common permission class. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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::DecidePermission intercepts the flow in 11 // GeolocationPermissionContextAndroid::DecidePermission intercepts the flow in
12 // the UI thread, and posts a task to the blocking pool to CheckSystemLocation. 12 // the UI thread, and posts a task to the blocking pool to CheckSystemLocation.
13 // CheckSystemLocation will in fact check several possible settings 13 // CheckSystemLocation 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 23
24 // There is a bit of thread jumping since some of the permissions (like the 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 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. 26 // permissions are considered I/O and thus checked in the blocking thread pool.
27 27
28 #include "base/memory/scoped_ptr.h"
29 #include "base/memory/weak_ptr.h"
28 #include "chrome/browser/content_settings/permission_request_id.h" 30 #include "chrome/browser/content_settings/permission_request_id.h"
29 #include "chrome/browser/geolocation/geolocation_permission_context.h" 31 #include "chrome/browser/geolocation/geolocation_permission_context.h"
30 #include "url/gurl.h" 32 #include "url/gurl.h"
31 33
32 namespace content { 34 namespace content {
33 class WebContents; 35 class WebContents;
34 } 36 }
35 37
36 class GoogleLocationSettingsHelper; 38 class GoogleLocationSettingsHelper;
37 39
38
39 class GeolocationPermissionContextAndroid 40 class GeolocationPermissionContextAndroid
40 : public GeolocationPermissionContext { 41 : public GeolocationPermissionContext {
41 public: 42 public:
42 explicit GeolocationPermissionContextAndroid(Profile* profile); 43 explicit GeolocationPermissionContextAndroid(Profile* profile);
44 virtual ~GeolocationPermissionContextAndroid();
43 45
44 private: 46 private:
45 struct PermissionRequestInfo { 47 struct PermissionRequestInfo {
Michael van Ouwerkerk 2014/08/13 10:01:10 This struct looks generic. Can it be used for othe
Miguel Garcia 2014/08/13 13:18:13 This is only used to pass information during the t
46 PermissionRequestInfo(); 48 PermissionRequestInfo();
47 49
48 PermissionRequestID id; 50 PermissionRequestID id;
49 GURL requesting_frame; 51 GURL requesting_origin;
52 GURL embedder_origin;
50 bool user_gesture; 53 bool user_gesture;
51 GURL embedder;
52 }; 54 };
53 55
54 friend class GeolocationPermissionContext; 56 // PermissionContextBase:
57 virtual void RequestPermission(
58 content::WebContents* web_contents,
59 const PermissionRequestID& id,
60 const GURL& requesting_frame_origin,
61 bool user_gesture,
62 const BrowserPermissionCallback& callback) OVERRIDE;
55 63
56 virtual ~GeolocationPermissionContextAndroid(); 64 void CheckMasterLocation(content::WebContents* web_contents,
57 65 const PermissionRequestInfo& info,
58 // GeolocationPermissionContext implementation: 66 const BrowserPermissionCallback& callback);
59 virtual void DecidePermission(content::WebContents* web_contents,
60 const PermissionRequestID& id,
61 const GURL& requesting_frame,
62 bool user_gesture,
63 const GURL& embedder,
64 base::Callback<void(bool)> callback) OVERRIDE;
65 67
66 void ProceedDecidePermission(content::WebContents* web_contents, 68 void ProceedDecidePermission(content::WebContents* web_contents,
67 const PermissionRequestInfo& info, 69 const PermissionRequestInfo& info,
68 base::Callback<void(bool)> callback); 70 base::Callback<void(bool)> callback);
69 71
72 // Will perform a final check on the system location settigns before
Michael van Ouwerkerk 2014/08/13 10:01:10 s/settigns/settings/
Miguel Garcia 2014/08/13 13:18:13 Done.
73 // granting the permission.
74 void InterceptPermissionCheck(const BrowserPermissionCallback& callback,
75 bool granted);
76
70 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_; 77 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_;
78 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
71 79
72 private:
73 void CheckSystemLocation(content::WebContents* web_contents,
74 const PermissionRequestInfo& info,
75 base::Callback<void(bool)> callback);
76 80
77 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); 81 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
78 }; 82 };
79 83
80 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ 84 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698