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

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

Issue 441883003: Simplify Android geolocation permission checks (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 (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
Bernhard Bauer 2014/08/05 12:43:50 Nit: Android is capitalized.
Miguel Garcia 2014/08/05 16:19:41 Done.
9 // the global geolocation settings so it differs from the desktop one. It
10 // works as follows.
11 // - GeolocationPermissionContextAndroid::DecidePermission
Bernhard Bauer 2014/08/05 12:43:50 Nit: This should be either indented to match the o
Miguel Garcia 2014/08/05 16:19:41 Done.
12 // intercepts the flow in the UI thread, and posts a task
13 // to the blocking pool to CheckSystemLocation.
14 // CheckSystemLocation will in fact check several possible settings
15 // - The global system geolocation setting
16 // - The Google location settings on pre KK devices
17 // - An old internal Chrome setting on pre-JB MR1 devices
18 // With all that information it will decide if system location is enabled.
19 // If enabled, it proceeds with the per site flow
20 // via GeolocationPermissionContext (which will check per site permissions,
21 // create infobars, etc.).
22 //
23 // Otherwise the permission is already decided.
24
25 // There is a bit of thread jumping since some of the permissions
26 // (like the per site settings) are queried on the UX thread while the
Bernhard Bauer 2014/08/05 12:43:50 Nit: "UI thread"
Miguel Garcia 2014/08/05 16:19:41 Done.
27 // system level permissions are considered I/O and thus checked in the
28 // blocking thread pool.
29
8 #include "chrome/browser/content_settings/permission_request_id.h" 30 #include "chrome/browser/content_settings/permission_request_id.h"
9 #include "chrome/browser/geolocation/geolocation_permission_context.h" 31 #include "chrome/browser/geolocation/geolocation_permission_context.h"
10 #include "url/gurl.h" 32 #include "url/gurl.h"
11 33
12 namespace content { 34 namespace content {
13 class WebContents; 35 class WebContents;
14 } 36 }
15 37
16 class GoogleLocationSettingsHelper; 38 class GoogleLocationSettingsHelper;
17 39
18 // Android-specific geolocation permission flow, taking into account the 40
19 // Google Location Settings, if available.
20 class GeolocationPermissionContextAndroid 41 class GeolocationPermissionContextAndroid
21 : public GeolocationPermissionContext { 42 : public GeolocationPermissionContext {
22 public: 43 public:
23 explicit GeolocationPermissionContextAndroid(Profile* profile); 44 explicit GeolocationPermissionContextAndroid(Profile* profile);
24 45
25 private: 46 private:
26 struct PermissionRequestInfo { 47 struct PermissionRequestInfo {
27 PermissionRequestInfo(); 48 PermissionRequestInfo();
28 49
29 PermissionRequestID id; 50 PermissionRequestID id;
30 GURL requesting_frame; 51 GURL requesting_frame;
31 bool user_gesture; 52 bool user_gesture;
32 GURL embedder; 53 GURL embedder;
33 }; 54 };
34 55
35 friend class GeolocationPermissionContext; 56 friend class GeolocationPermissionContext;
36 57
37 virtual ~GeolocationPermissionContextAndroid(); 58 virtual ~GeolocationPermissionContextAndroid();
38 59
39 // GeolocationPermissionContext implementation: 60 // GeolocationPermissionContext implementation:
40 virtual void DecidePermission(content::WebContents* web_contents, 61 virtual void DecidePermission(content::WebContents* web_contents,
41 const PermissionRequestID& id, 62 const PermissionRequestID& id,
42 const GURL& requesting_frame, 63 const GURL& requesting_frame,
43 bool user_gesture, 64 bool user_gesture,
44 const GURL& embedder, 65 const GURL& embedder,
45 const std::string& accept_button_label,
46 base::Callback<void(bool)> callback) OVERRIDE; 66 base::Callback<void(bool)> callback) OVERRIDE;
47 67
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, 68 void ProceedDecidePermission(content::WebContents* web_contents,
55 const PermissionRequestInfo& info, 69 const PermissionRequestInfo& info,
56 const std::string& accept_button_label,
57 base::Callback<void(bool)> callback); 70 base::Callback<void(bool)> callback);
58 71
59 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_; 72 scoped_ptr<GoogleLocationSettingsHelper> google_location_settings_helper_;
60 73
61 private: 74 private:
62 void CheckMasterLocation(content::WebContents* web_contents, 75 void CheckSystemLocation(content::WebContents* web_contents,
63 const PermissionRequestInfo& info, 76 const PermissionRequestInfo& info,
64 base::Callback<void(bool)> callback); 77 base::Callback<void(bool)> callback);
65 78
66 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); 79 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
67 }; 80 };
68 81
69 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ 82 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698