| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #include "chrome/browser/chromeos/login/startup_utils.h" | 5 #include "chrome/browser/chromeos/login/startup_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/prefs/pref_registry_simple.h" | 10 #include "base/prefs/pref_registry_simple.h" |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 50 namespace chromeos { | 50 namespace chromeos { |
| 51 | 51 |
| 52 // static | 52 // static |
| 53 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 53 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
| 54 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 54 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
| 55 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); | 55 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
| 56 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 56 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
| 57 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); | 57 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); |
| 58 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 58 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
| 59 registry->RegisterBooleanPref(prefs::kNewOobe, false); | 59 registry->RegisterBooleanPref(prefs::kNewOobe, false); |
| 60 registry->RegisterBooleanPref(prefs::kWebviewSigninEnabled, false); |
| 60 } | 61 } |
| 61 | 62 |
| 62 // static | 63 // static |
| 63 bool StartupUtils::IsEulaAccepted() { | 64 bool StartupUtils::IsEulaAccepted() { |
| 64 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 65 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
| 65 } | 66 } |
| 66 | 67 |
| 67 // static | 68 // static |
| 68 bool StartupUtils::IsOobeCompleted() { | 69 bool StartupUtils::IsOobeCompleted() { |
| 69 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 70 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 // static | 169 // static |
| 169 std::string StartupUtils::GetInitialLocale() { | 170 std::string StartupUtils::GetInitialLocale() { |
| 170 std::string locale = | 171 std::string locale = |
| 171 g_browser_process->local_state()->GetString(prefs::kInitialLocale); | 172 g_browser_process->local_state()->GetString(prefs::kInitialLocale); |
| 172 if (!l10n_util::IsValidLocaleSyntax(locale)) | 173 if (!l10n_util::IsValidLocaleSyntax(locale)) |
| 173 locale = "en-US"; | 174 locale = "en-US"; |
| 174 return locale; | 175 return locale; |
| 175 } | 176 } |
| 176 | 177 |
| 177 // static | 178 // static |
| 179 bool StartupUtils::IsWebviewSigninAllowed() { |
| 180 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; |
| 181 } |
| 182 |
| 183 // static |
| 184 bool StartupUtils::IsWebviewSigninEnabled() { |
| 185 return IsWebviewSigninAllowed() && |
| 186 g_browser_process->local_state()->GetBoolean( |
| 187 prefs::kWebviewSigninEnabled); |
| 188 } |
| 189 |
| 190 // static |
| 191 bool StartupUtils::EnableWebviewSignin(bool is_enabled) { |
| 192 if (!IsWebviewSigninAllowed()) |
| 193 return false; |
| 194 |
| 195 g_browser_process->local_state()->SetBoolean(prefs::kWebviewSigninEnabled, |
| 196 is_enabled); |
| 197 return true; |
| 198 } |
| 199 |
| 200 // static |
| 178 void StartupUtils::SetInitialLocale(const std::string& locale) { | 201 void StartupUtils::SetInitialLocale(const std::string& locale) { |
| 179 if (l10n_util::IsValidLocaleSyntax(locale)) | 202 if (l10n_util::IsValidLocaleSyntax(locale)) |
| 180 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 203 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
| 181 else | 204 else |
| 182 NOTREACHED(); | 205 NOTREACHED(); |
| 183 } | 206 } |
| 184 | 207 |
| 185 // static | 208 // static |
| 186 bool StartupUtils::IsNewOobeAllowed() { | 209 bool StartupUtils::IsNewOobeAllowed() { |
| 187 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; | 210 return extensions::GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV; |
| 188 } | 211 } |
| 189 | 212 |
| 190 // static | 213 // static |
| 191 bool StartupUtils::IsNewOobeActivated() { | 214 bool StartupUtils::IsNewOobeActivated() { |
| 192 return g_browser_process->local_state()->GetBoolean(prefs::kNewOobe) && | 215 return g_browser_process->local_state()->GetBoolean(prefs::kNewOobe) && |
| 193 IsNewOobeAllowed(); | 216 IsNewOobeAllowed(); |
| 194 } | 217 } |
| 195 | 218 |
| 196 } // namespace chromeos | 219 } // namespace chromeos |
| OLD | NEW |