summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 15:09:06 +0000
committerantrim@chromium.org <antrim@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-04-19 15:09:06 +0000
commitaa8328fb543ae6ce61522735586cfdd3349a49b4 (patch)
treefc166aa0c4515cba3663af5c4d64de44df5a6f6a
parent6f54b9b29087aad960be16e0c7060d73398ae001 (diff)
downloadchromium_src-aa8328fb543ae6ce61522735586cfdd3349a49b4.zip
chromium_src-aa8328fb543ae6ce61522735586cfdd3349a49b4.tar.gz
chromium_src-aa8328fb543ae6ce61522735586cfdd3349a49b4.tar.bz2
Move part of WizardController static code to StartupUtils
BUG=231331 TBR=ben@chromium.org Review URL: https://codereview.chromium.org/14362031 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@195202 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/automation/testing_automation_provider_chromeos.cc5
-rw-r--r--chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc3
-rw-r--r--chrome/browser/chromeos/chrome_browser_main_chromeos.cc3
-rw-r--r--chrome/browser/chromeos/extensions/info_private_api.cc4
-rw-r--r--chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc3
-rw-r--r--chrome/browser/chromeos/login/existing_user_controller.cc9
-rw-r--r--chrome/browser/chromeos/login/login_display_host_impl.cc15
-rw-r--r--chrome/browser/chromeos/login/screens/update_screen.cc3
-rw-r--r--chrome/browser/chromeos/login/startup_utils.cc169
-rw-r--r--chrome/browser/chromeos/login/startup_utils.h48
-rw-r--r--chrome/browser/chromeos/login/wallpaper_manager.cc3
-rw-r--r--chrome/browser/chromeos/login/webui_login_display_host.cc5
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.cc121
-rw-r--r--chrome/browser/chromeos/login/wizard_controller.h27
-rw-r--r--chrome/browser/chromeos/mobile_config.cc4
-rw-r--r--chrome/browser/chromeos/options/wimax_config_view.cc4
-rw-r--r--chrome/browser/chromeos/system/ash_system_tray_delegate.cc4
-rw-r--r--chrome/browser/chromeos/system/tray_accessibility_browsertest.cc4
-rw-r--r--chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc5
-rw-r--r--chrome/browser/prefs/browser_prefs.cc4
-rw-r--r--chrome/browser/ui/webui/help/version_updater_chromeos.cc3
-rw-r--r--chrome/chrome_browser_chromeos.gypi15
22 files changed, 278 insertions, 183 deletions
diff --git a/chrome/browser/automation/testing_automation_provider_chromeos.cc b/chrome/browser/automation/testing_automation_provider_chromeos.cc
index b027b5c..df93fa9 100644
--- a/chrome/browser/automation/testing_automation_provider_chromeos.cc
+++ b/chrome/browser/automation/testing_automation_provider_chromeos.cc
@@ -31,6 +31,7 @@
#include "chrome/browser/chromeos/login/screens/network_screen.h"
#include "chrome/browser/chromeos/login/screens/update_screen.h"
#include "chrome/browser/chromeos/login/screens/user_image_screen.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
#include "chrome/browser/chromeos/login/webui_login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -227,8 +228,7 @@ void TestingAutomationProvider::AcceptOOBEEula(DictionaryValue* args,
void TestingAutomationProvider::CancelOOBEUpdate(DictionaryValue* args,
IPC::Message* reply_message) {
- WizardController* wizard_controller = WizardController::default_controller();
- if (wizard_controller && wizard_controller->IsOobeCompleted()) {
+ if (chromeos::StartupUtils::IsOobeCompleted()) {
// Update already finished.
scoped_ptr<DictionaryValue> return_value(new DictionaryValue);
return_value->SetString("next_screen",
@@ -236,6 +236,7 @@ void TestingAutomationProvider::CancelOOBEUpdate(DictionaryValue* args,
AutomationJSONReply(this, reply_message).SendSuccess(return_value.get());
return;
}
+ WizardController* wizard_controller = WizardController::default_controller();
if (!wizard_controller || wizard_controller->current_screen()->GetName() !=
WizardController::kUpdateScreenName) {
AutomationJSONReply(this, reply_message).SendError(
diff --git a/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc b/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
index 614065d..09f4b72 100644
--- a/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
+++ b/chrome/browser/chromeos/background/ash_user_wallpaper_delegate.cc
@@ -10,6 +10,7 @@
#include "base/command_line.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/extensions/wallpaper_manager_util.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile_manager.h"
@@ -58,7 +59,7 @@ class UserWallpaperDelegate : public ash::UserWallpaperDelegate {
// It is a first boot case now. If kDisableBootAnimation flag
// is passed, it only disables any transition after OOBE.
// |kDisableOobeAnimation| disables OOBE animation for slow hardware.
- bool is_registered = WizardController::IsDeviceRegistered();
+ bool is_registered = StartupUtils::IsDeviceRegistered();
const CommandLine* command_line = CommandLine::ForCurrentProcess();
bool disable_boot_animation = command_line->
HasSwitch(::switches::kDisableBootAnimation);
diff --git a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
index 13152d9..681f040 100644
--- a/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
+++ b/chrome/browser/chromeos/chrome_browser_main_chromeos.cc
@@ -46,6 +46,7 @@
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/login_wizard.h"
#include "chrome/browser/chromeos/login/screen_locker.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -672,7 +673,7 @@ void ChromeBrowserMainPartsChromeos::PostProfileInit() {
#endif
// Enable portal detector if EULA was previously accepted or if
// this is an unofficial build.
- if (!is_official_build || WizardController::IsEulaAccepted())
+ if (!is_official_build || StartupUtils::IsEulaAccepted())
detector->Enable(true);
}
diff --git a/chrome/browser/chromeos/extensions/info_private_api.cc b/chrome/browser/chromeos/extensions/info_private_api.cc
index 87ee73e..872d790 100644
--- a/chrome/browser/chromeos/extensions/info_private_api.cc
+++ b/chrome/browser/chromeos/extensions/info_private_api.cc
@@ -7,8 +7,8 @@
#include "base/values.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/system/statistics_provider.h"
using chromeos::CrosLibrary;
@@ -76,7 +76,7 @@ base::Value* ChromeosInfoPrivateGetFunction::GetValue(
return new base::StringValue(netlib->GetCellularHomeCarrierId());
} else if (property_name == kPropertyInitialLocale) {
return new base::StringValue(
- chromeos::WizardController::GetInitialLocale());
+ chromeos::StartupUtils::GetInitialLocale());
} else if (property_name == kPropertyBoard) {
std::string board;
chromeos::system::StatisticsProvider* provider =
diff --git a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
index f67c631..dbbcc9e 100644
--- a/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
+++ b/chrome/browser/chromeos/login/enrollment/enterprise_enrollment_screen.cc
@@ -12,6 +12,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/screens/screen_observer.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
@@ -221,7 +222,7 @@ void EnterpriseEnrollmentScreen::ReportEnrollmentStatus(
switch (status.status()) {
case policy::EnrollmentStatus::STATUS_SUCCESS:
- WizardController::MarkDeviceRegistered();
+ StartupUtils::MarkDeviceRegistered();
UMA(is_auto_enrollment_ ? policy::kMetricEnrollmentAutoOK
: policy::kMetricEnrollmentOK);
return;
diff --git a/chrome/browser/chromeos/login/existing_user_controller.cc b/chrome/browser/chromeos/login/existing_user_controller.cc
index e54bf0e..77cb8a1 100644
--- a/chrome/browser/chromeos/login/existing_user_controller.cc
+++ b/chrome/browser/chromeos/login/existing_user_controller.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/login_display_host.h"
#include "chrome/browser/chromeos/login/login_utils.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/net/connectivity_state_helper.h"
@@ -784,8 +785,8 @@ void ExistingUserController::OnProfilePrepared(Profile* profile) {
#endif
// Mark the device as registered., i.e. the second part of OOBE as
// completed.
- if (!WizardController::IsDeviceRegistered())
- WizardController::MarkDeviceRegistered();
+ if (!StartupUtils::IsDeviceRegistered())
+ StartupUtils::MarkDeviceRegistered();
ActivateWizard(WizardController::kTermsOfServiceScreenName);
#ifndef NDEBUG
@@ -810,8 +811,8 @@ void ExistingUserController::OnOffTheRecordLoginSuccess() {
offline_failed_ = false;
// Mark the device as registered., i.e. the second part of OOBE as completed.
- if (!WizardController::IsDeviceRegistered())
- WizardController::MarkDeviceRegistered();
+ if (!StartupUtils::IsDeviceRegistered())
+ StartupUtils::MarkDeviceRegistered();
LoginUtils::Get()->CompleteOffTheRecordLogin(guest_mode_url_);
diff --git a/chrome/browser/chromeos/login/login_display_host_impl.cc b/chrome/browser/chromeos/login/login_display_host_impl.cc
index 549b6ee..7163bb7 100644
--- a/chrome/browser/chromeos/login/login_display_host_impl.cc
+++ b/chrome/browser/chromeos/login/login_display_host_impl.cc
@@ -28,6 +28,7 @@
#include "chrome/browser/chromeos/login/language_switch_menu.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/login_wizard.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/webui_login_display_host.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -193,7 +194,7 @@ void LoginDisplayHostImpl::StartWizard(
wizard_controller_.reset();
wizard_controller_.reset(CreateWizardController());
- oobe_progress_bar_visible_ = !WizardController::IsDeviceRegistered();
+ oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered();
SetOobeProgressBarVisible(oobe_progress_bar_visible_);
wizard_controller_->Init(first_screen_name, screen_parameters);
}
@@ -205,15 +206,15 @@ void LoginDisplayHostImpl::StartSignInScreen() {
// Fix for users who updated device and thus never passed register screen.
// If we already have users, we assume that it is not a second part of
// OOBE. See http://crosbug.com/6289
- if (!WizardController::IsDeviceRegistered() && !users.empty()) {
+ if (!StartupUtils::IsDeviceRegistered() && !users.empty()) {
VLOG(1) << "Mark device registered because there are remembered users: "
<< users.size();
- WizardController::MarkDeviceRegistered();
+ StartupUtils::MarkDeviceRegistered();
}
sign_in_controller_.reset(); // Only one controller in a time.
sign_in_controller_.reset(new chromeos::ExistingUserController(this));
- oobe_progress_bar_visible_ = !WizardController::IsDeviceRegistered();
+ oobe_progress_bar_visible_ = !StartupUtils::IsDeviceRegistered();
SetOobeProgressBarVisible(oobe_progress_bar_visible_);
SetStatusAreaVisible(true);
SetShutdownButtonEnabled(true);
@@ -418,7 +419,7 @@ void ShowLoginWizard(const std::string& first_screen_name,
gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(size));
// Check whether we need to execute OOBE process.
- bool oobe_complete = chromeos::WizardController::IsOobeCompleted();
+ bool oobe_complete = chromeos::StartupUtils::IsOobeCompleted();
if (!oobe_complete) {
LoginState::Get()->SetLoggedInState(
LoginState::LOGGED_IN_OOBE, LoginState::LOGGED_IN_USER_NONE);
@@ -440,7 +441,7 @@ void ShowLoginWizard(const std::string& first_screen_name,
// OOBE process has set kApplicationLocale to non-default value.
PrefService* prefs = g_browser_process->local_state();
if (!prefs->HasPrefPath(prefs::kApplicationLocale)) {
- std::string locale = chromeos::WizardController::GetInitialLocale();
+ std::string locale = chromeos::StartupUtils::GetInitialLocale();
prefs->SetString(prefs::kApplicationLocale, locale);
manager->EnableLayouts(
locale,
@@ -478,7 +479,7 @@ void ShowLoginWizard(const std::string& first_screen_name,
// Don't need to schedule pref save because setting initial local
// will enforce preference saving.
prefs->SetString(prefs::kApplicationLocale, locale);
- chromeos::WizardController::SetInitialLocale(locale);
+ chromeos::StartupUtils::SetInitialLocale(locale);
// Determine keyboard layout from OEM customization (if provided) or
// initial locale and save it in preferences.
DetermineAndSaveHardwareKeyboard(locale, layout);
diff --git a/chrome/browser/chromeos/login/screens/update_screen.cc b/chrome/browser/chromeos/login/screens/update_screen.cc
index 33b76be9..b9dbdaf 100644
--- a/chrome/browser/chromeos/login/screens/update_screen.cc
+++ b/chrome/browser/chromeos/login/screens/update_screen.cc
@@ -16,6 +16,7 @@
#include "chrome/browser/chromeos/login/screens/error_screen.h"
#include "chrome/browser/chromeos/login/screens/screen_observer.h"
#include "chrome/browser/chromeos/login/screens/update_screen_actor.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chromeos/chromeos_switches.h"
#include "chromeos/dbus/dbus_thread_manager.h"
@@ -205,7 +206,7 @@ void UpdateScreen::UpdateStatusChanged(
case UpdateEngineClient::UPDATE_STATUS_UPDATED_NEED_REBOOT:
MakeSureScreenIsShown();
// Make sure that first OOBE stage won't be shown after reboot.
- WizardController::MarkOobeCompleted();
+ StartupUtils::MarkOobeCompleted();
actor_->SetProgress(kProgressComplete);
actor_->ShowEstimatedTimeLeft(false);
if (HasCriticalUpdate()) {
diff --git a/chrome/browser/chromeos/login/startup_utils.cc b/chrome/browser/chromeos/login/startup_utils.cc
new file mode 100644
index 0000000..00ea3d0
--- /dev/null
+++ b/chrome/browser/chromeos/login/startup_utils.cc
@@ -0,0 +1,169 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/login/startup_utils.h"
+
+#include "base/bind.h"
+#include "base/chromeos/chromeos_version.h"
+#include "base/file_util.h"
+#include "base/prefs/pref_registry_simple.h"
+#include "base/prefs/pref_service.h"
+#include "base/threading/thread_restrictions.h"
+#include "chrome/browser/browser_process.h"
+#include "chrome/common/pref_names.h"
+#include "content/public/browser/browser_thread.h"
+#include "ui/base/l10n/l10n_util.h"
+
+using content::BrowserThread;
+
+namespace {
+
+// A string pref with initial locale set in VPD or manifest.
+const char kInitialLocale[] = "intl.initial_locale";
+
+// A boolean pref of the OOBE complete flag (first OOBE part before login).
+const char kOobeComplete[] = "OobeComplete";
+
+// A boolean pref of the device registered flag (second part after first login).
+const char kDeviceRegistered[] = "DeviceRegistered";
+
+// Time in seconds that we wait for the device to reboot.
+// If reboot didn't happen, ask user to reboot device manually.
+const int kWaitForRebootTimeSec = 3;
+
+// Saves boolean "Local State" preference and forces its persistence to disk.
+void SaveBoolPreferenceForced(const char* pref_name, bool value) {
+ PrefService* prefs = g_browser_process->local_state();
+ prefs->SetBoolean(pref_name, value);
+ prefs->CommitPendingWrite();
+}
+
+// Saves integer "Local State" preference and forces its persistence to disk.
+void SaveIntegerPreferenceForced(const char* pref_name, int value) {
+ PrefService* prefs = g_browser_process->local_state();
+ prefs->SetInteger(pref_name, value);
+ prefs->CommitPendingWrite();
+}
+
+// Saves string "Local State" preference and forces its persistence to disk.
+void SaveStringPreferenceForced(const char* pref_name,
+ const std::string& value) {
+ PrefService* prefs = g_browser_process->local_state();
+ prefs->SetString(pref_name, value);
+ prefs->CommitPendingWrite();
+}
+
+} // namespace
+
+namespace chromeos {
+
+// static
+void StartupUtils::RegisterPrefs(PrefRegistrySimple* registry) {
+ registry->RegisterBooleanPref(kOobeComplete, false);
+ registry->RegisterIntegerPref(kDeviceRegistered, -1);
+ registry->RegisterBooleanPref(prefs::kEulaAccepted, false);
+ registry->RegisterStringPref(kInitialLocale, "en-US");
+}
+
+// static
+bool StartupUtils::IsEulaAccepted() {
+ return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted);
+}
+
+// static
+bool StartupUtils::IsOobeCompleted() {
+ return g_browser_process->local_state()->GetBoolean(kOobeComplete);
+}
+
+// static
+void StartupUtils::MarkEulaAccepted() {
+ SaveBoolPreferenceForced(prefs::kEulaAccepted, true);
+}
+
+// static
+void StartupUtils::MarkOobeCompleted() {
+ SaveBoolPreferenceForced(kOobeComplete, true);
+}
+
+// Returns the path to flag file indicating that both parts of OOBE were
+// completed.
+// On chrome device, returns /home/chronos/.oobe_completed.
+// On Linux desktop, returns $HOME/.oobe_completed.
+static base::FilePath GetOobeCompleteFlagPath() {
+ // The constant is defined here so it won't be referenced directly.
+ const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
+
+ if (base::chromeos::IsRunningOnChromeOS()) {
+ return base::FilePath(kOobeCompleteFlagFilePath);
+ } else {
+ const char* home = getenv("HOME");
+ // Unlikely but if HOME is not defined, use the current directory.
+ if (!home)
+ home = "";
+ return base::FilePath(home).AppendASCII(".oobe_completed");
+ }
+}
+
+static void CreateOobeCompleteFlagFile() {
+ // Create flag file for boot-time init scripts.
+ base::FilePath oobe_complete_path = GetOobeCompleteFlagPath();
+ if (!file_util::PathExists(oobe_complete_path)) {
+ FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
+ if (oobe_flag_file == NULL)
+ DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist.";
+ else
+ file_util::CloseFile(oobe_flag_file);
+ }
+}
+
+// static
+bool StartupUtils::IsDeviceRegistered() {
+ int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered);
+ if (value > 0) {
+ // Recreate flag file in case it was lost.
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&CreateOobeCompleteFlagFile));
+ return true;
+ } else if (value == 0) {
+ return false;
+ } else {
+ // Pref is not set. For compatibility check flag file. It causes blocking
+ // IO on UI thread. But it's required for update from old versions.
+ base::ThreadRestrictions::ScopedAllowIO allow_io;
+ base::FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath();
+ bool file_exists = file_util::PathExists(oobe_complete_flag_file_path);
+ SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0);
+ return file_exists;
+ }
+}
+
+// static
+void StartupUtils::MarkDeviceRegistered() {
+ SaveIntegerPreferenceForced(kDeviceRegistered, 1);
+ BrowserThread::PostTask(
+ BrowserThread::FILE,
+ FROM_HERE,
+ base::Bind(&CreateOobeCompleteFlagFile));
+}
+
+// static
+std::string StartupUtils::GetInitialLocale() {
+ std::string locale =
+ g_browser_process->local_state()->GetString(kInitialLocale);
+ if (!l10n_util::IsValidLocaleSyntax(locale))
+ locale = "en-US";
+ return locale;
+}
+
+// static
+void StartupUtils::SetInitialLocale(const std::string& locale) {
+ if (l10n_util::IsValidLocaleSyntax(locale))
+ SaveStringPreferenceForced(kInitialLocale, locale);
+ else
+ NOTREACHED();
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/login/startup_utils.h b/chrome/browser/chromeos/login/startup_utils.h
new file mode 100644
index 0000000..f87ce4f
--- /dev/null
+++ b/chrome/browser/chromeos/login/startup_utils.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_STARTUP_UTILS_H_
+#define CHROME_BROWSER_CHROMEOS_LOGIN_STARTUP_UTILS_H_
+
+#include <string>
+
+class PrefRegistrySimple;
+
+namespace chromeos {
+
+// Static utitliy methods used in startup time to get/change bits of device
+// state.
+class StartupUtils {
+ public:
+ // Returns true if EULA has been accepted.
+ static bool IsEulaAccepted();
+
+ // Returns OOBE completion status.
+ static bool IsOobeCompleted();
+
+ // Marks EULA status as accepted.
+ static void MarkEulaAccepted();
+
+ // Marks OOBE process as completed.
+ static void MarkOobeCompleted();
+
+ // Returns device registration completion status, i.e. second part of OOBE.
+ static bool IsDeviceRegistered();
+
+ // Marks device registered. i.e. second part of OOBE is completed.
+ static void MarkDeviceRegistered();
+
+ // Returns initial locale from local settings.
+ static std::string GetInitialLocale();
+
+ // Sets initial locale in local settings.
+ static void SetInitialLocale(const std::string& locale);
+
+ // Registers OOBE preferences.
+ static void RegisterPrefs(PrefRegistrySimple* registry);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_LOGIN_STARTUP_UTILS_H_
diff --git a/chrome/browser/chromeos/login/wallpaper_manager.cc b/chrome/browser/chromeos/login/wallpaper_manager.cc
index 1e8eaf2..e8e60fd 100644
--- a/chrome/browser/chromeos/login/wallpaper_manager.cc
+++ b/chrome/browser/chromeos/login/wallpaper_manager.cc
@@ -22,6 +22,7 @@
#include "base/time.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -265,7 +266,7 @@ void WallpaperManager::InitializeWallpaper() {
}
if (!user_manager->IsUserLoggedIn()) {
- if (!WizardController::IsDeviceRegistered())
+ if (!StartupUtils::IsDeviceRegistered())
SetDefaultWallpaper();
else
InitializeRegisteredDeviceWallpaper();
diff --git a/chrome/browser/chromeos/login/webui_login_display_host.cc b/chrome/browser/chromeos/login/webui_login_display_host.cc
index abb3880..631bc73 100644
--- a/chrome/browser/chromeos/login/webui_login_display_host.cc
+++ b/chrome/browser/chromeos/login/webui_login_display_host.cc
@@ -18,6 +18,7 @@
#include "chrome/browser/browser_shutdown.h"
#include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h"
#include "chrome/browser/chromeos/login/oobe_display.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/webui_login_display.h"
#include "chrome/browser/chromeos/login/webui_login_view.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
@@ -71,7 +72,7 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
crash_count_(0),
restore_path_(RESTORE_UNKNOWN),
old_ignore_solo_window_frame_painter_policy_value_(false) {
- bool is_registered = WizardController::IsDeviceRegistered();
+ bool is_registered = StartupUtils::IsDeviceRegistered();
bool zero_delay_enabled = WizardController::IsZeroDelayEnabled();
bool disable_boot_animation = CommandLine::ForCurrentProcess()->
HasSwitch(switches::kDisableBootAnimation);
@@ -110,7 +111,7 @@ WebUILoginDisplayHost::WebUILoginDisplayHost(const gfx::Rect& background_bounds)
// Always postpone WebUI initialization on first boot, otherwise we miss
// initial animation.
- if (!WizardController::IsOobeCompleted())
+ if (!StartupUtils::IsOobeCompleted())
initialize_webui_hidden_ = false;
// There is no wallpaper for KioskMode, don't initialize the webui hidden.
diff --git a/chrome/browser/chromeos/login/wizard_controller.cc b/chrome/browser/chromeos/login/wizard_controller.cc
index 2d01718..e5c1417 100644
--- a/chrome/browser/chromeos/login/wizard_controller.cc
+++ b/chrome/browser/chromeos/login/wizard_controller.cc
@@ -41,6 +41,7 @@
#include "chrome/browser/chromeos/login/screens/update_screen.h"
#include "chrome/browser/chromeos/login/screens/user_image_screen.h"
#include "chrome/browser/chromeos/login/screens/wrong_hwid_screen.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/net/network_portal_detector.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -175,7 +176,7 @@ void WizardController::Init(const std::string& first_screen_name,
first_screen_name_ = first_screen_name;
screen_parameters_.reset(screen_parameters);
- bool oobe_complete = IsOobeCompleted();
+ bool oobe_complete = StartupUtils::IsOobeCompleted();
if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) {
is_out_of_box_ = true;
}
@@ -185,7 +186,7 @@ void WizardController::Init(const std::string& first_screen_name,
chrome::NOTIFICATION_WIZARD_FIRST_SCREEN_SHOWN,
content::NotificationService::AllSources(),
content::NotificationService::NoDetails());
- if (!IsMachineHWIDCorrect() && !IsDeviceRegistered() &&
+ if (!IsMachineHWIDCorrect() && !StartupUtils::IsDeviceRegistered() &&
first_screen_name.empty())
ShowWrongHWIDScreen();
}
@@ -390,7 +391,7 @@ void WizardController::ShowLocallyManagedUserCreationScreen() {
}
void WizardController::SkipToLoginForTesting() {
- MarkEulaAccepted();
+ StartupUtils::MarkEulaAccepted();
PerformPostEulaActions();
PerformPostUpdateActions();
ShowLoginScreen();
@@ -416,19 +417,11 @@ void WizardController::SkipUpdateEnrollAfterEula() {
skip_update_enroll_after_eula_ = true;
}
-// static
-void WizardController::RegisterPrefs(PrefRegistrySimple* registry) {
- registry->RegisterBooleanPref(kOobeComplete, false);
- registry->RegisterIntegerPref(kDeviceRegistered, -1);
- registry->RegisterBooleanPref(prefs::kEulaAccepted, false);
- registry->RegisterStringPref(kInitialLocale, "en-US");
-}
-
///////////////////////////////////////////////////////////////////////////////
// WizardController, ExitHandlers:
void WizardController::OnNetworkConnected() {
if (is_official_build_) {
- if (!IsEulaAccepted()) {
+ if (!StartupUtils::IsEulaAccepted()) {
ShowEulaScreen();
} else {
// Possible cases:
@@ -459,7 +452,7 @@ void WizardController::OnUpdateCompleted() {
void WizardController::OnEulaAccepted() {
time_eula_accepted_ = base::Time::Now();
- MarkEulaAccepted();
+ StartupUtils::MarkEulaAccepted();
bool uma_enabled =
OptionsUtil::ResolveMetricsReportingEnabled(usage_statistics_reporting_);
@@ -589,7 +582,7 @@ void WizardController::PerformPostEulaActions() {
}
void WizardController::PerformPostUpdateActions() {
- MarkOobeCompleted();
+ StartupUtils::MarkOobeCompleted();
}
void WizardController::SetCurrentScreen(WizardScreen* new_current) {
@@ -677,106 +670,6 @@ void WizardController::AdvanceToScreen(const std::string& screen_name) {
}
}
-// static
-bool WizardController::IsEulaAccepted() {
- return g_browser_process->local_state()->GetBoolean(prefs::kEulaAccepted);
-}
-
-// static
-bool WizardController::IsOobeCompleted() {
- return g_browser_process->local_state()->GetBoolean(kOobeComplete);
-}
-
-// static
-void WizardController::MarkEulaAccepted() {
- SaveBoolPreferenceForced(prefs::kEulaAccepted, true);
-}
-
-// static
-void WizardController::MarkOobeCompleted() {
- SaveBoolPreferenceForced(kOobeComplete, true);
-}
-
-// Returns the path to flag file indicating that both parts of OOBE were
-// completed.
-// On chrome device, returns /home/chronos/.oobe_completed.
-// On Linux desktop, returns $HOME/.oobe_completed.
-static base::FilePath GetOobeCompleteFlagPath() {
- // The constant is defined here so it won't be referenced directly.
- const char kOobeCompleteFlagFilePath[] = "/home/chronos/.oobe_completed";
-
- if (base::chromeos::IsRunningOnChromeOS()) {
- return base::FilePath(kOobeCompleteFlagFilePath);
- } else {
- const char* home = getenv("HOME");
- // Unlikely but if HOME is not defined, use the current directory.
- if (!home)
- home = "";
- return base::FilePath(home).AppendASCII(".oobe_completed");
- }
-}
-
-static void CreateOobeCompleteFlagFile() {
- // Create flag file for boot-time init scripts.
- base::FilePath oobe_complete_path = GetOobeCompleteFlagPath();
- if (!file_util::PathExists(oobe_complete_path)) {
- FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
- if (oobe_flag_file == NULL)
- DLOG(WARNING) << oobe_complete_path.value() << " doesn't exist.";
- else
- file_util::CloseFile(oobe_flag_file);
- }
-}
-
-// static
-bool WizardController::IsDeviceRegistered() {
- int value = g_browser_process->local_state()->GetInteger(kDeviceRegistered);
- if (value > 0) {
- // Recreate flag file in case it was lost.
- BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&CreateOobeCompleteFlagFile));
- return true;
- } else if (value == 0) {
- return false;
- } else {
- // Pref is not set. For compatibility check flag file. It causes blocking
- // IO on UI thread. But it's required for update from old versions.
- base::ThreadRestrictions::ScopedAllowIO allow_io;
- base::FilePath oobe_complete_flag_file_path = GetOobeCompleteFlagPath();
- bool file_exists = file_util::PathExists(oobe_complete_flag_file_path);
- SaveIntegerPreferenceForced(kDeviceRegistered, file_exists ? 1 : 0);
- return file_exists;
- }
-}
-
-// static
-void WizardController::MarkDeviceRegistered() {
- SaveIntegerPreferenceForced(kDeviceRegistered, 1);
- BrowserThread::PostTask(
- BrowserThread::FILE,
- FROM_HERE,
- base::Bind(&CreateOobeCompleteFlagFile));
-}
-
-// static
-std::string WizardController::GetInitialLocale() {
- std::string locale =
- g_browser_process->local_state()->GetString(kInitialLocale);
- if (!l10n_util::IsValidLocaleSyntax(locale))
- locale = "en-US";
- return locale;
-}
-
-// static
-void WizardController::SetInitialLocale(const std::string& locale) {
- if (l10n_util::IsValidLocaleSyntax(locale))
- SaveStringPreferenceForced(kInitialLocale, locale);
- else
- NOTREACHED();
-}
-
///////////////////////////////////////////////////////////////////////////////
// WizardController, chromeos::ScreenObserver overrides:
void WizardController::OnExit(ExitCodes exit_code) {
diff --git a/chrome/browser/chromeos/login/wizard_controller.h b/chrome/browser/chromeos/login/wizard_controller.h
index df0e183..44c126b 100644
--- a/chrome/browser/chromeos/login/wizard_controller.h
+++ b/chrome/browser/chromeos/login/wizard_controller.h
@@ -68,39 +68,12 @@ class WizardController : public ScreenObserver {
return skip_post_login_screens_;
}
- // Returns true if EULA has been accepted.
- static bool IsEulaAccepted();
-
- // Returns OOBE completion status.
- static bool IsOobeCompleted();
-
- // Marks EULA status as accepted.
- static void MarkEulaAccepted();
-
- // Marks OOBE process as completed.
- static void MarkOobeCompleted();
-
- // Returns device registration completion status, i.e. second part of OOBE.
- static bool IsDeviceRegistered();
-
- // Marks device registered. i.e. second part of OOBE is completed.
- static void MarkDeviceRegistered();
-
- // Returns initial locale from local settings.
- static std::string GetInitialLocale();
-
// Sets delays to zero. MUST be used only for tests.
static void SetZeroDelays();
// If true zero delays have been enabled (for browser tests).
static bool IsZeroDelayEnabled();
- // Sets initial locale in local settings.
- static void SetInitialLocale(const std::string& locale);
-
- // Registers OOBE preferences.
- static void RegisterPrefs(PrefRegistrySimple* registry);
-
// Skips any screens that may normally be shown after login (registration,
// Terms of Service, user image selection).
static void SkipPostLoginScreensForTesting();
diff --git a/chrome/browser/chromeos/mobile_config.cc b/chrome/browser/chromeos/mobile_config.cc
index a43e137..78198f6 100644
--- a/chrome/browser/chromeos/mobile_config.cc
+++ b/chrome/browser/chromeos/mobile_config.cc
@@ -14,7 +14,7 @@
#include "base/stl_util.h"
#include "base/values.h"
#include "chrome/browser/browser_process.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "content/public/browser/browser_thread.h"
using content::BrowserThread;
@@ -305,7 +305,7 @@ bool MobileConfig::LoadManifestFromString(const std::string& manifest) {
MobileConfig::MobileConfig()
: CustomizationDocument(kAcceptedConfigVersion),
- initial_locale_(WizardController::GetInitialLocale()) {
+ initial_locale_(StartupUtils::GetInitialLocale()) {
LoadConfig();
}
diff --git a/chrome/browser/chromeos/options/wimax_config_view.cc b/chrome/browser/chromeos/options/wimax_config_view.cc
index 5b33516..5705583 100644
--- a/chrome/browser/chromeos/options/wimax_config_view.cc
+++ b/chrome/browser/chromeos/options/wimax_config_view.cc
@@ -10,7 +10,7 @@
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/chromeos/enrollment_dialog_view.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chromeos/login/login_state.h"
#include "chromeos/network/onc/onc_constants.h"
@@ -59,7 +59,7 @@ views::View* WimaxConfigView::GetInitiallyFocusedView() {
bool WimaxConfigView::CanLogin() {
// In OOBE it may be valid to log in with no credentials (crbug.com/137776).
- if (!chromeos::WizardController::IsOobeCompleted())
+ if (!chromeos::StartupUtils::IsOobeCompleted())
return true;
// TODO(benchan): Update this with the correct minimum length (don't just
diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
index a7a66361..b869cb1 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -58,9 +58,9 @@
#include "chrome/browser/chromeos/login/login_display_host.h"
#include "chrome/browser/chromeos/login/login_display_host_impl.h"
#include "chrome/browser/chromeos/login/login_wizard.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user.h"
#include "chrome/browser/chromeos/login/user_manager.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/mobile_config.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/status/data_promo_notification.h"
@@ -417,7 +417,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
virtual bool IsOobeCompleted() const OVERRIDE {
- return WizardController::IsOobeCompleted();
+ return StartupUtils::IsOobeCompleted();
}
virtual void GetLoggedInUsers(ash::UserEmailList* users) OVERRIDE {
diff --git a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
index b4ba5c4..fd68b4f 100644
--- a/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
+++ b/chrome/browser/chromeos/system/tray_accessibility_browsertest.cc
@@ -16,9 +16,9 @@
#include "chrome/browser/chromeos/cros/cros_in_process_browser_test.h"
#include "chrome/browser/chromeos/login/helper.h"
#include "chrome/browser/chromeos/login/login_utils.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/user_manager_impl.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/common/chrome_notification_types.h"
@@ -49,7 +49,7 @@ class TrayAccessibilityTest : public CrosInProcessBrowserTest {
virtual void RunTestOnMainThreadLoop() OVERRIDE {
// Need to mark oobe completed to show detailed views.
- WizardController::MarkOobeCompleted();
+ StartupUtils::MarkOobeCompleted();
CrosInProcessBrowserTest::RunTestOnMainThreadLoop();
}
diff --git a/chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc b/chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc
index acc16b9..12bbddf 100644
--- a/chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc
+++ b/chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.cc
@@ -4,7 +4,8 @@
#include "chrome/browser/metrics/variations/eula_accepted_notifier_chromeos.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
+#include "base/logging.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/common/chrome_notification_types.h"
#include "content/public/browser/notification_service.h"
@@ -15,7 +16,7 @@ EulaAcceptedNotifierChromeos::~EulaAcceptedNotifierChromeos() {
}
bool EulaAcceptedNotifierChromeos::IsEulaAccepted() {
- if (chromeos::WizardController::IsEulaAccepted())
+ if (chromeos::StartupUtils::IsEulaAccepted())
return true;
// Register for the notification, if this is the first time.
diff --git a/chrome/browser/prefs/browser_prefs.cc b/chrome/browser/prefs/browser_prefs.cc
index 47a67b7..37fdcef 100644
--- a/chrome/browser/prefs/browser_prefs.cc
+++ b/chrome/browser/prefs/browser_prefs.cc
@@ -121,10 +121,10 @@
#include "chrome/browser/chromeos/display/display_preferences.h"
#include "chrome/browser/chromeos/login/login_utils.h"
#include "chrome/browser/chromeos/login/oauth2_login_manager.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_image_manager.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wallpaper_manager.h"
-#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/policy/auto_enrollment_client.h"
#include "chrome/browser/chromeos/policy/device_cloud_policy_manager_chromeos.h"
#include "chrome/browser/chromeos/policy/device_status_collector.h"
@@ -255,7 +255,7 @@ void RegisterLocalState(PrefRegistrySimple* registry) {
chromeos::UserImageManager::RegisterPrefs(registry);
chromeos::UserManager::RegisterPrefs(registry);
chromeos::WallpaperManager::RegisterPrefs(registry);
- chromeos::WizardController::RegisterPrefs(registry);
+ chromeos::StartupUtils::RegisterPrefs(registry);
policy::AutoEnrollmentClient::RegisterPrefs(registry);
policy::DeviceStatusCollector::RegisterPrefs(registry);
#endif
diff --git a/chrome/browser/ui/webui/help/version_updater_chromeos.cc b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
index ddce999..e2b843a 100644
--- a/chrome/browser/ui/webui/help/version_updater_chromeos.cc
+++ b/chrome/browser/ui/webui/help/version_updater_chromeos.cc
@@ -8,6 +8,7 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
+#include "chrome/browser/chromeos/login/startup_utils.h"
#include "chrome/browser/chromeos/login/user_manager.h"
#include "chrome/browser/chromeos/login/wizard_controller.h"
#include "chrome/browser/chromeos/settings/cros_settings.h"
@@ -36,7 +37,7 @@ void VersionUpdaterCros::CheckForUpdate(const StatusCallback& callback) {
// Make sure that libcros is loaded and OOBE is complete.
if (!WizardController::default_controller() ||
- WizardController::IsDeviceRegistered()) {
+ chromeos::StartupUtils::IsDeviceRegistered()) {
update_engine_client->RequestUpdateCheck(
base::Bind(&VersionUpdaterCros::OnUpdateCheck,
weak_ptr_factory_.GetWeakPtr()));
diff --git a/chrome/chrome_browser_chromeos.gypi b/chrome/chrome_browser_chromeos.gypi
index a4f2dd3..1aef388 100644
--- a/chrome/chrome_browser_chromeos.gypi
+++ b/chrome/chrome_browser_chromeos.gypi
@@ -444,7 +444,6 @@
'browser/chromeos/login/oobe_display.h',
'browser/chromeos/login/parallel_authenticator.cc',
'browser/chromeos/login/parallel_authenticator.h',
- 'browser/chromeos/login/user_flow.h',
'browser/chromeos/login/profile_auth_data.cc',
'browser/chromeos/login/profile_auth_data.h',
'browser/chromeos/login/proxy_settings_dialog.cc',
@@ -468,15 +467,9 @@
'browser/chromeos/login/screens/reset_screen.h',
'browser/chromeos/login/screens/reset_screen_actor.h',
'browser/chromeos/login/screens/screen_observer.h',
- 'browser/chromeos/login/simple_web_view_dialog.cc',
- 'browser/chromeos/login/simple_web_view_dialog.h',
'browser/chromeos/login/screens/terms_of_service_screen.cc',
'browser/chromeos/login/screens/terms_of_service_screen.h',
'browser/chromeos/login/screens/terms_of_service_screen_actor.h',
- 'browser/chromeos/login/test_attempt_state.cc',
- 'browser/chromeos/login/test_attempt_state.h',
- 'browser/chromeos/login/tpm_password_fetcher.cc',
- 'browser/chromeos/login/tpm_password_fetcher.h',
'browser/chromeos/login/screens/update_screen.cc',
'browser/chromeos/login/screens/update_screen.h',
'browser/chromeos/login/screens/update_screen_actor.h',
@@ -488,6 +481,14 @@
'browser/chromeos/login/screens/wrong_hwid_screen.cc',
'browser/chromeos/login/screens/wrong_hwid_screen.h',
'browser/chromeos/login/screens/wrong_hwid_screen_actor.h',
+ 'browser/chromeos/login/simple_web_view_dialog.cc',
+ 'browser/chromeos/login/simple_web_view_dialog.h',
+ 'browser/chromeos/login/startup_utils.cc',
+ 'browser/chromeos/login/startup_utils.h',
+ 'browser/chromeos/login/test_attempt_state.cc',
+ 'browser/chromeos/login/test_attempt_state.h',
+ 'browser/chromeos/login/tpm_password_fetcher.cc',
+ 'browser/chromeos/login/tpm_password_fetcher.h',
'browser/chromeos/login/user.cc',
'browser/chromeos/login/user.h',
'browser/chromeos/login/user_image.cc',