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/l10n_util.h" | 14 #include "app/l10n_util.h" |
| 15 #include "app/resource_bundle.h" |
15 #include "base/command_line.h" | 16 #include "base/command_line.h" |
16 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/file_util.h" |
17 #include "chrome/browser/browser_process.h" | 19 #include "chrome/browser/browser_process.h" |
18 #include "chrome/browser/chromeos/cros/cros_library.h" | 20 #include "chrome/browser/chromeos/cros/cros_library.h" |
19 #include "chrome/browser/chromeos/cros/login_library.h" | 21 #include "chrome/browser/chromeos/cros/login_library.h" |
20 #include "chrome/browser/chromeos/cros/system_library.h" | 22 #include "chrome/browser/chromeos/cros/system_library.h" |
21 #include "chrome/browser/chromeos/customization_document.h" | 23 #include "chrome/browser/chromeos/customization_document.h" |
22 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 24 #include "chrome/browser/chromeos/input_method/input_method_util.h" |
23 #include "chrome/browser/chromeos/login/account_screen.h" | 25 #include "chrome/browser/chromeos/login/account_screen.h" |
24 #include "chrome/browser/chromeos/login/background_view.h" | 26 #include "chrome/browser/chromeos/login/background_view.h" |
25 #include "chrome/browser/chromeos/login/eula_view.h" | 27 #include "chrome/browser/chromeos/login/eula_view.h" |
26 #include "chrome/browser/chromeos/login/existing_user_controller.h" | 28 #include "chrome/browser/chromeos/login/existing_user_controller.h" |
(...skipping 17 matching lines...) Expand all Loading... |
44 #include "views/accelerator.h" | 46 #include "views/accelerator.h" |
45 #include "views/painter.h" | 47 #include "views/painter.h" |
46 #include "views/view.h" | 48 #include "views/view.h" |
47 #include "views/widget/widget_gtk.h" | 49 #include "views/widget/widget_gtk.h" |
48 | 50 |
49 namespace { | 51 namespace { |
50 | 52 |
51 // A boolean pref of the OOBE complete flag. | 53 // A boolean pref of the OOBE complete flag. |
52 const wchar_t kOobeComplete[] = L"OobeComplete"; | 54 const wchar_t kOobeComplete[] = L"OobeComplete"; |
53 | 55 |
| 56 // Path to OEM partner startup customization manifest. |
| 57 const char kStartupCustomizationManifestPath[] = |
| 58 "/mnt/partner_partition/etc/chromeos/startup_manifest.json"; |
| 59 |
| 60 // URL where to fetch OEM services customization manifest from. |
| 61 // TODO(denisromanov): Change this to real URL when it becomes available. |
| 62 const char kServicesCustomizationManifestUrl[] = |
| 63 "file:///mnt/partner_partition/etc/chromeos/services_manifest.json"; |
| 64 |
| 65 // Path to flag file indicating that OOBE was completed successfully. |
| 66 const char kOobeCompleteFlagFilePath[] = |
| 67 "/home/chronos/.oobe_completed"; |
| 68 |
54 // Default size of the OOBE screen. | 69 // Default size of the OOBE screen. |
55 const int kWizardScreenWidth = 700; | 70 const int kWizardScreenWidth = 700; |
56 const int kWizardScreenHeight = 416; | 71 const int kWizardScreenHeight = 416; |
57 | 72 |
58 // RootView of the Widget WizardController creates. Contains the contents of the | 73 // RootView of the Widget WizardController creates. Contains the contents of the |
59 // WizardController. | 74 // WizardController. |
60 class ContentView : public views::View { | 75 class ContentView : public views::View { |
61 public: | 76 public: |
62 ContentView(int window_x, int window_y, int screen_w, int screen_h) | 77 ContentView(int window_x, int window_y, int screen_w, int screen_h) |
63 : window_x_(window_x), | 78 : window_x_(window_x), |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
155 delete controller; | 170 delete controller; |
156 // Launch browser after controller is deleted and its windows are closed. | 171 // Launch browser after controller is deleted and its windows are closed. |
157 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); | 172 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); |
158 ChromeThread::PostTask( | 173 ChromeThread::PostTask( |
159 ChromeThread::UI, | 174 ChromeThread::UI, |
160 FROM_HERE, | 175 FROM_HERE, |
161 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, | 176 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, |
162 ProfileManager::GetDefaultProfile())); | 177 ProfileManager::GetDefaultProfile())); |
163 } | 178 } |
164 | 179 |
| 180 void DeleteWizardControllerAndApplyCustomization(WizardController* controller) { |
| 181 controller->ApplyPartnerServicesCustomizations(); |
| 182 delete controller; |
| 183 } |
| 184 |
165 } // namespace | 185 } // namespace |
166 | 186 |
167 const char WizardController::kNetworkScreenName[] = "network"; | 187 const char WizardController::kNetworkScreenName[] = "network"; |
168 const char WizardController::kLoginScreenName[] = "login"; | 188 const char WizardController::kLoginScreenName[] = "login"; |
169 const char WizardController::kAccountScreenName[] = "account"; | 189 const char WizardController::kAccountScreenName[] = "account"; |
170 const char WizardController::kUpdateScreenName[] = "update"; | 190 const char WizardController::kUpdateScreenName[] = "update"; |
171 const char WizardController::kUserImageScreenName[] = "image"; | 191 const char WizardController::kUserImageScreenName[] = "image"; |
172 const char WizardController::kEulaScreenName[] = "eula"; | 192 const char WizardController::kEulaScreenName[] = "eula"; |
173 const char WizardController::kRegistrationScreenName[] = "register"; | 193 const char WizardController::kRegistrationScreenName[] = "register"; |
174 | 194 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 // stream). Hence enabling double buffer. | 250 // stream). Hence enabling double buffer. |
231 window->EnableDoubleBuffer(true); | 251 window->EnableDoubleBuffer(true); |
232 window->Init(NULL, gfx::Rect(window_x, window_y, kWizardScreenWidth, | 252 window->Init(NULL, gfx::Rect(window_x, window_y, kWizardScreenWidth, |
233 kWizardScreenHeight)); | 253 kWizardScreenHeight)); |
234 chromeos::WmIpc::instance()->SetWindowType( | 254 chromeos::WmIpc::instance()->SetWindowType( |
235 window->GetNativeView(), | 255 window->GetNativeView(), |
236 chromeos::WM_IPC_WINDOW_LOGIN_GUEST, | 256 chromeos::WM_IPC_WINDOW_LOGIN_GUEST, |
237 NULL); | 257 NULL); |
238 window->SetContentsView(contents_); | 258 window->SetContentsView(contents_); |
239 | 259 |
240 bool oobe_complete = IsOobeComplete(); | 260 bool oobe_complete = IsOobeCompleted(); |
241 | 261 |
242 if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) { | 262 if (!oobe_complete || first_screen_name == kOutOfBoxScreenName) { |
243 is_out_of_box_ = true; | 263 is_out_of_box_ = true; |
244 } | 264 } |
245 | 265 |
246 ShowFirstScreen(first_screen_name); | 266 ShowFirstScreen(first_screen_name); |
247 | 267 |
248 // This keeps the window from flashing at startup. | 268 // This keeps the window from flashing at startup. |
249 GdkWindow* gdk_window = window->GetNativeView()->window; | 269 GdkWindow* gdk_window = window->GetNativeView()->window; |
250 gdk_window_set_back_pixmap(gdk_window, NULL, false); | 270 gdk_window_set_back_pixmap(gdk_window, NULL, false); |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 chromeos::UserManager::Get()->GetUsers(); | 353 chromeos::UserManager::Get()->GetUsers(); |
334 // ExistingUserController deletes itself. | 354 // ExistingUserController deletes itself. |
335 gfx::Rect screen_bounds; | 355 gfx::Rect screen_bounds; |
336 background_widget_->GetBounds(&screen_bounds, true); | 356 background_widget_->GetBounds(&screen_bounds, true); |
337 chromeos::ExistingUserController* controller = | 357 chromeos::ExistingUserController* controller = |
338 new chromeos::ExistingUserController(users, screen_bounds); | 358 new chromeos::ExistingUserController(users, screen_bounds); |
339 controller->OwnBackground(background_widget_, background_view_); | 359 controller->OwnBackground(background_widget_, background_view_); |
340 controller->Init(); | 360 controller->Init(); |
341 background_widget_ = NULL; | 361 background_widget_ = NULL; |
342 background_view_ = NULL; | 362 background_view_ = NULL; |
343 MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 363 |
| 364 FilePath startup_manifest_path(kStartupCustomizationManifestPath); |
| 365 if (file_util::PathExists(startup_manifest_path)) { |
| 366 services_manifest_fetcher_.reset(new StringFetcher( |
| 367 kServicesCustomizationManifestUrl)); |
| 368 } |
| 369 ChromeThread::PostTask( |
| 370 ChromeThread::UI, |
| 371 FROM_HERE, |
| 372 NewRunnableFunction(&DeleteWizardControllerAndApplyCustomization, |
| 373 this)); |
| 374 |
344 return; | 375 return; |
345 } | 376 } |
346 | 377 |
347 SetCurrentScreen(GetLoginScreen()); | 378 SetCurrentScreen(GetLoginScreen()); |
348 } | 379 } |
349 | 380 |
350 void WizardController::ShowAccountScreen() { | 381 void WizardController::ShowAccountScreen() { |
351 SetStatusAreaVisible(true); | 382 SetStatusAreaVisible(true); |
352 SetCurrentScreen(GetAccountScreen()); | 383 SetCurrentScreen(GetAccountScreen()); |
353 } | 384 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
443 } | 474 } |
444 | 475 |
445 void WizardController::OnAccountCreated() { | 476 void WizardController::OnAccountCreated() { |
446 ShowLoginScreen(); | 477 ShowLoginScreen(); |
447 chromeos::LoginScreen* login = GetLoginScreen(); | 478 chromeos::LoginScreen* login = GetLoginScreen(); |
448 if (!username_.empty()) { | 479 if (!username_.empty()) { |
449 login->view()->SetUsername(username_); | 480 login->view()->SetUsername(username_); |
450 if (!password_.empty()) { | 481 if (!password_.empty()) { |
451 login->view()->SetPassword(password_); | 482 login->view()->SetPassword(password_); |
452 // TODO(dpolukhin): clear password memory for real. Now it is not | 483 // TODO(dpolukhin): clear password memory for real. Now it is not |
453 // a problem becuase we can't extract password from the form. | 484 // a problem because we can't extract password from the form. |
454 password_.clear(); | 485 password_.clear(); |
455 login->view()->Login(); | 486 login->view()->Login(); |
456 } | 487 } |
457 } | 488 } |
458 } | 489 } |
459 | 490 |
460 void WizardController::OnConnectionFailed() { | 491 void WizardController::OnConnectionFailed() { |
461 // TODO(dpolukhin): show error message after login screen is displayed. | 492 // TODO(dpolukhin): show error message after login screen is displayed. |
462 ShowLoginScreen(); | 493 ShowLoginScreen(); |
463 } | 494 } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
499 NewRunnableFunction(&DeleteWizardControllerAndLaunchBrowser, | 530 NewRunnableFunction(&DeleteWizardControllerAndLaunchBrowser, |
500 this)); | 531 this)); |
501 // TODO(avayvod): Sync image with Google Sync. | 532 // TODO(avayvod): Sync image with Google Sync. |
502 } | 533 } |
503 | 534 |
504 void WizardController::OnUserImageSkipped() { | 535 void WizardController::OnUserImageSkipped() { |
505 OnUserImageSelected(); | 536 OnUserImageSelected(); |
506 } | 537 } |
507 | 538 |
508 void WizardController::OnRegistrationSuccess() { | 539 void WizardController::OnRegistrationSuccess() { |
| 540 MarkDeviceRegistered(); |
509 // TODO(nkostylev): Registration screen should be shown on first sign in. | 541 // TODO(nkostylev): Registration screen should be shown on first sign in. |
510 ShowLoginScreen(); | 542 ShowLoginScreen(); |
511 } | 543 } |
512 | 544 |
513 void WizardController::OnRegistrationSkipped() { | 545 void WizardController::OnRegistrationSkipped() { |
514 // TODO(nkostylev): Track in a histogram? | 546 // TODO(nkostylev): Track in a histogram? |
515 OnRegistrationSuccess(); | 547 OnRegistrationSuccess(); |
516 } | 548 } |
517 | 549 |
518 /////////////////////////////////////////////////////////////////////////////// | 550 /////////////////////////////////////////////////////////////////////////////// |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
564 } | 596 } |
565 } | 597 } |
566 | 598 |
567 void WizardController::MarkOobeCompleted() { | 599 void WizardController::MarkOobeCompleted() { |
568 PrefService* prefs = g_browser_process->local_state(); | 600 PrefService* prefs = g_browser_process->local_state(); |
569 prefs->SetBoolean(kOobeComplete, true); | 601 prefs->SetBoolean(kOobeComplete, true); |
570 // Make sure that changes are reflected immediately. | 602 // Make sure that changes are reflected immediately. |
571 prefs->SavePersistentPrefs(); | 603 prefs->SavePersistentPrefs(); |
572 } | 604 } |
573 | 605 |
| 606 void WizardController::MarkDeviceRegistered() { |
| 607 // Create flag file for boot-time init scripts. |
| 608 FilePath oobe_complete_path(kOobeCompleteFlagFilePath); |
| 609 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b"); |
| 610 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath; |
| 611 if (oobe_flag_file != NULL) |
| 612 file_util::CloseFile(oobe_flag_file); |
| 613 } |
| 614 |
| 615 void WizardController::ApplyPartnerServicesCustomizations() { |
| 616 if (services_manifest_fetcher_.get() == NULL || |
| 617 services_manifest_fetcher_->result().empty()) { |
| 618 return; |
| 619 } |
| 620 scoped_ptr<chromeos::ServicesCustomizationDocument> customization; |
| 621 bool manifest_loaded; |
| 622 customization.reset(new chromeos::ServicesCustomizationDocument()); |
| 623 manifest_loaded = customization->LoadManifestFromString( |
| 624 services_manifest_fetcher_->result()); |
| 625 DCHECK(manifest_loaded) << "Customization manifest fetch error: " |
| 626 << services_manifest_fetcher_->result(); |
| 627 if (!manifest_loaded) |
| 628 return; |
| 629 LOG(INFO) << "partner services customizations manifest loaded successfully"; |
| 630 if (!customization->initial_start_page_url().empty()) { |
| 631 // Append partner's start page url to command line so it gets opened |
| 632 // on browser startup. |
| 633 CommandLine::ForCurrentProcess()->AppendLooseValue( |
| 634 UTF8ToWide(customization->initial_start_page_url())); |
| 635 LOG(INFO) << "initial_start_page_url: " |
| 636 << customization->initial_start_page_url(); |
| 637 } |
| 638 // TODO(dpolukhin): apply customized apps, exts and support page. |
| 639 MarkDeviceRegistered(); |
| 640 } |
| 641 |
574 /////////////////////////////////////////////////////////////////////////////// | 642 /////////////////////////////////////////////////////////////////////////////// |
575 // WizardController, chromeos::ScreenObserver overrides: | 643 // WizardController, chromeos::ScreenObserver overrides: |
576 void WizardController::OnExit(ExitCodes exit_code) { | 644 void WizardController::OnExit(ExitCodes exit_code) { |
577 switch (exit_code) { | 645 switch (exit_code) { |
578 case LOGIN_SIGN_IN_SELECTED: | 646 case LOGIN_SIGN_IN_SELECTED: |
579 OnLoginSignInSelected(); | 647 OnLoginSignInSelected(); |
580 break; | 648 break; |
581 case LOGIN_GUEST_SELECTED: | 649 case LOGIN_GUEST_SELECTED: |
582 OnLoginGuestUser(); | 650 OnLoginGuestUser(); |
583 break; | 651 break; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
632 /////////////////////////////////////////////////////////////////////////////// | 700 /////////////////////////////////////////////////////////////////////////////// |
633 // WizardController, WizardScreen overrides: | 701 // WizardController, WizardScreen overrides: |
634 views::View* WizardController::GetWizardView() { | 702 views::View* WizardController::GetWizardView() { |
635 return contents_; | 703 return contents_; |
636 } | 704 } |
637 | 705 |
638 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { | 706 chromeos::ScreenObserver* WizardController::GetObserver(WizardScreen* screen) { |
639 return observer_ ? observer_ : this; | 707 return observer_ ? observer_ : this; |
640 } | 708 } |
641 | 709 |
642 bool WizardController::IsOobeComplete() { | 710 bool WizardController::IsOobeCompleted() { |
643 return g_browser_process->local_state()->GetBoolean(kOobeComplete); | 711 return g_browser_process->local_state()->GetBoolean(kOobeComplete); |
644 } | 712 } |
645 | 713 |
| 714 bool WizardController::IsDeviceRegistered() { |
| 715 FilePath oobe_complete_flag_file_path(kOobeCompleteFlagFilePath); |
| 716 return file_util::PathExists(oobe_complete_flag_file_path); |
| 717 } |
| 718 |
646 namespace browser { | 719 namespace browser { |
647 | 720 |
648 // Declared in browser_dialogs.h so that others don't need to depend on our .h. | 721 // Declared in browser_dialogs.h so that others don't need to depend on our .h. |
649 void ShowLoginWizard(const std::string& first_screen_name, | 722 void ShowLoginWizard(const std::string& first_screen_name, |
650 const gfx::Size& size) { | 723 const gfx::Size& size) { |
651 LOG(INFO) << "showing login screen: " << first_screen_name; | 724 LOG(INFO) << "showing login screen: " << first_screen_name; |
652 | 725 |
653 // Tell the window manager that the user isn't logged in. | 726 // Tell the window manager that the user isn't logged in. |
654 chromeos::WmIpc::instance()->SetLoggedInProperty(false); | 727 chromeos::WmIpc::instance()->SetLoggedInProperty(false); |
655 | 728 |
656 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty | 729 // Set up keyboards. For example, when |locale| is "en-US", enable US qwerty |
657 // and US dvorak keyboard layouts. | 730 // and US dvorak keyboard layouts. |
658 if (g_browser_process && g_browser_process->local_state()) { | 731 if (g_browser_process && g_browser_process->local_state()) { |
659 const std::string locale = g_browser_process->GetApplicationLocale(); | 732 const std::string locale = g_browser_process->GetApplicationLocale(); |
660 const std::string initial_input_method_id = | 733 const std::string initial_input_method_id = |
661 g_browser_process->local_state()->GetString( | 734 g_browser_process->local_state()->GetString( |
662 chromeos::kPreferredKeyboardLayout); | 735 chromeos::kPreferredKeyboardLayout); |
663 chromeos::input_method::EnableInputMethods( | 736 chromeos::input_method::EnableInputMethods( |
664 locale, chromeos::input_method::kKeyboardLayoutsOnly, | 737 locale, chromeos::input_method::kKeyboardLayoutsOnly, |
665 initial_input_method_id); | 738 initial_input_method_id); |
666 } | 739 } |
667 | 740 |
668 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(size)); | 741 gfx::Rect screen_bounds(chromeos::CalculateScreenBounds(size)); |
669 | 742 |
670 // Check whether we need to execute OOBE process. | 743 // Check whether we need to execute OOBE process. |
671 bool oobe_complete = WizardController::IsOobeComplete(); | 744 bool oobe_complete = WizardController::IsOobeCompleted(); |
672 | 745 |
673 if (first_screen_name.empty() && | 746 if (first_screen_name.empty() && |
674 oobe_complete && | 747 oobe_complete && |
675 chromeos::CrosLibrary::Get()->EnsureLoaded() && | 748 chromeos::CrosLibrary::Get()->EnsureLoaded() && |
676 CommandLine::ForCurrentProcess()->HasSwitch( | 749 CommandLine::ForCurrentProcess()->HasSwitch( |
677 switches::kEnableLoginImages)) { | 750 switches::kEnableLoginImages)) { |
678 std::vector<chromeos::UserManager::User> users = | 751 std::vector<chromeos::UserManager::User> users = |
679 chromeos::UserManager::Get()->GetUsers(); | 752 chromeos::UserManager::Get()->GetUsers(); |
680 // ExistingUserController deletes itself. | 753 // ExistingUserController deletes itself. |
681 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); | 754 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); |
682 return; | 755 return; |
683 } | 756 } |
684 | 757 |
685 scoped_ptr<chromeos::StartupCustomizationDocument> customization; | |
686 | |
687 if (!oobe_complete) { | |
688 // Load partner customization startup manifest if needed. | |
689 if (CommandLine::ForCurrentProcess()->HasSwitch( | |
690 switches::kStartupManifest)) { | |
691 customization.reset(new chromeos::StartupCustomizationDocument()); | |
692 FilePath manifest_path = | |
693 CommandLine::ForCurrentProcess()->GetSwitchValuePath( | |
694 switches::kStartupManifest); | |
695 bool manifest_loaded = customization->LoadManifestFromFile(manifest_path); | |
696 DCHECK(manifest_loaded) << manifest_path.value(); | |
697 } | |
698 | |
699 // Do UX customizations if needed. | |
700 if (customization != NULL) { | |
701 // Switch to initial locale if specified by customization. | |
702 const std::string locale = customization->initial_locale(); | |
703 if (!locale.empty()) { | |
704 chromeos::LanguageSwitchMenu::SwitchLanguage(locale); | |
705 } | |
706 | |
707 // Set initial timezone if specified by customization. | |
708 const std::string timezone_name = customization->initial_timezone(); | |
709 if (!timezone_name.empty()) { | |
710 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( | |
711 icu::UnicodeString::fromUTF8(timezone_name)); | |
712 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); | |
713 } | |
714 } | |
715 } | |
716 | |
717 // Create and show the wizard. | 758 // Create and show the wizard. |
718 WizardController* controller = new WizardController(); | 759 WizardController* controller = new WizardController(); |
719 if (!oobe_complete) | 760 |
720 controller->SetCustomization(customization.release()); | 761 // Load partner customization startup manifest if it is available. |
| 762 FilePath startup_manifest_path(kStartupCustomizationManifestPath); |
| 763 std::string locale; |
| 764 if (file_util::PathExists(startup_manifest_path)) { |
| 765 scoped_ptr<chromeos::StartupCustomizationDocument> customization( |
| 766 new chromeos::StartupCustomizationDocument()); |
| 767 bool manifest_loaded = customization->LoadManifestFromFile( |
| 768 FilePath(kStartupCustomizationManifestPath)); |
| 769 DCHECK(manifest_loaded) << kStartupCustomizationManifestPath; |
| 770 if (manifest_loaded) { |
| 771 LOG(INFO) << "startup manifest loaded successfully"; |
| 772 // Switch to initial locale if specified by customization |
| 773 // and has not been set yet. We cannot call |
| 774 // chromeos::LanguageSwitchMenu::SwitchLanguage here before |
| 775 // EmitLoginPromptReady. |
| 776 const std::string current_locale = |
| 777 g_browser_process->local_state()->GetString( |
| 778 prefs::kApplicationLocale); |
| 779 LOG(INFO) << "current locale: " << current_locale; |
| 780 if (current_locale.empty()) { |
| 781 locale = customization->initial_locale(); |
| 782 LOG(INFO) << "initial locale: " << locale; |
| 783 if (!locale.empty()) { |
| 784 ResourceBundle::ReloadSharedInstance(UTF8ToWide(locale)); |
| 785 } |
| 786 } |
| 787 |
| 788 controller->SetCustomization(customization.release()); |
| 789 } |
| 790 } |
| 791 |
721 controller->ShowBackground(screen_bounds); | 792 controller->ShowBackground(screen_bounds); |
722 controller->Init(first_screen_name, screen_bounds); | 793 controller->Init(first_screen_name, screen_bounds); |
723 controller->Show(); | 794 controller->Show(); |
| 795 |
724 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) | 796 if (chromeos::CrosLibrary::Get()->EnsureLoaded()) |
725 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); | 797 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady(); |
| 798 |
| 799 if (controller->GetCustomization() != NULL) { |
| 800 if (!locale.empty()) |
| 801 chromeos::LanguageSwitchMenu::SwitchLanguage(locale); |
| 802 |
| 803 // Set initial timezone if specified by customization. |
| 804 const std::string timezone_name = |
| 805 controller->GetCustomization()->initial_timezone(); |
| 806 LOG(INFO) << "initial time zone: " << timezone_name; |
| 807 if (!timezone_name.empty()) { |
| 808 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( |
| 809 icu::UnicodeString::fromUTF8(timezone_name)); |
| 810 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); |
| 811 } |
| 812 } |
726 } | 813 } |
727 | 814 |
728 } // namespace browser | 815 } // namespace browser |
OLD | NEW |