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

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

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

Powered by Google App Engine
This is Rietveld 408576698