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

Side by Side Diff: chrome/browser/chromeos/login/startup_utils.cc

Issue 374573006: Force enterprise enrollment flow upon detection of inconsistent state. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase. Created 6 years, 5 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 (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/file_util.h" 8 #include "base/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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
45 45
46 } // namespace 46 } // namespace
47 47
48 namespace chromeos { 48 namespace chromeos {
49 49
50 // static 50 // static
51 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) { 51 void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) {
52 registry->RegisterBooleanPref(prefs::kOobeComplete, false); 52 registry->RegisterBooleanPref(prefs::kOobeComplete, false);
53 registry->RegisterStringPref(prefs::kOobeScreenPending, ""); 53 registry->RegisterStringPref(prefs::kOobeScreenPending, "");
54 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1); 54 registry->RegisterIntegerPref(prefs::kDeviceRegistered, -1);
55 registry->RegisterBooleanPref(prefs::kEnrollmentRecoveryRequired, false);
55 registry->RegisterStringPref(prefs::kInitialLocale, "en-US"); 56 registry->RegisterStringPref(prefs::kInitialLocale, "en-US");
56 } 57 }
57 58
58 // static 59 // static
59 bool StartupUtils::IsEulaAccepted() { 60 bool StartupUtils::IsEulaAccepted() {
60 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted); 61 return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted);
61 } 62 }
62 63
63 // static 64 // static
64 bool StartupUtils::IsOobeCompleted() { 65 bool StartupUtils::IsOobeCompleted() {
65 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete); 66 return g_browser_process->local_state()->GetBoolean(prefs::kOobeComplete);
66 } 67 }
67 68
68 // static 69 // static
69 void StartupUtils::MarkEulaAccepted() { 70 void StartupUtils::MarkEulaAccepted() {
70 SaveBoolPreferenceForced(prefs::kEulaAccepted, true); 71 SaveBoolPreferenceForced(prefs::kEulaAccepted, true);
71 } 72 }
72 73
73 // static 74 // static
74 void StartupUtils::MarkOobeCompleted() { 75 void StartupUtils::MarkOobeCompleted() {
75 // Forcing the second pref will force this one as well. Even if this one 76 // Forcing the second pref will force this one as well. Even if this one
76 // doesn't end up synced it is only going to eat up a couple of bytes with no 77 // doesn't end up synced it is only going to eat up a couple of bytes with no
77 // side-effects. 78 // side-effects.
78 g_browser_process->local_state()->ClearPref(prefs::kOobeScreenPending); 79 g_browser_process->local_state()->ClearPref(prefs::kOobeScreenPending);
79 SaveBoolPreferenceForced(prefs::kOobeComplete, true); 80 SaveBoolPreferenceForced(prefs::kOobeComplete, true);
81
82 // Successful enrollment implies that recovery is not required.
83 SaveBoolPreferenceForced(prefs::kEnrollmentRecoveryRequired, false);
80 } 84 }
81 85
82 void StartupUtils::SaveOobePendingScreen(const std::string& screen) { 86 void StartupUtils::SaveOobePendingScreen(const std::string& screen) {
83 SaveStringPreferenceForced(prefs::kOobeScreenPending, screen); 87 SaveStringPreferenceForced(prefs::kOobeScreenPending, screen);
84 } 88 }
85 89
86 // Returns the path to flag file indicating that both parts of OOBE were 90 // Returns the path to flag file indicating that both parts of OOBE were
87 // completed. 91 // completed.
88 // On chrome device, returns /home/chronos/.oobe_completed. 92 // On chrome device, returns /home/chronos/.oobe_completed.
89 // On Linux desktop, returns {DIR_USER_DATA}/.oobe_completed. 93 // On Linux desktop, returns {DIR_USER_DATA}/.oobe_completed.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
147 } else { 151 } else {
148 BrowserThread::PostTaskAndReply( 152 BrowserThread::PostTaskAndReply(
149 BrowserThread::FILE, 153 BrowserThread::FILE,
150 FROM_HERE, 154 FROM_HERE,
151 base::Bind(&CreateOobeCompleteFlagFile), 155 base::Bind(&CreateOobeCompleteFlagFile),
152 done_callback); 156 done_callback);
153 } 157 }
154 } 158 }
155 159
156 // static 160 // static
161 bool StartupUtils::IsEnrollmentRecoveryRequired() {
162 return g_browser_process->local_state()
163 ->GetBoolean(prefs::kEnrollmentRecoveryRequired);
164 }
165
166 // static
167 void StartupUtils::MarkEnrollmentRecoveryRequired() {
168 SaveBoolPreferenceForced(prefs::kEnrollmentRecoveryRequired, true);
169 }
170
171 // static
157 std::string StartupUtils::GetInitialLocale() { 172 std::string StartupUtils::GetInitialLocale() {
158 std::string locale = 173 std::string locale =
159 g_browser_process->local_state()->GetString(prefs::kInitialLocale); 174 g_browser_process->local_state()->GetString(prefs::kInitialLocale);
160 if (!l10n_util::IsValidLocaleSyntax(locale)) 175 if (!l10n_util::IsValidLocaleSyntax(locale))
161 locale = "en-US"; 176 locale = "en-US";
162 return locale; 177 return locale;
163 } 178 }
164 179
165 // static 180 // static
166 void StartupUtils::SetInitialLocale(const std::string& locale) { 181 void StartupUtils::SetInitialLocale(const std::string& locale) {
167 if (l10n_util::IsValidLocaleSyntax(locale)) 182 if (l10n_util::IsValidLocaleSyntax(locale))
168 SaveStringPreferenceForced(prefs::kInitialLocale, locale); 183 SaveStringPreferenceForced(prefs::kInitialLocale, locale);
169 else 184 else
170 NOTREACHED(); 185 NOTREACHED();
171 } 186 }
172 187
173 } // namespace chromeos 188 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/login/startup_utils.h ('k') | chrome/browser/chromeos/login/ui/login_display_host_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698