| 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/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 prefs->CommitPendingWrite(); | 32 prefs->CommitPendingWrite(); |
| 33 } | 33 } |
| 34 | 34 |
| 35 // Saves integer "Local State" preference and forces its persistence to disk. | 35 // Saves integer "Local State" preference and forces its persistence to disk. |
| 36 void SaveIntegerPreferenceForced(const char* pref_name, int value) { | 36 void SaveIntegerPreferenceForced(const char* pref_name, int value) { |
| 37 PrefService* prefs = g_browser_process->local_state(); | 37 PrefService* prefs = g_browser_process->local_state(); |
| 38 prefs->SetInteger(pref_name, value); | 38 prefs->SetInteger(pref_name, value); |
| 39 prefs->CommitPendingWrite(); | 39 prefs->CommitPendingWrite(); |
| 40 } | 40 } |
| 41 | 41 |
| 42 // Saves 64 bit signed integer "Local State" preference and forces its |
| 43 // persistence to disk. |
| 44 void SaveInt64PreferenceForced(const char* pref_name, int64_t value) { |
| 45 PrefService* prefs = g_browser_process->local_state(); |
| 46 prefs->SetInt64(pref_name, value); |
| 47 prefs->CommitPendingWrite(); |
| 48 } |
| 49 |
| 42 // Saves string "Local State" preference and forces its persistence to disk. | 50 // Saves string "Local State" preference and forces its persistence to disk. |
| 43 void SaveStringPreferenceForced(const char* pref_name, | 51 void SaveStringPreferenceForced(const char* pref_name, |
| 44 const std::string& value) { | 52 const std::string& value) { |
| 45 PrefService* prefs = g_browser_process->local_state(); | 53 PrefService* prefs = g_browser_process->local_state(); |
| 46 prefs->SetString(pref_name, value); | 54 prefs->SetString(pref_name, value); |
| 47 prefs->CommitPendingWrite(); | 55 prefs->CommitPendingWrite(); |
| 48 } | 56 } |
| 49 | 57 |
| 50 // Returns the path to flag file indicating that both parts of OOBE were | 58 // Returns the path to flag file indicating that both parts of OOBE were |
| 51 // completed. | 59 // completed. |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 83 // static | 91 // static |
| 84 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { | 92 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { |
| 85 registry->RegisterBooleanPref(prefs::kOobeComplete, false); | 93 registry->RegisterBooleanPref(prefs::kOobeComplete, false); |
| 86 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); | 94 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); |
| 87 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); | 95 registry->RegisterBooleanPref(prefs::kOobeMdMode, false); |
| 88 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); | 96 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); |
| 89 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); | 97 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false); |
| 90 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); | 98 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); |
| 91 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); | 99 registry->RegisterBooleanPref(prefs::kIsBootstrappingSlave, false); |
| 92 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); | 100 registry->RegisterBooleanPref(prefs::kOobeControllerDetected, false); |
| 101 registry->RegisterInt64Pref(prefs::kTimeOfLastUpdateCheckWithoutUpdate, 0); |
| 93 } | 102 } |
| 94 | 103 |
| 95 // static | 104 // static |
| 96 bool StartupUtils::IsEulaAccepted() { | 105 bool StartupUtils::IsEulaAccepted() { |
| 97 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); | 106 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); |
| 98 } | 107 } |
| 99 | 108 |
| 100 // static | 109 // static |
| 101 bool StartupUtils::IsOobeCompleted() { | 110 bool StartupUtils::IsOobeCompleted() { |
| 102 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); | 111 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 191 } | 200 } |
| 192 | 201 |
| 193 // static | 202 // static |
| 194 void StartupUtils::SetInitialLocale(const std::string& locale) { | 203 void StartupUtils::SetInitialLocale(const std::string& locale) { |
| 195 if (l10n_util::IsValidLocaleSyntax(locale)) | 204 if (l10n_util::IsValidLocaleSyntax(locale)) |
| 196 SaveStringPreferenceForced(prefs::kInitialLocale, locale); | 205 SaveStringPreferenceForced(prefs::kInitialLocale, locale); |
| 197 else | 206 else |
| 198 NOTREACHED(); | 207 NOTREACHED(); |
| 199 } | 208 } |
| 200 | 209 |
| 210 // static |
| 211 void StartupUtils::SaveTimeOfLastUpdateCheckWithoutUpdate(base::Time time) { |
| 212 SaveInt64PreferenceForced(prefs::kTimeOfLastUpdateCheckWithoutUpdate, |
| 213 time.ToInternalValue()); |
| 214 } |
| 215 |
| 216 // static |
| 217 base::Time StartupUtils::GetTimeOfLastUpdateCheckWithoutUpdate() { |
| 218 return base::Time::FromInternalValue( |
| 219 g_browser_process->local_state()->GetInt64( |
| 220 prefs::kTimeOfLastUpdateCheckWithoutUpdate)); |
| 221 } |
| 222 |
| 201 } // namespace chromeos | 223 } // namespace chromeos |
| OLD | NEW |