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

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: 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 20 matching lines...) Expand all
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 void HandleUpdateAndroidPermissions(const PermissionRequestID& id, 72 void HandleUpdateAndroidPermissions(const PermissionRequestID& id,
73 const GURL& requesting_frame_origin, 73 const GURL& requesting_frame_origin,
74 const GURL& embedding_origin, 74 const GURL& embedding_origin,
75 const BrowserPermissionCallback& callback, 75 const BrowserPermissionCallback& callback,
76 bool permissions_updated); 76 bool permissions_updated);
77 77
78 // Will return true if the location settings dialog will be shown for the
79 // given origins. This is true if the location setting is off, the dialog can
80 // be shown, any gesture requirements for the origin are met, and the dialog
81 // is not being suppressed for backoff.
82 bool WillShowLocationSettingsDialog(const GURL& requesting_origin,
83 const GURL& embedding_origin);
84
85 void OnLocationSettingsDialogShown(
86 const PermissionRequestID& id,
87 const GURL& requesting_origin,
88 const GURL& embedding_origin,
89 const BrowserPermissionCallback& callback,
90 bool persist,
91 ContentSetting content_setting,
92 LocationSettings::LocationSettingsDialogPromptOutcome prompt_outcome);
93
94 void FinishNotifyPermissionSet(const PermissionRequestID& id,
95 const GURL& requesting_origin,
96 const GURL& embedding_origin,
97 const BrowserPermissionCallback& callback,
98 bool persist,
99 ContentSetting content_setting);
100
78 // Overrides the LocationSettings object used to determine whether 101 // Overrides the LocationSettings object used to determine whether
79 // system and Chrome-wide location permissions are enabled. 102 // system and Chrome-wide location permissions are enabled.
80 void SetLocationSettingsForTesting( 103 void SetLocationSettingsForTesting(
81 std::unique_ptr<LocationSettings> settings); 104 std::unique_ptr<LocationSettings> settings);
82 105
83 std::unique_ptr<LocationSettings> location_settings_; 106 std::unique_ptr<LocationSettings> location_settings_;
84 107
85 // This is owned by the InfoBarService (owner of the InfoBar). 108 // This is owned by the InfoBarService (owner of the InfoBar).
86 infobars::InfoBar* permission_update_infobar_; 109 infobars::InfoBar* permission_update_infobar_;
87 110
88 // Must be the last member, to ensure that it will be destroyed first, which 111 // Must be the last member, to ensure that it will be destroyed first, which
89 // will invalidate weak pointers. 112 // will invalidate weak pointers.
90 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_; 113 base::WeakPtrFactory<GeolocationPermissionContextAndroid> weak_factory_;
91 114
92 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid); 115 DISALLOW_COPY_AND_ASSIGN(GeolocationPermissionContextAndroid);
93 }; 116 };
94 117
95 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_ 118 #endif // CHROME_BROWSER_GEOLOCATION_GEOLOCATION_PERMISSION_CONTEXT_ANDROID_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698