| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/chrome_browser_main_chromeos.h" | 5 #include "chrome/browser/chromeos/chrome_browser_main_chromeos.h" | 
| 6 | 6 | 
| 7 #include <string> | 7 #include <string> | 
| 8 #include <vector> | 8 #include <vector> | 
| 9 | 9 | 
| 10 #include "ash/ash_switches.h" | 10 #include "ash/ash_switches.h" | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 29 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 29 #include "chrome/browser/chromeos/app_mode/kiosk_app_launch_error.h" | 
| 30 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 30 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h" | 
| 31 #include "chrome/browser/chromeos/boot_times_loader.h" | 31 #include "chrome/browser/chromeos/boot_times_loader.h" | 
| 32 #include "chrome/browser/chromeos/contacts/contact_manager.h" | 32 #include "chrome/browser/chromeos/contacts/contact_manager.h" | 
| 33 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 33 #include "chrome/browser/chromeos/dbus/cros_dbus_service.h" | 
| 34 #include "chrome/browser/chromeos/extensions/default_app_order.h" | 34 #include "chrome/browser/chromeos/extensions/default_app_order.h" | 
| 35 #include "chrome/browser/chromeos/extensions/extension_system_event_observer.h" | 35 #include "chrome/browser/chromeos/extensions/extension_system_event_observer.h" | 
| 36 #include "chrome/browser/chromeos/external_metrics.h" | 36 #include "chrome/browser/chromeos/external_metrics.h" | 
| 37 #include "chrome/browser/chromeos/imageburner/burn_manager.h" | 37 #include "chrome/browser/chromeos/imageburner/burn_manager.h" | 
| 38 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 38 #include "chrome/browser/chromeos/input_method/input_method_configuration.h" | 
|  | 39 #include "chrome/browser/chromeos/input_method/input_method_util.h" | 
| 39 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" | 40 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_idle_logout.h" | 
| 40 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" | 41 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_screensaver.h" | 
| 41 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 42 #include "chrome/browser/chromeos/kiosk_mode/kiosk_mode_settings.h" | 
|  | 43 #include "chrome/browser/chromeos/language_preferences.h" | 
| 42 #include "chrome/browser/chromeos/login/authenticator.h" | 44 #include "chrome/browser/chromeos/login/authenticator.h" | 
| 43 #include "chrome/browser/chromeos/login/login_utils.h" | 45 #include "chrome/browser/chromeos/login/login_utils.h" | 
| 44 #include "chrome/browser/chromeos/login/login_wizard.h" | 46 #include "chrome/browser/chromeos/login/login_wizard.h" | 
| 45 #include "chrome/browser/chromeos/login/screen_locker.h" | 47 #include "chrome/browser/chromeos/login/screen_locker.h" | 
| 46 #include "chrome/browser/chromeos/login/startup_utils.h" | 48 #include "chrome/browser/chromeos/login/startup_utils.h" | 
| 47 #include "chrome/browser/chromeos/login/user_manager.h" | 49 #include "chrome/browser/chromeos/login/user_manager.h" | 
| 48 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 50 #include "chrome/browser/chromeos/login/wallpaper_manager.h" | 
| 49 #include "chrome/browser/chromeos/login/wizard_controller.h" | 51 #include "chrome/browser/chromeos/login/wizard_controller.h" | 
| 50 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" | 52 #include "chrome/browser/chromeos/memory/oom_priority_manager.h" | 
| 51 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 53 #include "chrome/browser/chromeos/net/network_portal_detector.h" | 
| (...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 546     UserManager* user_manager = UserManager::Get(); | 548     UserManager* user_manager = UserManager::Get(); | 
| 547     // In case of multi-profiles --login-profile will contain user_id_hash. | 549     // In case of multi-profiles --login-profile will contain user_id_hash. | 
| 548     std::string username_hash = | 550     std::string username_hash = | 
| 549         parsed_command_line().GetSwitchValueASCII(switches::kLoginProfile); | 551         parsed_command_line().GetSwitchValueASCII(switches::kLoginProfile); | 
| 550     user_manager->UserLoggedIn(username, username_hash, true); | 552     user_manager->UserLoggedIn(username, username_hash, true); | 
| 551     VLOG(1) << "Relaunching browser for user: " << username | 553     VLOG(1) << "Relaunching browser for user: " << username | 
| 552             << " with hash: " << username_hash; | 554             << " with hash: " << username_hash; | 
| 553   } | 555   } | 
| 554 } | 556 } | 
| 555 | 557 | 
|  | 558 class GuestLanguageSetCallbackData { | 
|  | 559  public: | 
|  | 560   explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { | 
|  | 561   } | 
|  | 562 | 
|  | 563   // Must match SwitchLanguageCallback type. | 
|  | 564   static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, | 
|  | 565                        const std::string& locale, | 
|  | 566                        const std::string& loaded_locale, | 
|  | 567                        bool success); | 
|  | 568 | 
|  | 569   Profile* profile; | 
|  | 570 }; | 
|  | 571 | 
|  | 572 // static | 
|  | 573 void GuestLanguageSetCallbackData::Callback( | 
|  | 574     const scoped_ptr<GuestLanguageSetCallbackData>& self, | 
|  | 575     const std::string& locale, | 
|  | 576     const std::string& loaded_locale, | 
|  | 577     bool success) { | 
|  | 578   input_method::InputMethodManager* const ime_manager = | 
|  | 579       input_method::InputMethodManager::Get(); | 
|  | 580   // Active layout must be hardware "login layout". | 
|  | 581   // The previous one must be "locale default layout". | 
|  | 582   const std::string login_input_method = | 
|  | 583       ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodId(); | 
|  | 584   ime_manager->ChangeInputMethod(login_input_method); | 
|  | 585 | 
|  | 586   const std::string locale_default_input_method = | 
|  | 587       ime_manager->GetInputMethodUtil()-> | 
|  | 588           GetLanguageDefaultInputMethodId(loaded_locale); | 
|  | 589   if (!locale_default_input_method.empty()) { | 
|  | 590     PrefService* user_prefs = self->profile->GetPrefs(); | 
|  | 591     user_prefs->SetString(prefs::kLanguagePreviousInputMethod, | 
|  | 592                           locale_default_input_method); | 
|  | 593   } | 
|  | 594 } | 
|  | 595 | 
|  | 596 void SetGuestLocale(UserManager* const usermanager, Profile* const profile) { | 
|  | 597   scoped_ptr<GuestLanguageSetCallbackData> data( | 
|  | 598       new GuestLanguageSetCallbackData(profile)); | 
|  | 599   scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 
|  | 600       new locale_util::SwitchLanguageCallback(base::Bind( | 
|  | 601           &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); | 
|  | 602   User* const user = usermanager->GetUserByProfile(profile); | 
|  | 603   usermanager->RespectLocalePreference(profile, user, callback.Pass()); | 
|  | 604 } | 
|  | 605 | 
| 556 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 606 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 
| 557   // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | 607   // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | 
| 558   // -- just after CreateProfile(). | 608   // -- just after CreateProfile(). | 
| 559 | 609 | 
| 560   // Restarting Chrome inside existing user session. Possible cases: | 610   // Restarting Chrome inside existing user session. Possible cases: | 
| 561   // 1. Chrome is restarted after crash. | 611   // 1. Chrome is restarted after crash. | 
| 562   // 2. Chrome is started in browser_tests skipping the login flow | 612   // 2. Chrome is started in browser_tests skipping the login flow | 
| 563   // 3. Chrome is started on dev machine | 613   // 3. Chrome is started on dev machine | 
| 564   //    i.e. not on Chrome OS device w/o login flow. | 614   //    i.e. not on Chrome OS device w/o login flow. | 
| 565   if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 615   if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 602       detector->Enable(true); | 652       detector->Enable(true); | 
| 603   } | 653   } | 
| 604 | 654 | 
| 605   // Tests should be able to tune login manager before showing it. | 655   // Tests should be able to tune login manager before showing it. | 
| 606   // Thus only show login manager in normal (non-testing) mode. | 656   // Thus only show login manager in normal (non-testing) mode. | 
| 607   if (!parameters().ui_task || | 657   if (!parameters().ui_task || | 
| 608       parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { | 658       parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { | 
| 609     OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | 659     OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | 
| 610   } | 660   } | 
| 611 | 661 | 
|  | 662   // Guest user profile is never initialized with locale settings, | 
|  | 663   // so we need special handling for Guest session. | 
|  | 664   UserManager* const usermanager = UserManager::Get(); | 
|  | 665   if (usermanager->IsLoggedInAsGuest()) | 
|  | 666     SetGuestLocale(usermanager, profile()); | 
|  | 667 | 
| 612   // These observers must be initialized after the profile because | 668   // These observers must be initialized after the profile because | 
| 613   // they use the profile to dispatch extension events. | 669   // they use the profile to dispatch extension events. | 
| 614   extension_system_event_observer_.reset(new ExtensionSystemEventObserver()); | 670   extension_system_event_observer_.reset(new ExtensionSystemEventObserver()); | 
| 615   if (KioskModeSettings::Get()->IsKioskModeEnabled()) { | 671   if (KioskModeSettings::Get()->IsKioskModeEnabled()) { | 
| 616     retail_mode_power_save_blocker_ = content::PowerSaveBlocker::Create( | 672     retail_mode_power_save_blocker_ = content::PowerSaveBlocker::Create( | 
| 617         content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 673         content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 
| 618         "Retail mode"); | 674         "Retail mode"); | 
| 619   } | 675   } | 
| 620 | 676 | 
| 621   peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); | 677   peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 766   // Destroy DBus services immediately after threads are stopped. | 822   // Destroy DBus services immediately after threads are stopped. | 
| 767   dbus_services_.reset(); | 823   dbus_services_.reset(); | 
| 768 | 824 | 
| 769   ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 825   ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 
| 770 | 826 | 
| 771   // Destroy DeviceSettingsService after g_browser_process. | 827   // Destroy DeviceSettingsService after g_browser_process. | 
| 772   DeviceSettingsService::Shutdown(); | 828   DeviceSettingsService::Shutdown(); | 
| 773 } | 829 } | 
| 774 | 830 | 
| 775 }  //  namespace chromeos | 831 }  //  namespace chromeos | 
| OLD | NEW | 
|---|