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

Side by Side Diff: chrome/browser/android/location_settings.h

Issue 2709883005: Stubs for triggering the LSD in Clank (Closed)
Patch Set: Incorporate first batch of comments 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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_ANDROID_LOCATION_SETTINGS_H_ 5 #ifndef CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_
6 #define CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_ 6 #define CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_
7 7
8 #include "base/callback.h"
8 #include "base/macros.h" 9 #include "base/macros.h"
9 10
10 namespace content { 11 namespace content {
11 class WebContents; 12 class WebContents;
12 } 13 }
13 14
14 // This class determines whether Chrome can access the device's location, 15 // This class determines whether Chrome can access the device's location,
15 // i.e. whether location is enabled system-wide on the device. 16 // i.e. whether location is enabled system-wide on the device.
16 class LocationSettings { 17 class LocationSettings {
17 public: 18 public:
18 virtual ~LocationSettings() {} 19 virtual ~LocationSettings() {}
19 20
20 // Returns true if: 21 // Returns true if:
21 // - Location is enabled system-wide (in Android settings) 22 // - Location is enabled system-wide (in Android settings)
22 // - The necessary location permission are granted to Chrome, or if Chrome 23 // - The necessary location permission are granted to Chrome, or if Chrome
23 // still has the ability to request the permissions to be granted. 24 // still has the ability to request the permissions to be granted.
24 virtual bool CanSitesRequestLocationPermission( 25 virtual bool CanSitesRequestLocationPermission(
25 content::WebContents* web_contents) = 0; 26 content::WebContents* web_contents) = 0;
27
28 // Returns true iff a prompt can be triggered to ask the user to turn on the
29 // system location setting on their device.
30 // In particular, returns false if the system location setting is already
31 // enabled or if some of the features required to trigger a system location
32 // setting prompt are not available.
33 virtual bool CanPromptToEnableSystemLocationSetting() = 0;
34
35 // An enum to describe the context in which a system location setting prompt
36 // is triggered to allow the prompt UI to be customized to the given context.
37 //
38 // Keep in sync with the LocationSettingsDialogPromptContext IntDef in
39 // //components/location/android/java/src/org/chromium/components/location/Loc ationUtils.java
40 enum LocationSettingsDialogPromptContext {
benwells 2017/03/01 03:51:26 nit: Sorry, I know I suggested this name but the '
qfiard 2017/03/01 08:48:18 Done.
41 // Default context.
42 DEFAULT = 1,
43 // Prompt triggered in the context of a search.
44 SEARCH = 2,
45 };
46
47 // An enum to describe the outcome of a location setting prompt triggered by
48 // PromptToEnableSystemLocationSetting().
49 //
50 // Keep in sync with the LocationSettingsDialogPromptOutcome IntDef in
51 // //components/location/android/java/src/org/chromium/components/location/Loc ationUtils.java
52 enum LocationSettingsDialogPromptOutcome {
benwells 2017/03/01 03:51:26 nit: Ditto here, the 'Prompt' is redundant.
qfiard 2017/03/01 08:48:18 Done.
53 // The user accepted the prompt and the system location setting has been
54 // flipped to granted.
55 GRANTED = 1,
56
57 // The user rejected the prompt and the system location setting has not been
58 // flipped.
59 DENIED = 2,
60
61 // The prompt could not be triggered.
62 // When CanPromptToEnableSystemLocationSetting() returns true, this should
63 // only happen in exceptional circonstances, e.g.
64 // - In the case of a race condition where the system location setting is
65 // flipped elsewhere before the prompt could be triggered;
66 // - In the case where some of the features required to trigger a system
67 // location setting prompt became unavailable or unresponsive after the
68 // response from CanPromptToEnableSystemLocationSetting() was received.
69 NO_PROMPT = 3,
70 };
71
72 typedef base::OnceCallback<void(LocationSettingsDialogPromptOutcome)>
73 LocationSettingsDialogPromptOutcomeCallback;
74
75 // Triggers a prompt to ask the user to turn on the system location setting on
76 // their device.
77 // The prompt will be triggered in the activity of the web contents.
78 virtual void PromptToEnableSystemLocationSetting(
79 const LocationSettingsDialogPromptContext prompt_context,
80 content::WebContents* web_contents,
81 LocationSettingsDialogPromptOutcomeCallback callback) = 0;
26 }; 82 };
27 83
28 #endif // CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_ 84 #endif // CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698