| OLD | NEW |
| 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 #include "chrome/browser/android/mock_location_settings.h" | 5 #include "chrome/browser/android/mock_location_settings.h" |
| 6 | 6 |
| 7 bool MockLocationSettings::master_location_enabled = false; | 7 bool MockLocationSettings::has_android_location_permission_ = false; |
| 8 bool MockLocationSettings::google_apps_location_enabled = false; | 8 bool MockLocationSettings::is_system_location_setting_enabled_ = false; |
| 9 bool MockLocationSettings::can_prompt_for_android_location_permission_ = false; |
| 10 bool MockLocationSettings::location_settings_dialog_enabled_ = false; |
| 11 LocationSettingsDialogOutcome |
| 12 MockLocationSettings::location_settings_dialog_outcome_ = NO_PROMPT; |
| 13 bool MockLocationSettings::has_shown_location_settings_dialog_ = false; |
| 9 | 14 |
| 10 MockLocationSettings::MockLocationSettings() : LocationSettings() { | 15 MockLocationSettings::MockLocationSettings() : LocationSettings() { |
| 11 } | 16 } |
| 12 | 17 |
| 13 MockLocationSettings::~MockLocationSettings() { | 18 MockLocationSettings::~MockLocationSettings() { |
| 14 } | 19 } |
| 15 | 20 |
| 16 void MockLocationSettings::SetLocationStatus( | 21 void MockLocationSettings::SetLocationStatus( |
| 17 bool master, bool google_apps) { | 22 bool has_android_location_permission, |
| 18 master_location_enabled = master; | 23 bool is_system_location_setting_enabled) { |
| 19 google_apps_location_enabled = google_apps; | 24 has_android_location_permission_ = has_android_location_permission; |
| 25 is_system_location_setting_enabled_ = is_system_location_setting_enabled; |
| 20 } | 26 } |
| 21 | 27 |
| 22 bool MockLocationSettings::IsGoogleAppsLocationSettingEnabled() { | 28 void MockLocationSettings::SetCanPromptForAndroidPermission(bool can_prompt) { |
| 23 return google_apps_location_enabled; | 29 can_prompt_for_android_location_permission_ = can_prompt; |
| 24 } | 30 } |
| 25 | 31 |
| 26 bool MockLocationSettings::IsMasterLocationSettingEnabled() { | 32 void MockLocationSettings::SetLocationSettingsDialogStatus( |
| 27 return master_location_enabled; | 33 bool enabled, |
| 34 LocationSettingsDialogOutcome outcome) { |
| 35 location_settings_dialog_enabled_ = enabled; |
| 36 location_settings_dialog_outcome_ = outcome; |
| 28 } | 37 } |
| 29 | 38 |
| 30 bool MockLocationSettings::CanSitesRequestLocationPermission( | 39 bool MockLocationSettings::HasShownLocationSettingsDialog() { |
| 40 return has_shown_location_settings_dialog_; |
| 41 } |
| 42 |
| 43 bool MockLocationSettings::HasAndroidLocationPermission() { |
| 44 return has_android_location_permission_; |
| 45 } |
| 46 |
| 47 bool MockLocationSettings::CanPromptForAndroidLocationPermission( |
| 31 content::WebContents* web_contents) { | 48 content::WebContents* web_contents) { |
| 32 return IsMasterLocationSettingEnabled() && | 49 return can_prompt_for_android_location_permission_; |
| 33 IsGoogleAppsLocationSettingEnabled(); | 50 } |
| 51 |
| 52 bool MockLocationSettings::IsSystemLocationSettingEnabled() { |
| 53 return is_system_location_setting_enabled_; |
| 34 } | 54 } |
| 35 | 55 |
| 36 bool MockLocationSettings::CanPromptToEnableSystemLocationSetting() { | 56 bool MockLocationSettings::CanPromptToEnableSystemLocationSetting() { |
| 37 return false; | 57 return location_settings_dialog_enabled_; |
| 38 } | 58 } |
| 39 | 59 |
| 40 void MockLocationSettings::PromptToEnableSystemLocationSetting( | 60 void MockLocationSettings::PromptToEnableSystemLocationSetting( |
| 41 const LocationSettingsDialogContext prompt_context, | 61 const LocationSettingsDialogContext prompt_context, |
| 42 content::WebContents* web_contents, | 62 content::WebContents* web_contents, |
| 43 LocationSettingsDialogOutcomeCallback callback) { | 63 LocationSettingsDialogOutcomeCallback callback) { |
| 44 std::move(callback).Run(LocationSettingsDialogOutcome::NO_PROMPT); | 64 has_shown_location_settings_dialog_ = true; |
| 65 std::move(callback).Run(location_settings_dialog_outcome_); |
| 45 } | 66 } |
| OLD | NEW |