| 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 488 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  540     UserManager* user_manager = UserManager::Get(); |  542     UserManager* user_manager = UserManager::Get(); | 
|  541     // In case of multi-profiles --login-profile will contain user_id_hash. |  543     // In case of multi-profiles --login-profile will contain user_id_hash. | 
|  542     std::string username_hash = |  544     std::string username_hash = | 
|  543         parsed_command_line().GetSwitchValueASCII(switches::kLoginProfile); |  545         parsed_command_line().GetSwitchValueASCII(switches::kLoginProfile); | 
|  544     user_manager->UserLoggedIn(username, username_hash, true); |  546     user_manager->UserLoggedIn(username, username_hash, true); | 
|  545     VLOG(1) << "Relaunching browser for user: " << username |  547     VLOG(1) << "Relaunching browser for user: " << username | 
|  546             << " with hash: " << username_hash; |  548             << " with hash: " << username_hash; | 
|  547   } |  549   } | 
|  548 } |  550 } | 
|  549  |  551  | 
 |  552 class GuestLanguageSetCallbackData { | 
 |  553  public: | 
 |  554   explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { | 
 |  555   } | 
 |  556  | 
 |  557   // must match SwitchLanguageCallback type. | 
 |  558   static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, | 
 |  559                        const std::string& locale, | 
 |  560                        const std::string& loaded_locale, | 
 |  561                        bool success); | 
 |  562  | 
 |  563   Profile* profile; | 
 |  564 }; | 
 |  565  | 
 |  566 // static | 
 |  567 void GuestLanguageSetCallbackData::Callback( | 
 |  568     const scoped_ptr<GuestLanguageSetCallbackData>& self, | 
 |  569     const std::string& locale, | 
 |  570     const std::string& loaded_locale, | 
 |  571     bool success) { | 
 |  572   input_method::InputMethodManager* const ime_manager = | 
 |  573       input_method::InputMethodManager::Get(); | 
 |  574   // Active layout must be hardware "login layout". | 
 |  575   // The previous one must be "locale default layout". | 
 |  576   const std::string login_im = | 
 |  577       ime_manager->GetInputMethodUtil()->GetHardwareLoginInputMethodId(); | 
 |  578   ime_manager->ChangeInputMethod(login_im); | 
 |  579  | 
 |  580   const std::string locale_default_input_method = | 
 |  581       ime_manager->GetInputMethodUtil()->GetLanguageDefaultInputMethodId( | 
 |  582           loaded_locale); | 
 |  583   if (!locale_default_input_method.empty()) { | 
 |  584     PrefService* user_prefs = self->profile->GetPrefs(); | 
 |  585     user_prefs->SetString(prefs::kLanguagePreviousInputMethod, | 
 |  586                           locale_default_input_method); | 
 |  587   } | 
 |  588 } | 
 |  589  | 
 |  590 void SetGuestLocale(UserManager* const usermanager, Profile* const profile) { | 
 |  591   scoped_ptr<GuestLanguageSetCallbackData> data( | 
 |  592       new GuestLanguageSetCallbackData(profile)); | 
 |  593   scoped_ptr<locale_util::SwitchLanguageCallback> callback( | 
 |  594       new locale_util::SwitchLanguageCallback(base::Bind( | 
 |  595           &GuestLanguageSetCallbackData::Callback, base::Passed(data.Pass())))); | 
 |  596   User* const user = usermanager->GetUserByProfile(profile); | 
 |  597   usermanager->RespectLocalePreference(profile, user, callback.Pass()); | 
 |  598 } | 
 |  599  | 
|  550 void ChromeBrowserMainPartsChromeos::PostProfileInit() { |  600 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 
|  551   // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |  601   // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | 
|  552   // -- just after CreateProfile(). |  602   // -- just after CreateProfile(). | 
|  553  |  603  | 
|  554   // Restarting Chrome inside existing user session. Possible cases: |  604   // Restarting Chrome inside existing user session. Possible cases: | 
|  555   // 1. Chrome is restarted after crash. |  605   // 1. Chrome is restarted after crash. | 
|  556   // 2. Chrome is started in browser_tests skipping the login flow |  606   // 2. Chrome is started in browser_tests skipping the login flow | 
|  557   // 3. Chrome is started on dev machine |  607   // 3. Chrome is started on dev machine | 
|  558   //    i.e. not on Chrome OS device w/o login flow. |  608   //    i.e. not on Chrome OS device w/o login flow. | 
|  559   if (parsed_command_line().HasSwitch(switches::kLoginUser) && |  609   if (parsed_command_line().HasSwitch(switches::kLoginUser) && | 
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  596       detector->Enable(true); |  646       detector->Enable(true); | 
|  597   } |  647   } | 
|  598  |  648  | 
|  599   // Tests should be able to tune login manager before showing it. |  649   // Tests should be able to tune login manager before showing it. | 
|  600   // Thus only show login manager in normal (non-testing) mode. |  650   // Thus only show login manager in normal (non-testing) mode. | 
|  601   if (!parameters().ui_task || |  651   if (!parameters().ui_task || | 
|  602       parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { |  652       parsed_command_line().HasSwitch(switches::kForceLoginManagerInTests)) { | 
|  603     OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); |  653     OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | 
|  604   } |  654   } | 
|  605  |  655  | 
 |  656   // Guest user profile is never initialized with locale settings, | 
 |  657   // so we need special handling for Guest session. | 
 |  658   UserManager* const usermanager = UserManager::Get(); | 
 |  659   if (usermanager->IsUserLoggedIn() && usermanager->IsLoggedInAsGuest()) { | 
 |  660     SetGuestLocale(usermanager, profile()); | 
 |  661   } | 
 |  662  | 
|  606   // These observers must be initialized after the profile because |  663   // These observers must be initialized after the profile because | 
|  607   // they use the profile to dispatch extension events. |  664   // they use the profile to dispatch extension events. | 
|  608   extension_system_event_observer_.reset(new ExtensionSystemEventObserver()); |  665   extension_system_event_observer_.reset(new ExtensionSystemEventObserver()); | 
|  609   if (KioskModeSettings::Get()->IsKioskModeEnabled()) { |  666   if (KioskModeSettings::Get()->IsKioskModeEnabled()) { | 
|  610     retail_mode_power_save_blocker_ = content::PowerSaveBlocker::Create( |  667     retail_mode_power_save_blocker_ = content::PowerSaveBlocker::Create( | 
|  611         content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, |  668         content::PowerSaveBlocker::kPowerSaveBlockPreventDisplaySleep, | 
|  612         "Retail mode"); |  669         "Retail mode"); | 
|  613   } |  670   } | 
|  614  |  671  | 
|  615   peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); |  672   peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); | 
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
|  760   // Destroy DBus services immediately after threads are stopped. |  817   // Destroy DBus services immediately after threads are stopped. | 
|  761   dbus_services_.reset(); |  818   dbus_services_.reset(); | 
|  762  |  819  | 
|  763   ChromeBrowserMainPartsLinux::PostDestroyThreads(); |  820   ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 
|  764  |  821  | 
|  765   // Destroy DeviceSettingsService after g_browser_process. |  822   // Destroy DeviceSettingsService after g_browser_process. | 
|  766   DeviceSettingsService::Shutdown(); |  823   DeviceSettingsService::Shutdown(); | 
|  767 } |  824 } | 
|  768  |  825  | 
|  769 }  //  namespace chromeos |  826 }  //  namespace chromeos | 
| OLD | NEW |