Chromium Code Reviews| Index: chrome/browser/android/location_settings.h |
| diff --git a/chrome/browser/android/location_settings.h b/chrome/browser/android/location_settings.h |
| index 5d7fa7ec9c42059e31453f18fd37c1ab01fa0f2a..d1eb232ab64682371c17b571daceb797ccf243fd 100644 |
| --- a/chrome/browser/android/location_settings.h |
| +++ b/chrome/browser/android/location_settings.h |
| @@ -5,6 +5,7 @@ |
| #ifndef CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_ |
| #define CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_ |
| +#include "base/callback.h" |
| #include "base/macros.h" |
| namespace content { |
| @@ -23,6 +24,61 @@ class LocationSettings { |
| // still has the ability to request the permissions to be granted. |
| virtual bool CanSitesRequestLocationPermission( |
| content::WebContents* web_contents) = 0; |
| + |
| + // Returns true iff a prompt can be triggered to ask the user to turn on the |
| + // system location setting on their device. |
| + // In particular, returns false if the system location setting is already |
| + // enabled or if some of the features required to trigger a system location |
| + // setting prompt are not available. |
| + virtual bool CanPromptToEnableSystemLocationSetting() = 0; |
| + |
| + // An enum to describe the context in which a system location setting prompt |
| + // is triggered to allow the prompt UI to be customized to the given context. |
| + // |
| + // Keep in sync with the LocationSettingsDialogContext IntDef in |
|
Ted C
2017/03/02 00:21:56
We have a system to generate java int constants ba
qfiard
2017/03/02 13:28:13
Done, nice!
|
| + // //components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| + enum LocationSettingsDialogContext { |
| + // Default context. |
| + DEFAULT = 1, |
| + // Prompt triggered in the context of a search. |
| + SEARCH = 2, |
| + }; |
| + |
| + // An enum to describe the outcome of a location setting prompt triggered by |
| + // PromptToEnableSystemLocationSetting(). |
| + // |
| + // Keep in sync with the LocationSettingsDialogOutcome IntDef in |
| + // //components/location/android/java/src/org/chromium/components/location/LocationUtils.java |
| + enum LocationSettingsDialogOutcome { |
| + // The user accepted the prompt and the system location setting has been |
| + // flipped to granted. |
| + GRANTED = 1, |
| + |
| + // The user rejected the prompt and the system location setting has not been |
| + // flipped. |
| + DENIED = 2, |
| + |
| + // The prompt could not be triggered. |
| + // When CanPromptToEnableSystemLocationSetting() returns true, this should |
| + // only happen in exceptional circonstances, e.g. |
| + // - In the case of a race condition where the system location setting is |
| + // flipped elsewhere before the prompt could be triggered; |
| + // - In the case where some of the features required to trigger a system |
| + // location setting prompt became unavailable or unresponsive after the |
| + // response from CanPromptToEnableSystemLocationSetting() was received. |
| + NO_PROMPT = 3, |
| + }; |
| + |
| + typedef base::OnceCallback<void(LocationSettingsDialogOutcome)> |
| + LocationSettingsDialogOutcomeCallback; |
| + |
| + // Triggers a prompt to ask the user to turn on the system location setting on |
| + // their device. |
| + // The prompt will be triggered in the activity of the web contents. |
| + virtual void PromptToEnableSystemLocationSetting( |
|
Ted C
2017/03/02 00:21:56
I would add comments about the lifetime of this.
qfiard
2017/03/02 13:28:13
Done.
|
| + const LocationSettingsDialogContext prompt_context, |
| + content::WebContents* web_contents, |
| + LocationSettingsDialogOutcomeCallback callback) = 0; |
| }; |
| #endif // CHROME_BROWSER_ANDROID_LOCATION_SETTINGS_H_ |