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 |
11 #include <string> | 11 #include <string> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "app/resource_bundle.h" | 14 #include "app/resource_bundle.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/logging.h" | 16 #include "base/logging.h" |
17 #include "base/file_util.h" | 17 #include "base/file_util.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/input_method_library.h" | 20 #include "chrome/browser/chromeos/cros/input_method_library.h" |
21 #include "chrome/browser/chromeos/cros/login_library.h" | 21 #include "chrome/browser/chromeos/cros/login_library.h" |
22 #include "chrome/browser/chromeos/cros/system_library.h" | 22 #include "chrome/browser/chromeos/cros/system_library.h" |
23 #include "chrome/browser/chromeos/customization_document.h" | 23 #include "chrome/browser/chromeos/customization_document.h" |
24 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
25 #include "chrome/browser/chromeos/login/account_screen.h" | 25 #include "chrome/browser/chromeos/login/account_screen.h" |
| 26 #include "chrome/browser/chromeos/login/apply_services_customization.h" |
26 #include "chrome/browser/chromeos/login/background_view.h" | 27 #include "chrome/browser/chromeos/login/background_view.h" |
27 #include "chrome/browser/chromeos/login/eula_view.h" | 28 #include "chrome/browser/chromeos/login/eula_view.h" |
28 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 29 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
29 #include "chrome/browser/chromeos/login/helper.h" | 30 #include "chrome/browser/chromeos/login/helper.h" |
30 #include "chrome/browser/chromeos/login/language_switch_menu.h" | 31 #include "chrome/browser/chromeos/login/language_switch_menu.h" |
31 #include "chrome/browser/chromeos/login/login_screen.h" | 32 #include "chrome/browser/chromeos/login/login_screen.h" |
32 #include "chrome/browser/chromeos/login/login_utils.h" | 33 #include "chrome/browser/chromeos/login/login_utils.h" |
33 #include "chrome/browser/chromeos/login/network_screen.h" | 34 #include "chrome/browser/chromeos/login/network_screen.h" |
34 #include "chrome/browser/chromeos/login/registration_screen.h" | 35 #include "chrome/browser/chromeos/login/registration_screen.h" |
35 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" | 36 #include "chrome/browser/chromeos/login/rounded_rect_painter.h" |
(...skipping 14 matching lines...) Expand all Loading... |
50 | 51 |
51 namespace { | 52 namespace { |
52 | 53 |
53 // A boolean pref of the OOBE complete flag. | 54 // A boolean pref of the OOBE complete flag. |
54 const wchar_t kOobeComplete[] = L"OobeComplete"; | 55 const wchar_t kOobeComplete[] = L"OobeComplete"; |
55 | 56 |
56 // Path to OEM partner startup customization manifest. | 57 // Path to OEM partner startup customization manifest. |
57 const char kStartupCustomizationManifestPath[] = | 58 const char kStartupCustomizationManifestPath[] = |
58 "/mnt/partner_partition/etc/chromeos/startup_manifest.json"; | 59 "/mnt/partner_partition/etc/chromeos/startup_manifest.json"; |
59 | 60 |
60 // URL where to fetch OEM services customization manifest from. | |
61 // TODO(denisromanov): Change this to real URL when it becomes available. | |
62 // http://crosbug.com/5123 | |
63 const char kServicesCustomizationManifestUrl[] = | |
64 "file:///mnt/partner_partition/etc/chromeos/services_manifest.json"; | |
65 | |
66 // Path to flag file indicating that OOBE was completed successfully. | 61 // Path to flag file indicating that OOBE was completed successfully. |
67 const char kOobeCompleteFlagFilePath[] = | 62 const char kOobeCompleteFlagFilePath[] = |
68 "/home/chronos/.oobe_completed"; | 63 "/home/chronos/.oobe_completed"; |
69 | 64 |
70 // Default size of the OOBE screen. | 65 // Default size of the OOBE screen. |
71 const int kWizardScreenWidth = 700; | 66 const int kWizardScreenWidth = 700; |
72 const int kWizardScreenHeight = 416; | 67 const int kWizardScreenHeight = 416; |
73 | 68 |
74 // RootView of the Widget WizardController creates. Contains the contents of the | 69 // RootView of the Widget WizardController creates. Contains the contents of the |
75 // WizardController. | 70 // WizardController. |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 delete controller; | 172 delete controller; |
178 // Launch browser after controller is deleted and its windows are closed. | 173 // Launch browser after controller is deleted and its windows are closed. |
179 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); | 174 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); |
180 ChromeThread::PostTask( | 175 ChromeThread::PostTask( |
181 ChromeThread::UI, | 176 ChromeThread::UI, |
182 FROM_HERE, | 177 FROM_HERE, |
183 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, | 178 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, |
184 ProfileManager::GetDefaultProfile())); | 179 ProfileManager::GetDefaultProfile())); |
185 } | 180 } |
186 | 181 |
187 void DeleteWizardControllerAndApplyCustomization(WizardController* controller) { | |
188 controller->ApplyPartnerServicesCustomizations(); | |
189 delete controller; | |
190 } | |
191 | |
192 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { | 182 const chromeos::StartupCustomizationDocument* LoadStartupManifest() { |
193 // Load partner customization startup manifest if it is available. | 183 // Load partner customization startup manifest if it is available. |
194 FilePath startup_manifest_path(kStartupCustomizationManifestPath); | 184 FilePath startup_manifest_path(kStartupCustomizationManifestPath); |
195 if (file_util::PathExists(startup_manifest_path)) { | 185 if (file_util::PathExists(startup_manifest_path)) { |
196 scoped_ptr<chromeos::StartupCustomizationDocument> customization( | 186 scoped_ptr<chromeos::StartupCustomizationDocument> customization( |
197 new chromeos::StartupCustomizationDocument()); | 187 new chromeos::StartupCustomizationDocument()); |
198 bool manifest_loaded = customization->LoadManifestFromFile( | 188 bool manifest_loaded = customization->LoadManifestFromFile( |
199 startup_manifest_path); | 189 startup_manifest_path); |
200 if (manifest_loaded) { | 190 if (manifest_loaded) { |
201 LOG(INFO) << "Startup manifest loaded successfully"; | 191 LOG(INFO) << "Startup manifest loaded successfully"; |
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
371 void WizardController::ShowNetworkScreen() { | 361 void WizardController::ShowNetworkScreen() { |
372 SetStatusAreaVisible(false); | 362 SetStatusAreaVisible(false); |
373 SetCurrentScreen(GetNetworkScreen()); | 363 SetCurrentScreen(GetNetworkScreen()); |
374 background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); | 364 background_view_->SetOobeProgress(chromeos::BackgroundView::SELECT_NETWORK); |
375 } | 365 } |
376 | 366 |
377 chromeos::ExistingUserController* WizardController::ShowLoginScreen() { | 367 chromeos::ExistingUserController* WizardController::ShowLoginScreen() { |
378 SetStatusAreaVisible(true); | 368 SetStatusAreaVisible(true); |
379 background_view_->SetOobeProgress(chromeos::BackgroundView::SIGNIN); | 369 background_view_->SetOobeProgress(chromeos::BackgroundView::SIGNIN); |
380 | 370 |
| 371 // Initiate services customization. |
| 372 chromeos::ApplyServicesCustomization::StartIfNeeded(); |
| 373 |
381 // When run under automation test show plain login screen. | 374 // When run under automation test show plain login screen. |
382 if (!is_test_mode_ && | 375 if (!is_test_mode_ && |
383 chromeos::CrosLibrary::Get()->EnsureLoaded() && | 376 chromeos::CrosLibrary::Get()->EnsureLoaded() && |
384 CommandLine::ForCurrentProcess()->HasSwitch( | 377 CommandLine::ForCurrentProcess()->HasSwitch( |
385 switches::kEnableLoginImages)) { | 378 switches::kEnableLoginImages)) { |
386 std::vector<chromeos::UserManager::User> users = | 379 std::vector<chromeos::UserManager::User> users = |
387 chromeos::UserManager::Get()->GetUsers(); | 380 chromeos::UserManager::Get()->GetUsers(); |
388 // ExistingUserController deletes itself. | 381 // ExistingUserController deletes itself. |
389 gfx::Rect screen_bounds; | 382 gfx::Rect screen_bounds; |
390 background_widget_->GetBounds(&screen_bounds, true); | 383 background_widget_->GetBounds(&screen_bounds, true); |
391 chromeos::ExistingUserController* controller = | 384 chromeos::ExistingUserController* controller = |
392 new chromeos::ExistingUserController(users, screen_bounds); | 385 new chromeos::ExistingUserController(users, screen_bounds); |
393 controller->OwnBackground(background_widget_, background_view_); | 386 controller->OwnBackground(background_widget_, background_view_); |
394 controller->Init(); | 387 controller->Init(); |
395 background_widget_ = NULL; | 388 background_widget_ = NULL; |
396 background_view_ = NULL; | 389 background_view_ = NULL; |
397 | 390 |
398 FilePath startup_manifest_path(kStartupCustomizationManifestPath); | 391 MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
399 if (file_util::PathExists(startup_manifest_path)) { | |
400 services_manifest_fetcher_.reset(new StringFetcher( | |
401 kServicesCustomizationManifestUrl)); | |
402 } | |
403 ChromeThread::PostTask( | |
404 ChromeThread::UI, | |
405 FROM_HERE, | |
406 NewRunnableFunction(&DeleteWizardControllerAndApplyCustomization, | |
407 this)); | |
408 | 392 |
409 return controller; | 393 return controller; |
410 } | 394 } |
411 | 395 |
412 SetCurrentScreen(GetLoginScreen()); | 396 SetCurrentScreen(GetLoginScreen()); |
413 return NULL; | 397 return NULL; |
414 } | 398 } |
415 | 399 |
416 void WizardController::ShowAccountScreen() { | 400 void WizardController::ShowAccountScreen() { |
417 LOG(INFO) << "Showing create account screen."; | 401 LOG(INFO) << "Showing create account screen."; |
(...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
655 | 639 |
656 void WizardController::MarkDeviceRegistered() { | 640 void WizardController::MarkDeviceRegistered() { |
657 // Create flag file for boot-time init scripts. | 641 // Create flag file for boot-time init scripts. |
658 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); | 642 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); |
659 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); | 643 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); |
660 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; | 644 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; |
661 if (oobe_flag_file != NULL) | 645 if (oobe_flag_file != NULL) |
662 file_util::CloseFile(oobe_flag_file); | 646 file_util::CloseFile(oobe_flag_file); |
663 } | 647 } |
664 | 648 |
665 void WizardController::ApplyPartnerServicesCustomizations() { | |
666 if (services_manifest_fetcher_.get() == NULL || | |
667 services_manifest_fetcher_->result().empty()) { | |
668 return; | |
669 } | |
670 scoped_ptr<chromeos::ServicesCustomizationDocument> customization; | |
671 bool manifest_loaded; | |
672 customization.reset(new chromeos::ServicesCustomizationDocument()); | |
673 manifest_loaded = customization->LoadManifestFromString( | |
674 services_manifest_fetcher_->result()); | |
675 DCHECK(manifest_loaded) << "Customization manifest fetch error: " | |
676 << services_manifest_fetcher_->result(); | |
677 if (!manifest_loaded) | |
678 return; | |
679 LOG(INFO) << "partner services customizations manifest loaded successfully"; | |
680 if (!customization->initial_start_page_url().empty()) { | |
681 // Append partner's start page url to command line so it gets opened | |
682 // on browser startup. | |
683 CommandLine::ForCurrentProcess()->AppendLooseValue( | |
684 UTF8ToWide(customization->initial_start_page_url())); | |
685 LOG(INFO) << "initial_start_page_url: " | |
686 << customization->initial_start_page_url(); | |
687 } | |
688 // TODO(dpolukhin): apply customized apps, exts and support page. | |
689 } | |
690 | |
691 /////////////////////////////////////////////////////////////////////////////// | 649 /////////////////////////////////////////////////////////////////////////////// |
692 // WizardController, chromeos::ScreenObserver overrides: | 650 // WizardController, chromeos::ScreenObserver overrides: |
693 void WizardController::OnExit(ExitCodes exit_code) { | 651 void WizardController::OnExit(ExitCodes exit_code) { |
694 LOG(INFO) << "Wizard screen exit code: " << exit_code; | 652 LOG(INFO) << "Wizard screen exit code: " << exit_code; |
695 switch (exit_code) { | 653 switch (exit_code) { |
696 case LOGIN_SIGN_IN_SELECTED: | 654 case LOGIN_SIGN_IN_SELECTED: |
697 OnLoginSignInSelected(); | 655 OnLoginSignInSelected(); |
698 break; | 656 break; |
699 case LOGIN_GUEST_SELECTED: | 657 case LOGIN_GUEST_SELECTED: |
700 OnLoginGuestUser(); | 658 OnLoginGuestUser(); |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
799 | 757 |
800 if (first_screen_name.empty() && | 758 if (first_screen_name.empty() && |
801 oobe_complete && | 759 oobe_complete && |
802 chromeos::CrosLibrary::Get()->EnsureLoaded() && | 760 chromeos::CrosLibrary::Get()->EnsureLoaded() && |
803 CommandLine::ForCurrentProcess()->HasSwitch( | 761 CommandLine::ForCurrentProcess()->HasSwitch( |
804 switches::kEnableLoginImages)) { | 762 switches::kEnableLoginImages)) { |
805 std::vector<chromeos::UserManager::User> users = | 763 std::vector<chromeos::UserManager::User> users = |
806 chromeos::UserManager::Get()->GetUsers(); | 764 chromeos::UserManager::Get()->GetUsers(); |
807 // ExistingUserController deletes itself. | 765 // ExistingUserController deletes itself. |
808 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); | 766 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); |
| 767 |
| 768 // Initiate services customization. |
| 769 chromeos::ApplyServicesCustomization::StartIfNeeded(); |
| 770 |
809 return; | 771 return; |
810 } | 772 } |
811 | 773 |
812 // Create and show the wizard. | 774 // Create and show the wizard. |
813 WizardController* controller = new WizardController(); | 775 WizardController* controller = new WizardController(); |
814 | 776 |
815 // Load startup manifest. | 777 // Load startup manifest. |
816 controller->SetCustomization(LoadStartupManifest()); | 778 controller->SetCustomization(LoadStartupManifest()); |
817 | 779 |
818 std::string locale; | 780 std::string locale; |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
853 // user has changed to during OOBE. | 815 // user has changed to during OOBE. |
854 if (!timezone_name.empty()) { | 816 if (!timezone_name.empty()) { |
855 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | 817 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
856 icu::UnicodeString::fromUTF8(timezone_name)); | 818 icu::UnicodeString::fromUTF8(timezone_name)); |
857 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); | 819 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); |
858 } | 820 } |
859 } | 821 } |
860 } | 822 } |
861 | 823 |
862 } // namespace browser | 824 } // namespace browser |
OLD | NEW |