| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/wizard_controller.h" | 5 #include "chrome/browser/chromeos/login/wizard_controller.h" |
| 6 | 6 |
| 7 #include <gdk/gdk.h> | 7 #include <gdk/gdk.h> |
| 8 #include <signal.h> | 8 #include <signal.h> |
| 9 #include <sys/types.h> | 9 #include <sys/types.h> |
| 10 | 10 |
| 11 #include <string> | 11 #include <string> |
| 12 #include <vector> | 12 #include <vector> |
| 13 | 13 |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/file_util.h" | 15 #include "base/file_util.h" |
| 16 #include "base/logging.h" | 16 #include "base/logging.h" |
| 17 #include "base/threading/thread_restrictions.h" | 17 #include "base/threading/thread_restrictions.h" |
| 18 #include "chrome/browser/browser_process.h" | 18 #include "chrome/browser/browser_process.h" |
| 19 #include "chrome/browser/chromeos/cros/cros_library.h" | 19 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 20 #include "chrome/browser/chromeos/cros/cryptohome_library.h" | 20 #include "chrome/browser/chromeos/cros/cryptohome_library.h" |
| 21 #include "chrome/browser/chromeos/customization_document.h" | 21 #include "chrome/browser/chromeos/customization_document.h" |
| 22 #include "chrome/browser/chromeos/language_preferences.h" | 22 #include "chrome/browser/chromeos/language_preferences.h" |
| 23 #include "chrome/browser/chromeos/login/account_screen.h" | 23 #include "chrome/browser/chromeos/login/account_screen.h" |
| 24 #include "chrome/browser/chromeos/login/apply_services_customization.h" | |
| 25 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" | 24 #include "chrome/browser/chromeos/login/enterprise_enrollment_screen.h" |
| 26 #include "chrome/browser/chromeos/login/eula_view.h" | 25 #include "chrome/browser/chromeos/login/eula_view.h" |
| 27 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 26 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
| 28 #include "chrome/browser/chromeos/login/helper.h" | 27 #include "chrome/browser/chromeos/login/helper.h" |
| 29 #include "chrome/browser/chromeos/login/html_page_screen.h" | 28 #include "chrome/browser/chromeos/login/html_page_screen.h" |
| 30 #include "chrome/browser/chromeos/login/login_display_host.h" | 29 #include "chrome/browser/chromeos/login/login_display_host.h" |
| 31 #include "chrome/browser/chromeos/login/login_utils.h" | 30 #include "chrome/browser/chromeos/login/login_utils.h" |
| 32 #include "chrome/browser/chromeos/login/network_screen.h" | 31 #include "chrome/browser/chromeos/login/network_screen.h" |
| 33 #include "chrome/browser/chromeos/login/registration_screen.h" | 32 #include "chrome/browser/chromeos/login/registration_screen.h" |
| 34 #include "chrome/browser/chromeos/login/update_screen.h" | 33 #include "chrome/browser/chromeos/login/update_screen.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 views::Accelerator accel_eula_screen_; | 170 views::Accelerator accel_eula_screen_; |
| 172 views::Accelerator accel_register_screen_; | 171 views::Accelerator accel_register_screen_; |
| 173 views::Accelerator accel_enterprise_enrollment_screen_; | 172 views::Accelerator accel_enterprise_enrollment_screen_; |
| 174 #endif | 173 #endif |
| 175 views::Accelerator accel_toggle_accessibility_; | 174 views::Accelerator accel_toggle_accessibility_; |
| 176 views::Accelerator accel_cancel_update_; | 175 views::Accelerator accel_cancel_update_; |
| 177 | 176 |
| 178 DISALLOW_COPY_AND_ASSIGN(ContentView); | 177 DISALLOW_COPY_AND_ASSIGN(ContentView); |
| 179 }; | 178 }; |
| 180 | 179 |
| 181 // Returns true if startup manifest defines valid registration URL. | |
| 182 bool IsRegistrationScreenValid( | |
| 183 const chromeos::StartupCustomizationDocument* startup_manifest) { | |
| 184 return startup_manifest != NULL && | |
| 185 GURL(startup_manifest->registration_url()).is_valid(); | |
| 186 } | |
| 187 | |
| 188 // Saves boolean "Local State" preference and forces its persistence to disk. | 180 // Saves boolean "Local State" preference and forces its persistence to disk. |
| 189 void SaveBoolPreferenceForced(const char* pref_name, bool value) { | 181 void SaveBoolPreferenceForced(const char* pref_name, bool value) { |
| 190 PrefService* prefs = g_browser_process->local_state(); | 182 PrefService* prefs = g_browser_process->local_state(); |
| 191 prefs->SetBoolean(pref_name, value); | 183 prefs->SetBoolean(pref_name, value); |
| 192 prefs->SavePersistentPrefs(); | 184 prefs->SavePersistentPrefs(); |
| 193 } | 185 } |
| 194 | 186 |
| 195 // Saves integer "Local State" preference and forces its persistence to disk. | 187 // Saves integer "Local State" preference and forces its persistence to disk. |
| 196 void SaveIntegerPreferenceForced(const char* pref_name, int value) { | 188 void SaveIntegerPreferenceForced(const char* pref_name, int value) { |
| 197 PrefService* prefs = g_browser_process->local_state(); | 189 PrefService* prefs = g_browser_process->local_state(); |
| (...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 | 259 |
| 268 chromeos::WizardAccessibilityHelper::GetInstance()-> | 260 chromeos::WizardAccessibilityHelper::GetInstance()-> |
| 269 UnregisterNotifications(); | 261 UnregisterNotifications(); |
| 270 } | 262 } |
| 271 | 263 |
| 272 void WizardController::Init(const std::string& first_screen_name) { | 264 void WizardController::Init(const std::string& first_screen_name) { |
| 273 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name; | 265 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name; |
| 274 DCHECK(!contents_); | 266 DCHECK(!contents_); |
| 275 first_screen_name_ = first_screen_name; | 267 first_screen_name_ = first_screen_name; |
| 276 | 268 |
| 277 // When device is not registered yet we need to load startup manifest as well. | |
| 278 // In case of OOBE (network-EULA-update) manifest has been loaded in | |
| 279 // ShowLoginWizard(). | |
| 280 if (IsOobeCompleted() && !IsDeviceRegistered()) | |
| 281 SetCustomization(chromeos::LoadStartupManifest()); | |
| 282 | |
| 283 contents_ = new ContentView(); | 269 contents_ = new ContentView(); |
| 284 | 270 |
| 285 bool oobe_complete = IsOobeCompleted(); | 271 bool oobe_complete = IsOobeCompleted(); |
| 286 if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) { | 272 if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) { |
| 287 is_out_of_box_ = true; | 273 is_out_of_box_ = true; |
| 288 } | 274 } |
| 289 | 275 |
| 290 ShowFirstScreen(first_screen_name); | 276 ShowFirstScreen(first_screen_name); |
| 291 } | 277 } |
| 292 | 278 |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 408 void WizardController::ShowEulaScreen() { | 394 void WizardController::ShowEulaScreen() { |
| 409 VLOG(1) << "Showing EULA screen."; | 395 VLOG(1) << "Showing EULA screen."; |
| 410 SetStatusAreaVisible(false); | 396 SetStatusAreaVisible(false); |
| 411 SetCurrentScreen(GetEulaScreen()); | 397 SetCurrentScreen(GetEulaScreen()); |
| 412 #if defined(OFFICIAL_BUILD) | 398 #if defined(OFFICIAL_BUILD) |
| 413 host_->SetOobeProgress(chromeos::BackgroundView::EULA); | 399 host_->SetOobeProgress(chromeos::BackgroundView::EULA); |
| 414 #endif | 400 #endif |
| 415 } | 401 } |
| 416 | 402 |
| 417 void WizardController::ShowRegistrationScreen() { | 403 void WizardController::ShowRegistrationScreen() { |
| 418 if (!IsRegistrationScreenValid(GetCustomization())) { | 404 if (!IsRegisterScreenDefined()) { |
| 419 VLOG(1) << "Skipping registration screen: manifest not defined or invalid " | 405 VLOG(1) << "Skipping registration screen: manifest not defined or invalid " |
| 420 "URL."; | 406 "URL."; |
| 421 OnRegistrationSkipped(); | 407 OnRegistrationSkipped(); |
| 422 return; | 408 return; |
| 423 } | 409 } |
| 424 VLOG(1) << "Showing registration screen."; | 410 VLOG(1) << "Showing registration screen."; |
| 425 SetStatusAreaVisible(true); | 411 SetStatusAreaVisible(true); |
| 426 SetCurrentScreen(GetRegistrationScreen()); | 412 SetCurrentScreen(GetRegistrationScreen()); |
| 427 #if defined(OFFICIAL_BUILD) | 413 #if defined(OFFICIAL_BUILD) |
| 428 host_->SetOobeProgress(chromeos::BackgroundView::REGISTRATION); | 414 host_->SetOobeProgress(chromeos::BackgroundView::REGISTRATION); |
| 429 #endif | 415 #endif |
| 430 } | 416 } |
| 431 | 417 |
| 432 void WizardController::ShowHTMLPageScreen() { | 418 void WizardController::ShowHTMLPageScreen() { |
| 433 VLOG(1) << "Showing HTML page screen."; | 419 VLOG(1) << "Showing HTML page screen."; |
| 434 SetStatusAreaVisible(true); | 420 SetStatusAreaVisible(true); |
| 435 host_->SetOobeProgressBarVisible(false); | 421 host_->SetOobeProgressBarVisible(false); |
| 436 SetCurrentScreen(GetHTMLPageScreen()); | 422 SetCurrentScreen(GetHTMLPageScreen()); |
| 437 } | 423 } |
| 438 | 424 |
| 439 void WizardController::ShowEnterpriseEnrollmentScreen() { | 425 void WizardController::ShowEnterpriseEnrollmentScreen() { |
| 440 SetStatusAreaVisible(true); | 426 SetStatusAreaVisible(true); |
| 441 host_->SetOobeProgress(chromeos::BackgroundView::SIGNIN); | 427 host_->SetOobeProgress(chromeos::BackgroundView::SIGNIN); |
| 442 SetCurrentScreen(GetEnterpriseEnrollmentScreen()); | 428 SetCurrentScreen(GetEnterpriseEnrollmentScreen()); |
| 443 } | 429 } |
| 444 | 430 |
| 445 void WizardController::SetCustomization( | |
| 446 const chromeos::StartupCustomizationDocument* customization) { | |
| 447 customization_.reset(customization); | |
| 448 } | |
| 449 | |
| 450 const chromeos::StartupCustomizationDocument* | |
| 451 WizardController::GetCustomization() const { | |
| 452 return customization_.get(); | |
| 453 } | |
| 454 | |
| 455 void WizardController::SkipRegistration() { | 431 void WizardController::SkipRegistration() { |
| 456 if (current_screen_ == GetRegistrationScreen()) | 432 if (current_screen_ == GetRegistrationScreen()) |
| 457 OnRegistrationSkipped(); | 433 OnRegistrationSkipped(); |
| 458 else | 434 else |
| 459 LOG(ERROR) << "Registration screen is not active."; | 435 LOG(ERROR) << "Registration screen is not active."; |
| 460 } | 436 } |
| 461 | 437 |
| 462 // static | 438 // static |
| 463 void WizardController::RegisterPrefs(PrefService* local_state) { | 439 void WizardController::RegisterPrefs(PrefService* local_state) { |
| 464 local_state->RegisterBooleanPref(kOobeComplete, false); | 440 local_state->RegisterBooleanPref(kOobeComplete, false); |
| (...skipping 341 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 806 // static | 782 // static |
| 807 void WizardController::SetInitialLocale(const std::string& locale) { | 783 void WizardController::SetInitialLocale(const std::string& locale) { |
| 808 if (l10n_util::IsValidLocaleSyntax(locale)) | 784 if (l10n_util::IsValidLocaleSyntax(locale)) |
| 809 SaveStringPreferenceForced(kInitialLocale, locale); | 785 SaveStringPreferenceForced(kInitialLocale, locale); |
| 810 else | 786 else |
| 811 NOTREACHED(); | 787 NOTREACHED(); |
| 812 } | 788 } |
| 813 | 789 |
| 814 // static | 790 // static |
| 815 bool WizardController::IsRegisterScreenDefined() { | 791 bool WizardController::IsRegisterScreenDefined() { |
| 816 const chromeos::StartupCustomizationDocument* manifest = NULL; | 792 const chromeos::StartupCustomizationDocument* manifest = |
| 817 // This method will be called from ExistingUserController too | 793 chromeos::StartupCustomizationDocument::GetInstance(); |
| 818 // when Wizard instance doesn't exist. | 794 return manifest->IsReady() && |
| 819 if (default_controller()) | 795 GURL(manifest->registration_url()).is_valid(); |
| 820 manifest = default_controller()->GetCustomization(); | |
| 821 else | |
| 822 manifest = chromeos::LoadStartupManifest(); | |
| 823 return IsRegistrationScreenValid(manifest); | |
| 824 } | 796 } |
| 825 | 797 |
| 826 /////////////////////////////////////////////////////////////////////////////// | 798 /////////////////////////////////////////////////////////////////////////////// |
| 827 // WizardController, chromeos::ScreenObserver overrides: | 799 // WizardController, chromeos::ScreenObserver overrides: |
| 828 void WizardController::OnExit(ExitCodes exit_code) { | 800 void WizardController::OnExit(ExitCodes exit_code) { |
| 829 LOG(INFO) << "Wizard screen exit code: " << exit_code; | 801 LOG(INFO) << "Wizard screen exit code: " << exit_code; |
| 830 switch (exit_code) { | 802 switch (exit_code) { |
| 831 case NETWORK_CONNECTED: | 803 case NETWORK_CONNECTED: |
| 832 OnNetworkConnected(); | 804 OnNetworkConnected(); |
| 833 break; | 805 break; |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 892 return contents_; | 864 return contents_; |
| 893 } | 865 } |
| 894 | 866 |
| 895 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { | 867 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { |
| 896 return observer_ ? observer_ : this; | 868 return observer_ ? observer_ : this; |
| 897 } | 869 } |
| 898 | 870 |
| 899 void WizardController::SetZeroDelays() { | 871 void WizardController::SetZeroDelays() { |
| 900 kShowDelayMs = 0; | 872 kShowDelayMs = 0; |
| 901 } | 873 } |
| OLD | NEW |