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

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

Issue 2709883005: Stubs for triggering the LSD in Clank (Closed)
Patch Set: Declare the dependency of components/location on WindowAndroid 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 // Asynchronously checks if a prompt can be triggered to ask the user to turn
benwells 2017/02/28 06:51:38 Is it necessary for this to be async? It makes the
29 // on the system location setting on their device, and returns true iff a
30 // prompt can be triggered.
31 // In particular, returns false if the system location setting is already
32 // enabled or if some of the features required to trigger a system location
33 // setting prompt are not available.
34 virtual void CanPromptToEnableSystemLocationSetting(
35 const base::Callback<void(bool can_prompt)>& callback) = 0;
36
37 // An enum to describe the context in which a system location setting prompt
38 // is triggered to allow the prompt UI to be customized to the given context.
39 //
40 // Keep in sync with the PromptContext IntDef in
41 // https://cs.chromium.org/chromium/src/components/location/android/java/src/o rg/chromium/components/location/LocationUtils.java
benwells 2017/02/28 06:26:36 Nit: you can refer to source files as //components
42 enum PromptContext {
benwells 2017/02/28 07:03:26 This (and PromptOutcome) are a bit vague - there m
43 // Prompt triggered in the context of a user gesture on a web page or on
44 // a preliminary domain or app permission prompt.
45 GESTURE = 1,
benwells 2017/02/28 06:26:36 Nit: I think we should call this NON_SEARCH. We mi
46 // Prompt triggered in the context of a search.
47 SEARCH = 2,
48 };
49
50 // An enum to describe the outcome of a location setting prompt triggered by
51 // PromptToEnableSystemLocationSetting().
52 //
53 // Keep in sync with the PromptOutcome IntDef in
54 // https://cs.chromium.org/chromium/src/components/location/android/java/src/o rg/chromium/components/location/LocationUtils.java
55 enum PromptOutcome {
56 // The user accepted the prompt and the system location setting has been
57 // flipped to granted.
58 GRANTED = 1,
59
60 // The user rejected the prompt and the system location setting has not been
61 // flipped.
62 DENIED = 2,
63
64 // The prompt could not be triggered.
65 // When CanPromptToEnableSystemLocationSetting() returns true, this should
66 // only happen in exceptional circonstances, e.g.
67 // - In the case of a race condition where the system location setting is
68 // flipped elsewhere before the prompt could be triggered;
69 // - In the case where some of the features required to trigger a system
70 // location setting prompt became unavailable or unresponsive after the
71 // response from CanPromptToEnableSystemLocationSetting() was received.
72 NO_PROMPT = 3,
73 };
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 PromptContext prompt_context,
80 content::WebContents* web_contents,
81 const base::Callback<void(PromptOutcome prompt_outcome)>& 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