OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
182 | 182 |
183 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { | 183 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { |
184 // Load partner customization startup manifest if it is available. | 184 // Load partner customization startup manifest if it is available. |
185 FilePath startup_manifest_path(kStartupCustomizationManifestPath); | 185 FilePath startup_manifest_path(kStartupCustomizationManifestPath); |
186 if (file_util::PathExists(startup_manifest_path)) { | 186 if (file_util::PathExists(startup_manifest_path)) { |
187 scoped_ptr<chromeos::StartupCustomizationDocument> customization( | 187 scoped_ptr<chromeos::StartupCustomizationDocument> customization( |
188 new chromeos::StartupCustomizationDocument()); | 188 new chromeos::StartupCustomizationDocument()); |
189 bool manifest_loaded = customization->LoadManifestFromFile( | 189 bool manifest_loaded = customization->LoadManifestFromFile( |
190 startup_manifest_path); | 190 startup_manifest_path); |
191 if (manifest_loaded) { | 191 if (manifest_loaded) { |
192 LOG(INFO) << "Startup manifest loaded successfully"; | 192 VLOG(1) << "Startup manifest loaded successfully"; |
193 return customization.release(); | 193 return customization.release(); |
194 } else { | |
195 LOG(ERROR) << "Error loading startup manifest. " << | |
196 kStartupCustomizationManifestPath; | |
197 } | 194 } |
| 195 LOG(ERROR) << "Error loading startup manifest: " |
| 196 << kStartupCustomizationManifestPath; |
198 } | 197 } |
199 | 198 |
200 return NULL; | 199 return NULL; |
201 } | 200 } |
202 | 201 |
203 // Returns true if startup manifest defines valid registration URL. | 202 // Returns true if startup manifest defines valid registration URL. |
204 bool IsRegistrationScreenValid( | 203 bool IsRegistrationScreenValid( |
205 const chromeos::StartupCustomizationDocument* startup_manifest) { | 204 const chromeos::StartupCustomizationDocument* startup_manifest) { |
206 return startup_manifest != NULL && | 205 return startup_manifest != NULL && |
207 GURL(startup_manifest->registration_url()).is_valid(); | 206 GURL(startup_manifest->registration_url()).is_valid(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 if (widget_) | 256 if (widget_) |
258 widget_->Close(); | 257 widget_->Close(); |
259 | 258 |
260 default_controller_ = NULL; | 259 default_controller_ = NULL; |
261 chromeos::WizardAccessibilityHelper::GetInstance()-> | 260 chromeos::WizardAccessibilityHelper::GetInstance()-> |
262 UnregisterNotifications(); | 261 UnregisterNotifications(); |
263 } | 262 } |
264 | 263 |
265 void WizardController::Init(const std::string& first_screen_name, | 264 void WizardController::Init(const std::string& first_screen_name, |
266 const gfx::Rect& screen_bounds) { | 265 const gfx::Rect& screen_bounds) { |
267 LOG(INFO) << "Starting OOBE wizard with screen: " << first_screen_name; | 266 VLOG(1) << "Starting OOBE wizard with screen: " << first_screen_name; |
268 DCHECK(!contents_); | 267 DCHECK(!contents_); |
269 first_screen_name_ = first_screen_name; | 268 first_screen_name_ = first_screen_name; |
270 | 269 |
271 // When device is not registered yet we need to load startup manifest as well. | 270 // When device is not registered yet we need to load startup manifest as well. |
272 // In case of OOBE (network-EULA-update) manifest has been loaded in | 271 // In case of OOBE (network-EULA-update) manifest has been loaded in |
273 // ShowLoginWizard(). | 272 // ShowLoginWizard(). |
274 if (IsOobeCompleted() && !IsDeviceRegistered()) | 273 if (IsOobeCompleted() && !IsDeviceRegistered()) |
275 SetCustomization(LoadStartupManifest()); | 274 SetCustomization(LoadStartupManifest()); |
276 | 275 |
277 screen_bounds_ = screen_bounds; | 276 screen_bounds_ = screen_bounds; |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
408 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 407 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
409 | 408 |
410 return controller; | 409 return controller; |
411 } | 410 } |
412 | 411 |
413 SetCurrentScreen(GetLoginScreen()); | 412 SetCurrentScreen(GetLoginScreen()); |
414 return NULL; | 413 return NULL; |
415 } | 414 } |
416 | 415 |
417 void WizardController::ShowAccountScreen() { | 416 void WizardController::ShowAccountScreen() { |
418 LOG(INFO) << "Showing create account screen."; | 417 VLOG(1) << "Showing create account screen."; |
419 SetStatusAreaVisible(true); | 418 SetStatusAreaVisible(true); |
420 SetCurrentScreen(GetAccountScreen()); | 419 SetCurrentScreen(GetAccountScreen()); |
421 } | 420 } |
422 | 421 |
423 void WizardController::ShowUpdateScreen() { | 422 void WizardController::ShowUpdateScreen() { |
424 LOG(INFO) << "Showing update screen."; | 423 VLOG(1) << "Showing update screen."; |
425 SetStatusAreaVisible(true); | 424 SetStatusAreaVisible(true); |
426 SetCurrentScreen(GetUpdateScreen()); | 425 SetCurrentScreen(GetUpdateScreen()); |
427 // There is no special step for update. | 426 // There is no special step for update. |
428 #if defined(OFFICIAL_BUILD) | 427 #if defined(OFFICIAL_BUILD) |
429 background_view_->SetOobeProgress(chromeos::BackgroundView::EULA); | 428 background_view_->SetOobeProgress(chromeos::BackgroundView::EULA); |
430 #else | 429 #else |
431 background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); | 430 background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); |
432 #endif | 431 #endif |
433 } | 432 } |
434 | 433 |
435 void WizardController::ShowUserImageScreen() { | 434 void WizardController::ShowUserImageScreen() { |
436 LOG(INFO) << "Showing user image screen."; | 435 VLOG(1) << "Showing user image screen."; |
437 SetStatusAreaVisible(false); | 436 SetStatusAreaVisible(false); |
438 SetCurrentScreen(GetUserImageScreen()); | 437 SetCurrentScreen(GetUserImageScreen()); |
439 background_view_->SetOobeProgress(chromeos::BackgroundView::PICTURE); | 438 background_view_->SetOobeProgress(chromeos::BackgroundView::PICTURE); |
440 } | 439 } |
441 | 440 |
442 void WizardController::ShowEulaScreen() { | 441 void WizardController::ShowEulaScreen() { |
443 LOG(INFO) << "Showing EULA screen."; | 442 VLOG(1) << "Showing EULA screen."; |
444 SetStatusAreaVisible(false); | 443 SetStatusAreaVisible(false); |
445 SetCurrentScreen(GetEulaScreen()); | 444 SetCurrentScreen(GetEulaScreen()); |
446 #if defined(OFFICIAL_BUILD) | 445 #if defined(OFFICIAL_BUILD) |
447 background_view_->SetOobeProgress(chromeos::BackgroundView::EULA); | 446 background_view_->SetOobeProgress(chromeos::BackgroundView::EULA); |
448 #endif | 447 #endif |
449 } | 448 } |
450 | 449 |
451 void WizardController::ShowRegistrationScreen() { | 450 void WizardController::ShowRegistrationScreen() { |
452 if (!IsRegistrationScreenValid(GetCustomization())) { | 451 if (!IsRegistrationScreenValid(GetCustomization())) { |
453 LOG(INFO) << | 452 VLOG(1) << "Skipping registration screen: manifest not defined or invalid " |
454 "Skipping registration screen: manifest not defined or invalid URL."; | 453 "URL."; |
455 OnRegistrationSkipped(); | 454 OnRegistrationSkipped(); |
456 return; | 455 return; |
457 } | 456 } |
458 LOG(INFO) << "Showing registration screen."; | 457 VLOG(1) << "Showing registration screen."; |
459 SetStatusAreaVisible(true); | 458 SetStatusAreaVisible(true); |
460 SetCurrentScreen(GetRegistrationScreen()); | 459 SetCurrentScreen(GetRegistrationScreen()); |
461 #if defined(OFFICIAL_BUILD) | 460 #if defined(OFFICIAL_BUILD) |
462 background_view_->SetOobeProgress(chromeos::BackgroundView::REGISTRATION); | 461 background_view_->SetOobeProgress(chromeos::BackgroundView::REGISTRATION); |
463 #endif | 462 #endif |
464 } | 463 } |
465 | 464 |
466 void WizardController::ShowHTMLPageScreen() { | 465 void WizardController::ShowHTMLPageScreen() { |
467 LOG(INFO) << "Showing HTML page screen."; | 466 VLOG(1) << "Showing HTML page screen."; |
468 SetStatusAreaVisible(true); | 467 SetStatusAreaVisible(true); |
469 background_view_->SetOobeProgressBarVisible(false); | 468 background_view_->SetOobeProgressBarVisible(false); |
470 SetCurrentScreen(GetHTMLPageScreen()); | 469 SetCurrentScreen(GetHTMLPageScreen()); |
471 } | 470 } |
472 | 471 |
473 void WizardController::SetCustomization( | 472 void WizardController::SetCustomization( |
474 const chromeos::StartupCustomizationDocument* customization) { | 473 const chromeos::StartupCustomizationDocument* customization) { |
475 customization_.reset(customization); | 474 customization_.reset(customization); |
476 } | 475 } |
477 | 476 |
(...skipping 307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
785 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); | 784 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); |
786 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); | 785 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); |
787 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; | 786 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; |
788 if (oobe_flag_file != NULL) | 787 if (oobe_flag_file != NULL) |
789 file_util::CloseFile(oobe_flag_file); | 788 file_util::CloseFile(oobe_flag_file); |
790 } | 789 } |
791 | 790 |
792 /////////////////////////////////////////////////////////////////////////////// | 791 /////////////////////////////////////////////////////////////////////////////// |
793 // WizardController, chromeos::ScreenObserver overrides: | 792 // WizardController, chromeos::ScreenObserver overrides: |
794 void WizardController::OnExit(ExitCodes exit_code) { | 793 void WizardController::OnExit(ExitCodes exit_code) { |
795 LOG(INFO) << "Wizard screen exit code: " << exit_code; | 794 VLOG(1) << "Wizard screen exit code: " << exit_code; |
796 switch (exit_code) { | 795 switch (exit_code) { |
797 case LOGIN_SIGN_IN_SELECTED: | 796 case LOGIN_SIGN_IN_SELECTED: |
798 OnLoginSignInSelected(); | 797 OnLoginSignInSelected(); |
799 break; | 798 break; |
800 case LOGIN_GUEST_SELECTED: | 799 case LOGIN_GUEST_SELECTED: |
801 OnLoginGuestUser(); | 800 OnLoginGuestUser(); |
802 break; | 801 break; |
803 case LOGIN_CREATE_ACCOUNT: | 802 case LOGIN_CREATE_ACCOUNT: |
804 OnLoginCreateAccount(); | 803 OnLoginCreateAccount(); |
805 break; | 804 break; |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
865 | 864 |
866 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { | 865 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { |
867 return observer_ ? observer_ : this; | 866 return observer_ ? observer_ : this; |
868 } | 867 } |
869 | 868 |
870 namespace browser { | 869 namespace browser { |
871 | 870 |
872 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 871 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
873 void ShowLoginWizard(const std::string& first_screen_name, | 872 void ShowLoginWizard(const std::string& first_screen_name, |
874 const gfx::Size& size) { | 873 const gfx::Size& size) { |
875 LOG(INFO) << "showing login screen: " << first_screen_name; | 874 VLOG(1) << "Showing login screen: " << first_screen_name; |
876 | 875 |
877 // The login screen will enable alternate keyboard layouts, but we don't want | 876 // The login screen will enable alternate keyboard layouts, but we don't want |
878 // to start the IME process unless one is selected. | 877 // to start the IME process unless one is selected. |
879 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> | 878 chromeos::CrosLibrary::Get()->GetInputMethodLibrary()-> |
880 SetDeferImeStartup(true); | 879 SetDeferImeStartup(true); |
881 // Tell the window manager that the user isn't logged in. | 880 // Tell the window manager that the user isn't logged in. |
882 chromeos::WmIpc::instance()->SetLoggedInProperty(false); | 881 chromeos::WmIpc::instance()->SetLoggedInProperty(false); |
883 | 882 |
884 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty | 883 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty |
885 // and US dvorak keyboard layouts. | 884 // and US dvorak keyboard layouts. |
(...skipping 17 matching lines...) Expand all Loading... |
903 chromeos::CrosLibrary::Get()->EnsureLoaded() && | 902 chromeos::CrosLibrary::Get()->EnsureLoaded() && |
904 CommandLine::ForCurrentProcess()->HasSwitch( | 903 CommandLine::ForCurrentProcess()->HasSwitch( |
905 switches::kEnableLoginImages)) { | 904 switches::kEnableLoginImages)) { |
906 std::vector<chromeos::UserManager::User> users = | 905 std::vector<chromeos::UserManager::User> users = |
907 chromeos::UserManager::Get()->GetUsers(); | 906 chromeos::UserManager::Get()->GetUsers(); |
908 | 907 |
909 // Fix for users who updated device and thus never passed register screen. | 908 // Fix for users who updated device and thus never passed register screen. |
910 // If we already have user we assume that it is not a second part of OOBE. | 909 // If we already have user we assume that it is not a second part of OOBE. |
911 // See http://crosbug.com/6289 | 910 // See http://crosbug.com/6289 |
912 if (!WizardController::IsDeviceRegistered() && !users.empty()) { | 911 if (!WizardController::IsDeviceRegistered() && !users.empty()) { |
913 LOG(INFO) << "Mark device registered because there are remembered users: " | 912 VLOG(1) << "Mark device registered because there are remembered users: " |
914 << users.size(); | 913 << users.size(); |
915 WizardController::MarkDeviceRegistered(); | 914 WizardController::MarkDeviceRegistered(); |
916 } | 915 } |
917 | 916 |
918 // ExistingUserController deletes itself. | 917 // ExistingUserController deletes itself. |
919 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); | 918 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); |
920 | 919 |
921 // Initiate services customization. | 920 // Initiate services customization. |
922 chromeos::ApplyServicesCustomization::StartIfNeeded(); | 921 chromeos::ApplyServicesCustomization::StartIfNeeded(); |
923 | 922 |
924 return; | 923 return; |
925 } | 924 } |
926 | 925 |
927 // Create and show the wizard. | 926 // Create and show the wizard. |
928 WizardController* controller = new WizardController(); | 927 WizardController* controller = new WizardController(); |
929 | 928 |
930 // Load startup manifest. | 929 // Load startup manifest. |
931 controller->SetCustomization(LoadStartupManifest()); | 930 controller->SetCustomization(LoadStartupManifest()); |
932 | 931 |
933 std::string locale; | 932 std::string locale; |
934 if (controller->GetCustomization()) { | 933 if (controller->GetCustomization()) { |
935 // Switch to initial locale if specified by customization | 934 // Switch to initial locale if specified by customization |
936 // and has not been set yet. We cannot call | 935 // and has not been set yet. We cannot call |
937 // chromeos::LanguageSwitchMenu::SwitchLanguage here before | 936 // chromeos::LanguageSwitchMenu::SwitchLanguage here before |
938 // EmitLoginPromptReady. | 937 // EmitLoginPromptReady. |
939 const std::string current_locale = | 938 const std::string current_locale = |
940 g_browser_process->local_state()->GetString( | 939 g_browser_process->local_state()->GetString( |
941 prefs::kApplicationLocale); | 940 prefs::kApplicationLocale); |
942 LOG(INFO) << "current locale: " << current_locale; | 941 VLOG(1) << "Current locale: " << current_locale; |
943 if (current_locale.empty()) { | 942 if (current_locale.empty()) { |
944 locale = controller->GetCustomization()->initial_locale(); | 943 locale = controller->GetCustomization()->initial_locale(); |
945 LOG(INFO) << "initial locale: " << locale; | 944 VLOG(1) << "Initial locale: " << locale; |
946 if (!locale.empty()) { | 945 if (!locale.empty()) { |
947 ResourceBundle::ReloadSharedInstance(locale); | 946 ResourceBundle::ReloadSharedInstance(locale); |
948 } | 947 } |
949 } | 948 } |
950 } | 949 } |
951 | 950 |
952 controller->ShowBackground(screen_bounds); | 951 controller->ShowBackground(screen_bounds); |
953 controller->Init(first_screen_name, screen_bounds); | 952 controller->Init(first_screen_name, screen_bounds); |
954 controller->Show(); | 953 controller->Show(); |
955 | 954 |
956 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 955 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
957 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); | 956 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); |
958 | 957 |
959 if (controller->GetCustomization()) { | 958 if (controller->GetCustomization()) { |
960 if (!locale.empty()) | 959 if (!locale.empty()) |
961 chromeos::LanguageSwitchMenu::SwitchLanguage(locale); | 960 chromeos::LanguageSwitchMenu::SwitchLanguage(locale); |
962 | 961 |
963 // Set initial timezone if specified by customization. | 962 // Set initial timezone if specified by customization. |
964 const std::string timezone_name = | 963 const std::string timezone_name = |
965 controller->GetCustomization()->initial_timezone(); | 964 controller->GetCustomization()->initial_timezone(); |
966 LOG(INFO) << "initial time zone: " << timezone_name; | 965 VLOG(1) << "Initial time zone: " << timezone_name; |
967 // Apply locale customizations only once so preserve whatever locale | 966 // Apply locale customizations only once so preserve whatever locale |
968 // user has changed to during OOBE. | 967 // user has changed to during OOBE. |
969 if (!timezone_name.empty()) { | 968 if (!timezone_name.empty()) { |
970 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | 969 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
971 icu::UnicodeString::fromUTF8(timezone_name)); | 970 icu::UnicodeString::fromUTF8(timezone_name)); |
972 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); | 971 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); |
973 } | 972 } |
974 } | 973 } |
975 } | 974 } |
976 | 975 |
977 } // namespace browser | 976 } // namespace browser |
OLD | NEW |