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

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

Issue 2721293002: Show the Android Location Settings Dialog when sites want permission. (Closed)
Patch Set: Updated Created 3 years, 9 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
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::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 <memory> 23 #include <memory>
24 24
25 #include "base/macros.h" 25 #include "base/macros.h"
26 #include "base/memory/weak_ptr.h" 26 #include "base/memory/weak_ptr.h"
27 #include "chrome/browser/android/location_settings.h"
27 #include "chrome/browser/geolocation/geolocation_permission_context.h" 28 #include "chrome/browser/geolocation/geolocation_permission_context.h"
28 29
29 namespace content { 30 namespace content {
30 class WebContents; 31 class WebContents;
31 } 32 }
32 33
33 namespace infobars { 34 namespace infobars {
34 class InfoBar; 35 class InfoBar;
35 } 36 }
36 37
37 class LocationSettings;
38 class GURL; 38 class GURL;
39 class PermissionRequestID; 39 class PermissionRequestID;
40 40
41 class GeolocationPermissionContextAndroid 41 class GeolocationPermissionContextAndroid
42 : public GeolocationPermissionContext { 42 : public GeolocationPermissionContext {
43 public: 43 public:
44 explicit GeolocationPermissionContextAndroid(Profile* profile); 44 explicit GeolocationPermissionContextAndroid(Profile* profile);
45 ~GeolocationPermissionContextAndroid() override; 45 ~GeolocationPermissionContextAndroid() override;
46 46
47 protected: 47 protected:
(...skipping 14 matching lines...) Expand all
62 const BrowserPermissionCallback& callback) override; 62 const BrowserPermissionCallback& callback) override;
63 void CancelPermissionRequest(content::WebContents* web_contents, 63 void CancelPermissionRequest(content::WebContents* web_contents,
64 const PermissionRequestID& id) override; 64 const PermissionRequestID& id) override;
65 void NotifyPermissionSet(const PermissionRequestID& id, 65 void NotifyPermissionSet(const PermissionRequestID& id,
66 const GURL& requesting_origin, 66 const GURL& requesting_origin,
67 const GURL& embedding_origin, 67 const GURL& embedding_origin,
68 const BrowserPermissionCallback& callback, 68 const BrowserPermissionCallback& callback,
69 bool persist, 69 bool persist,
70 ContentSetting content_setting) override; 70 ContentSetting content_setting) override;
71 71
72 bool IsLocationAccessPossible(content::WebContents* web_contents,
73 const GURL& requesting_origin,
74 bool user_gesture);
75
76 LocationSettings::LocationSettingsDialogContext
77 GetLocationSettingsDialogContext(const GURL& requesting_origin);
78
72 void HandleUpdateAndroidPermissions(const PermissionRequestID& id, 79 void HandleUpdateAndroidPermissions(const PermissionRequestID& id,
73 const GURL& requesting_frame_origin, 80 const GURL& requesting_frame_origin,
74 const GURL& embedding_origin, 81 const GURL& embedding_origin,
75 const BrowserPermissionCallback& callback, 82 const BrowserPermissionCallback& callback,
76 bool permissions_updated); 83 bool permissions_updated);
77 84
85 // Will return true if the location settings dialog will be shown for the
86 // given origins. This is true if the location setting is off, the dialog can
87 // be shown, any gesture requirements for the origin are met, and the dialog
88 // is not being suppressed for backoff.
89 bool CanShowLocationSettingsDialog(const GURL& requesting_origin,
90 bool user_gesture);
91
92 void OnLocationSettingsDialogShown(
93 const PermissionRequestID& id,
94 const GURL& requesting_origin,
95 const GURL& embedding_origin,
96 const BrowserPermissionCallback& callback,
97 bool persist,
98 ContentSetting content_setting,
99 LocationSettings::LocationSettingsDialogOutcome prompt_outcome);
100
101 void FinishNotifyPermissionSet(const PermissionRequestID& id,
102 const GURL& requesting_origin,
103 const GURL& embedding_origin,
104 const BrowserPermissionCallback& callback,
105 bool persist,
106 ContentSetting content_setting);
107
78 // Overrides the LocationSettings object used to determine whether 108 // Overrides the LocationSettings object used to determine whether
79 // system and Chrome-wide location permissions are enabled. 109 // system and Chrome-wide location permissions are enabled.
80 void SetLocationSettingsForTesting( 110 void SetLocationSettingsForTesting(
81 std::unique_ptr<LocationSettings> settings); 111 std::unique_ptr<LocationSettings> settings);
82 112
83 std::unique_ptr<LocationSettings> location_settings_; 113 std::unique_ptr<LocationSettings> location_settings_;
84 114
85 // This is owned by the InfoBarService (owner of the InfoBar). 115 // This is owned by the InfoBarService (owner of the InfoBar).
86 infobars::InfoBar* permission_update_infobar_; 116 infobars::InfoBar* permission_update_infobar_;
87 117
88 // Must be the last member, to ensure that it will be destroyed first, which 118 // Must be the last member, to ensure that it will be destroyed first, which
89 // will invalidate weak pointers. 119 // will invalidate weak pointers.
90 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; 120 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
91 121
92 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); 122 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
93 }; 123 };
94 124
95 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ 125 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698