Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(38)

Side by Side Diff: chrome/browser/chromeos/login/wizard_controller.cc

Issue 3026006: Fixed problems with initial locale change freezing Chrome OS on the device.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 "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 "chrome/browser/browser_process.h" 18 #include "chrome/browser/browser_process.h"
18 #include "chrome/browser/chromeos/cros/cros_library.h" 19 #include "chrome/browser/chromeos/cros/cros_library.h"
19 #include "chrome/browser/chromeos/cros/login_library.h" 20 #include "chrome/browser/chromeos/cros/login_library.h"
20 #include "chrome/browser/chromeos/cros/system_library.h" 21 #include "chrome/browser/chromeos/cros/system_library.h"
21 #include "chrome/browser/chromeos/customization_document.h" 22 #include "chrome/browser/chromeos/customization_document.h"
22 #include "chrome/browser/chromeos/input_method/input_method_util.h" 23 #include "chrome/browser/chromeos/input_method/input_method_util.h"
23 #include "chrome/browser/chromeos/login/account_screen.h" 24 #include "chrome/browser/chromeos/login/account_screen.h"
24 #include "chrome/browser/chromeos/login/background_view.h" 25 #include "chrome/browser/chromeos/login/background_view.h"
25 #include "chrome/browser/chromeos/login/eula_view.h" 26 #include "chrome/browser/chromeos/login/eula_view.h"
26 #include "chrome/browser/chromeos/login/existing_user_controller.h" 27 #include "chrome/browser/chromeos/login/existing_user_controller.h"
(...skipping 17 matching lines...) Expand all
44 #include "views/accelerator.h" 45 #include "views/accelerator.h"
45 #include "views/painter.h" 46 #include "views/painter.h"
46 #include "views/view.h" 47 #include "views/view.h"
47 #include "views/widget/widget_gtk.h" 48 #include "views/widget/widget_gtk.h"
48 49
49 namespace { 50 namespace {
50 51
51 // A boolean pref of the OOBE complete flag. 52 // A boolean pref of the OOBE complete flag.
52 const wchar_t kOobeComplete[] = L"OobeComplete"; 53 const wchar_t kOobeComplete[] = L"OobeComplete";
53 54
55 // Path to OEM partner startup customization manifest.
56 const char kStartupCustomizationManifestPath[] =
57 "/mnt/partner_partition/etc/chromeos/startup_manifest.json";
58
59 // URL where to fetch OEM services customization manifest from.
60 // TODO(denisromanov): Change this to real URL when it becomes available.
Nikita (slow) 2010/07/19 12:31:19 Please file issue to track this and mention it her
61 const char kServicesCustomizationManifestUrl[] =
62 "file:///mnt/partner_partition/etc/chromeos/services_manifest.json";
63
64 // Path to flag file indicating that OOBE was completed successfully.
65 const char kOobeCompleteFlagFilePath[] =
66 "/home/chronos/.oobe_completed";
67
54 // Default size of the OOBE screen. 68 // Default size of the OOBE screen.
55 const int kWizardScreenWidth = 700; 69 const int kWizardScreenWidth = 700;
56 const int kWizardScreenHeight = 416; 70 const int kWizardScreenHeight = 416;
57 71
58 // RootView of the Widget WizardController creates. Contains the contents of the 72 // RootView of the Widget WizardController creates. Contains the contents of the
59 // WizardController. 73 // WizardController.
60 class ContentView : public views::View { 74 class ContentView : public views::View {
61 public: 75 public:
62 ContentView(int window_x, int window_y, int screen_w, int screen_h) 76 ContentView(int window_x, int window_y, int screen_w, int screen_h)
63 : window_x_(window_x), 77 : window_x_(window_x),
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 views::Accelerator accel_network_screen_; 160 views::Accelerator accel_network_screen_;
147 views::Accelerator accel_update_screen_; 161 views::Accelerator accel_update_screen_;
148 views::Accelerator accel_image_screen_; 162 views::Accelerator accel_image_screen_;
149 views::Accelerator accel_eula_screen_; 163 views::Accelerator accel_eula_screen_;
150 164
151 DISALLOW_COPY_AND_ASSIGN(ContentView); 165 DISALLOW_COPY_AND_ASSIGN(ContentView);
152 }; 166 };
153 167
154 void DeleteWizardControllerAndLaunchBrowser(WizardController* controller) { 168 void DeleteWizardControllerAndLaunchBrowser(WizardController* controller) {
155 delete controller; 169 delete controller;
170 // Apply OEM partner services customizations.
171 controller->ApplyPartnerServicesCustomizations();
Nikita (slow) 2010/07/19 12:31:19 It seems like a not the best place to apply these
156 // Launch browser after controller is deleted and its windows are closed. 172 // Launch browser after controller is deleted and its windows are closed.
157 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true); 173 chromeos::LoginUtils::Get()->EnableBrowserLaunch(true);
158 ChromeThread::PostTask( 174 ChromeThread::PostTask(
159 ChromeThread::UI, 175 ChromeThread::UI,
160 FROM_HERE, 176 FROM_HERE,
161 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch, 177 NewRunnableFunction(&chromeos::LoginUtils::DoBrowserLaunch,
162 ProfileManager::GetDefaultProfile())); 178 ProfileManager::GetDefaultProfile()));
163 } 179 }
164 180
165 } // namespace 181 } // namespace
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
336 new chromeos::ExistingUserController(users, screen_bounds); 352 new chromeos::ExistingUserController(users, screen_bounds);
337 controller->OwnBackground(background_widget_, background_view_); 353 controller->OwnBackground(background_widget_, background_view_);
338 controller->Init(); 354 controller->Init();
339 background_widget_ = NULL; 355 background_widget_ = NULL;
340 background_view_ = NULL; 356 background_view_ = NULL;
341 MessageLoop::current()->DeleteSoon(FROM_HERE, this); 357 MessageLoop::current()->DeleteSoon(FROM_HERE, this);
342 return; 358 return;
343 } 359 }
344 360
345 SetCurrentScreen(GetLoginScreen()); 361 SetCurrentScreen(GetLoginScreen());
362
363 LOG(INFO) << "WTF: " << (is_out_of_box_ ? "out" : "in");
Nikita (slow) 2010/07/19 12:31:19 Debug info - should be removed? At least place a d
364
365 if (is_out_of_box_) {
366 // Initiate fetching partner services manifest here.
367 services_manifest_fetcher_.reset(new StringFetcher(
Nikita (slow) 2010/07/19 12:31:19 We're fetching manifest during OOBE welcome-update
368 kServicesCustomizationManifestUrl));
369 }
346 } 370 }
347 371
348 void WizardController::ShowAccountScreen() { 372 void WizardController::ShowAccountScreen() {
349 SetStatusAreaVisible(true); 373 SetStatusAreaVisible(true);
350 SetCurrentScreen(GetAccountScreen()); 374 SetCurrentScreen(GetAccountScreen());
351 } 375 }
352 376
353 void WizardController::ShowUpdateScreen() { 377 void WizardController::ShowUpdateScreen() {
354 SetStatusAreaVisible(true); 378 SetStatusAreaVisible(true);
355 SetCurrentScreen(GetUpdateScreen()); 379 SetCurrentScreen(GetUpdateScreen());
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 ShowLoginScreen(); 574 ShowLoginScreen();
551 } 575 }
552 } 576 }
553 } 577 }
554 578
555 void WizardController::MarkOobeCompleted() { 579 void WizardController::MarkOobeCompleted() {
556 PrefService* prefs = g_browser_process->local_state(); 580 PrefService* prefs = g_browser_process->local_state();
557 prefs->SetBoolean(kOobeComplete, true); 581 prefs->SetBoolean(kOobeComplete, true);
558 // Make sure that changes are reflected immediately. 582 // Make sure that changes are reflected immediately.
559 prefs->SavePersistentPrefs(); 583 prefs->SavePersistentPrefs();
584 // Create flag file for boot-time init scripts.
585 FilePath oobe_complete_path(kOobeCompleteFlagFilePath);
586 FILE* oobe_flag_file = file_util::OpenFile(oobe_complete_path, "w+b");
587 DCHECK(oobe_flag_file != NULL) << kOobeCompleteFlagFilePath;
588 if (oobe_flag_file != NULL)
589 file_util::CloseFile(oobe_flag_file);
590 }
591
592 void WizardController::ApplyPartnerServicesCustomizations() {
593 if (services_manifest_fetcher_.get() == NULL ||
594 services_manifest_fetcher_->result().empty()) {
595 return;
596 }
597 scoped_ptr<chromeos::ServicesCustomizationDocument> customization;
598 bool manifest_loaded;
599 customization.reset(new chromeos::ServicesCustomizationDocument());
600 manifest_loaded = customization->LoadManifestFromString(
601 services_manifest_fetcher_->result());
602 DCHECK(manifest_loaded) << "Customization manifest fetch error: "
603 << services_manifest_fetcher_->result();
604 if (!manifest_loaded)
605 return;
606 if (!customization->initial_start_page_url().empty()) {
607 // Append partner's start page url to command line so it gets opened
608 // on browser startup.
609 CommandLine::ForCurrentProcess()->AppendLooseValue(
610 UTF8ToWide(customization->initial_start_page_url()));
611 }
Nikita (slow) 2010/07/19 12:31:19 apps + exts + support page?
560 } 612 }
561 613
562 /////////////////////////////////////////////////////////////////////////////// 614 ///////////////////////////////////////////////////////////////////////////////
563 // WizardController, chromeos::ScreenObserver overrides: 615 // WizardController, chromeos::ScreenObserver overrides:
564 void WizardController::OnExit(ExitCodes exit_code) { 616 void WizardController::OnExit(ExitCodes exit_code) {
565 switch (exit_code) { 617 switch (exit_code) {
566 case LOGIN_SIGN_IN_SELECTED: 618 case LOGIN_SIGN_IN_SELECTED:
567 OnLoginSignInSelected(); 619 OnLoginSignInSelected();
568 break; 620 break;
569 case LOGIN_GUEST_SELECTED: 621 case LOGIN_GUEST_SELECTED:
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 switches::kEnableLoginImages)) { 714 switches::kEnableLoginImages)) {
663 std::vector<chromeos::UserManager::User> users = 715 std::vector<chromeos::UserManager::User> users =
664 chromeos::UserManager::Get()->GetUsers(); 716 chromeos::UserManager::Get()->GetUsers();
665 // ExistingUserController deletes itself. 717 // ExistingUserController deletes itself.
666 (new chromeos::ExistingUserController(users, screen_bounds))->Init(); 718 (new chromeos::ExistingUserController(users, screen_bounds))->Init();
667 return; 719 return;
668 } 720 }
669 721
670 scoped_ptr<chromeos::StartupCustomizationDocument> customization; 722 scoped_ptr<chromeos::StartupCustomizationDocument> customization;
671 723
672 if (!oobe_complete) { 724 // Load partner customization startup manifest if it is available.
673 // Load partner customization startup manifest if needed. 725 FilePath startup_manifest_path(kStartupCustomizationManifestPath);
674 if (CommandLine::ForCurrentProcess()->HasSwitch( 726 if (file_util::PathExists(startup_manifest_path)) {
Nikita (slow) 2010/07/19 12:31:19 Please add check that startup manifest should exis
675 switches::kStartupManifest)) { 727 customization.reset(new chromeos::StartupCustomizationDocument());
676 customization.reset(new chromeos::StartupCustomizationDocument()); 728 bool manifest_loaded = customization->LoadManifestFromFile(
677 FilePath manifest_path = 729 FilePath(kStartupCustomizationManifestPath));
678 CommandLine::ForCurrentProcess()->GetSwitchValuePath( 730 DCHECK(manifest_loaded) << kStartupCustomizationManifestPath;
679 switches::kStartupManifest); 731 if (!manifest_loaded)
680 bool manifest_loaded = customization->LoadManifestFromFile(manifest_path); 732 customization.reset(NULL);
681 DCHECK(manifest_loaded) << manifest_path.value(); 733 }
682 }
683 734
684 // Do UX customizations if needed. 735 if (chromeos::CrosLibrary::Get()->EnsureLoaded())
685 if (customization != NULL) { 736 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
Nikita (slow) 2010/07/19 12:31:19 We should look deeper into it. Emitting login_prom
Nikita (slow) 2010/07/19 12:54:26 Possible solution: 1. Change Chrome locale only, s
686 // Switch to initial locale if specified by customization. 737
738 if (customization.get() != NULL) {
739 // Switch to initial locale if specified by customization
740 // and has not been set yet.
741 const std::string current_locale =
742 g_browser_process->local_state()->GetString(prefs::kApplicationLocale);
743 if (current_locale.empty()) {
687 const std::string locale = customization->initial_locale(); 744 const std::string locale = customization->initial_locale();
688 if (!locale.empty()) { 745 if (!locale.empty()) {
689 chromeos::LanguageSwitchMenu::SwitchLanguage(locale); 746 chromeos::LanguageSwitchMenu::SwitchLanguage(locale);
690 } 747 }
748 }
691 749
692 // Set initial timezone if specified by customization. 750 // Set initial timezone if specified by customization.
693 const std::string timezone_name = customization->initial_timezone(); 751 const std::string timezone_name = customization->initial_timezone();
694 if (!timezone_name.empty()) { 752 if (!timezone_name.empty()) {
695 icu::TimeZone* timezone = icu::TimeZone::createTimeZone( 753 icu::TimeZone* timezone = icu::TimeZone::createTimeZone(
696 icu::UnicodeString::fromUTF8(timezone_name)); 754 icu::UnicodeString::fromUTF8(timezone_name));
697 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone); 755 chromeos::CrosLibrary::Get()->GetSystemLibrary()->SetTimezone(timezone);
698 }
699 } 756 }
700 } 757 }
701 758
702 // Create and show the wizard. 759 // Create and show the wizard.
703 WizardController* controller = new WizardController(); 760 WizardController* controller = new WizardController();
704 if (!oobe_complete) 761 if (customization.get() != NULL)
705 controller->SetCustomization(customization.release()); 762 controller->SetCustomization(customization.release());
706 controller->ShowBackground(screen_bounds); 763 controller->ShowBackground(screen_bounds);
707 controller->Init(first_screen_name, screen_bounds); 764 controller->Init(first_screen_name, screen_bounds);
708 controller->Show(); 765 controller->Show();
709 if (chromeos::CrosLibrary::Get()->EnsureLoaded())
710 chromeos::CrosLibrary::Get()->GetLoginLibrary()->EmitLoginPromptReady();
711 } 766 }
712 767
713 } // namespace browser 768 } // namespace browser
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698