| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/callback.h" | 8 #include "base/callback.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/lazy_instance.h" | 10 #include "base/lazy_instance.h" |
| 11 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 12 #include "base/string_number_conversions.h" | |
| 13 #include "chrome/browser/browser_process_impl.h" | |
| 14 #include "chrome/browser/chromeos/accessibility/system_event_observer.h" | 12 #include "chrome/browser/chromeos/accessibility/system_event_observer.h" |
| 15 #include "chrome/browser/chromeos/audio_handler.h" | |
| 16 #include "chrome/browser/chromeos/audio_handler.h" | |
| 17 #include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" | 13 #include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" |
| 18 #include "chrome/browser/chromeos/boot_times_loader.h" | 14 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 19 #include "chrome/browser/chromeos/boot_times_loader.h" | |
| 20 #include "chrome/browser/chromeos/brightness_observer.h" | 15 #include "chrome/browser/chromeos/brightness_observer.h" |
| 21 #include "chrome/browser/chromeos/cros/cros_library.h" | 16 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 22 #include "chrome/browser/chromeos/cros/cros_library.h" | |
| 23 #include "chrome/browser/chromeos/cros/screen_lock_library.h" | |
| 24 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 17 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 25 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 18 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
| 26 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 19 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
| 27 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" | 20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" |
| 28 #include "chrome/browser/chromeos/external_metrics.h" | |
| 29 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 21 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
| 30 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 22 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 31 #include "chrome/browser/chromeos/login/authenticator.h" | |
| 32 #include "chrome/browser/chromeos/login/login_utils.h" | |
| 33 #include "chrome/browser/chromeos/login/ownership_service.h" | |
| 34 #include "chrome/browser/chromeos/login/screen_locker.h" | |
| 35 #include "chrome/browser/chromeos/login/session_manager_observer.h" | 23 #include "chrome/browser/chromeos/login/session_manager_observer.h" |
| 36 #include "chrome/browser/chromeos/login/user_manager.h" | |
| 37 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 24 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
| 38 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" | 25 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" |
| 39 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" | |
| 40 #include "chrome/browser/chromeos/system/runtime_environment.h" | 26 #include "chrome/browser/chromeos/system/runtime_environment.h" |
| 41 #include "chrome/browser/chromeos/system/statistics_provider.h" | 27 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 42 #include "chrome/browser/chromeos/system_key_event_listener.h" | |
| 43 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" | 28 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" |
| 44 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" | |
| 45 #include "chrome/browser/defaults.h" | 29 #include "chrome/browser/defaults.h" |
| 46 #include "chrome/browser/metrics/metrics_service.h" | |
| 47 #include "chrome/browser/oom_priority_manager.h" | |
| 48 #include "chrome/browser/policy/browser_policy_connector.h" | |
| 49 #include "chrome/browser/profiles/profile.h" | |
| 50 #include "chrome/browser/profiles/profile_manager.h" | |
| 51 #include "chrome/browser/ui/views/browser_dialogs.h" | |
| 52 #include "chrome/common/chrome_switches.h" | 30 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/logging_chrome.h" | |
| 54 #include "content/public/common/main_function_params.h" | 31 #include "content/public/common/main_function_params.h" |
| 55 #include "grit/platform_locale_settings.h" | |
| 56 #include "net/base/network_change_notifier.h" | 32 #include "net/base/network_change_notifier.h" |
| 57 #include "net/url_request/url_request.h" | |
| 58 #include "ui/base/l10n/l10n_util.h" | |
| 59 | 33 |
| 60 #if defined(TOOLKIT_USES_GTK) | 34 #if defined(TOOLKIT_USES_GTK) |
| 61 #include <gtk/gtk.h> | 35 #include <gtk/gtk.h> |
| 62 #endif | 36 #endif |
| 63 | 37 |
| 64 #if defined(USE_AURA) | 38 #if defined(USE_AURA) |
| 65 #include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_o
bserver.h" | 39 #include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_o
bserver.h" |
| 66 #endif | 40 #endif |
| 67 | 41 |
| 68 class MessageLoopObserver : public MessageLoopForUI::Observer { | 42 class MessageLoopObserver : public MessageLoopForUI::Observer { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 101 } | 75 } |
| 102 | 76 |
| 103 virtual void DidProcessEvent(GdkEvent* event) { | 77 virtual void DidProcessEvent(GdkEvent* event) { |
| 104 } | 78 } |
| 105 #endif | 79 #endif |
| 106 }; | 80 }; |
| 107 | 81 |
| 108 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = | 82 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = |
| 109 LAZY_INSTANCE_INITIALIZER; | 83 LAZY_INSTANCE_INITIALIZER; |
| 110 | 84 |
| 111 // Login ----------------------------------------------------------------------- | |
| 112 | |
| 113 // Class is used to login using passed username and password. | |
| 114 // The instance will be deleted upon success or failure. | |
| 115 class StubLogin : public chromeos::LoginStatusConsumer, | |
| 116 public chromeos::LoginUtils::Delegate { | |
| 117 public: | |
| 118 StubLogin(std::string username, std::string password) | |
| 119 : pending_requests_(false), | |
| 120 profile_prepared_(false) { | |
| 121 authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this); | |
| 122 authenticator_.get()->AuthenticateToLogin( | |
| 123 g_browser_process->profile_manager()->GetDefaultProfile(), | |
| 124 username, | |
| 125 password, | |
| 126 std::string(), | |
| 127 std::string()); | |
| 128 } | |
| 129 | |
| 130 ~StubLogin() { | |
| 131 chromeos::LoginUtils::Get()->DelegateDeleted(this); | |
| 132 } | |
| 133 | |
| 134 void OnLoginFailure(const chromeos::LoginFailure& error) { | |
| 135 LOG(ERROR) << "Login Failure: " << error.GetErrorString(); | |
| 136 delete this; | |
| 137 } | |
| 138 | |
| 139 void OnLoginSuccess(const std::string& username, | |
| 140 const std::string& password, | |
| 141 const GaiaAuthConsumer::ClientLoginResult& credentials, | |
| 142 bool pending_requests, | |
| 143 bool using_oauth) { | |
| 144 pending_requests_ = pending_requests; | |
| 145 if (!profile_prepared_) { | |
| 146 // Will call OnProfilePrepared in the end. | |
| 147 chromeos::LoginUtils::Get()->PrepareProfile(username, | |
| 148 password, | |
| 149 credentials, | |
| 150 pending_requests, | |
| 151 using_oauth, | |
| 152 false, | |
| 153 this); | |
| 154 } else if (!pending_requests) { | |
| 155 delete this; | |
| 156 } | |
| 157 } | |
| 158 | |
| 159 // LoginUtils::Delegate implementation: | |
| 160 virtual void OnProfilePrepared(Profile* profile) { | |
| 161 profile_prepared_ = true; | |
| 162 chromeos::LoginUtils::DoBrowserLaunch(profile, NULL); | |
| 163 if (!pending_requests_) | |
| 164 delete this; | |
| 165 } | |
| 166 | |
| 167 scoped_refptr<chromeos::Authenticator> authenticator_; | |
| 168 bool pending_requests_; | |
| 169 bool profile_prepared_; | |
| 170 }; | |
| 171 | |
| 172 // Allows authenticator to be invoked without adding refcounting. The instances | |
| 173 // will delete themselves upon completion. | |
| 174 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); | |
| 175 | |
| 176 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, | |
| 177 Profile* profile) { | |
| 178 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { | |
| 179 std::string first_screen = | |
| 180 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen); | |
| 181 std::string size_arg = | |
| 182 parsed_command_line.GetSwitchValueASCII( | |
| 183 switches::kLoginScreenSize); | |
| 184 gfx::Size size(0, 0); | |
| 185 // Allow the size of the login window to be set explicitly. If not set, | |
| 186 // default to the entire screen. This is mostly useful for testing. | |
| 187 if (size_arg.size()) { | |
| 188 std::vector<std::string> dimensions; | |
| 189 base::SplitString(size_arg, ',', &dimensions); | |
| 190 if (dimensions.size() == 2) { | |
| 191 int width, height; | |
| 192 if (base::StringToInt(dimensions[0], &width) && | |
| 193 base::StringToInt(dimensions[1], &height)) | |
| 194 size.SetSize(width, height); | |
| 195 } | |
| 196 } | |
| 197 browser::ShowLoginWizard(first_screen, size); | |
| 198 } else if (parsed_command_line.HasSwitch(switches::kLoginUser) && | |
| 199 parsed_command_line.HasSwitch(switches::kLoginPassword)) { | |
| 200 chromeos::BootTimesLoader::Get()->RecordLoginAttempted(); | |
| 201 new StubLogin( | |
| 202 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), | |
| 203 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); | |
| 204 } else { | |
| 205 if (!parsed_command_line.HasSwitch(switches::kTestName)) { | |
| 206 // We did not log in (we crashed or are debugging), so we need to | |
| 207 // set the user name for sync. | |
| 208 chromeos::LoginUtils::Get()->RestoreAuthenticationSession( | |
| 209 chromeos::UserManager::Get()->logged_in_user().email(), profile); | |
| 210 } | |
| 211 } | |
| 212 } | |
| 213 | |
| 214 // ChromeBrowserMainPartsChromeos ---------------------------------------------- | |
| 215 | |
| 216 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 85 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
| 217 const content::MainFunctionParams& parameters) | 86 const content::MainFunctionParams& parameters) |
| 218 : ChromeBrowserMainPartsLinux(parameters) { | 87 : ChromeBrowserMainPartsLinux(parameters) { |
| 219 } | 88 } |
| 220 | 89 |
| 221 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 90 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
| 222 chromeos::disks::DiskMountManager::Shutdown(); | 91 chromeos::disks::DiskMountManager::Shutdown(); |
| 223 | 92 |
| 224 chromeos::DBusThreadManager::Shutdown(); | 93 chromeos::DBusThreadManager::Shutdown(); |
| 225 | 94 |
| 226 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 95 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
| 227 chromeos::CrosLibrary::Shutdown(); | 96 chromeos::CrosLibrary::Shutdown(); |
| 228 | 97 |
| 229 // To be precise, logout (browser shutdown) is not yet done, but the | 98 // To be precise, logout (browser shutdown) is not yet done, but the |
| 230 // remaining work is negligible, hence we say LogoutDone here. | 99 // remaining work is negligible, hence we say LogoutDone here. |
| 231 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 100 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
| 232 false); | 101 false); |
| 233 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 102 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
| 234 } | 103 } |
| 235 | 104 |
| 236 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- | |
| 237 | |
| 238 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 105 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
| 106 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
| 239 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 107 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
| 240 // Disable sync and extensions if we're in "browse without sign-in" mode. | 108 // Disable sync and extensions if we're in "browse without sign-in" mode. |
| 241 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 109 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
| 242 singleton_command_line->AppendSwitch(switches::kDisableSync); | 110 singleton_command_line->AppendSwitch(switches::kDisableSync); |
| 243 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 111 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
| 244 browser_defaults::bookmarks_enabled = false; | 112 browser_defaults::bookmarks_enabled = false; |
| 245 } | 113 } |
| 246 | |
| 247 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | |
| 248 } | 114 } |
| 249 | 115 |
| 250 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 116 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 117 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
| 251 // Initialize CrosLibrary only for the browser, unless running tests | 118 // Initialize CrosLibrary only for the browser, unless running tests |
| 252 // (which do their own CrosLibrary setup). | 119 // (which do their own CrosLibrary setup). |
| 253 if (!parameters().ui_task) { | 120 if (!parameters().ui_task) { |
| 254 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); | 121 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); |
| 255 chromeos::CrosLibrary::Initialize(use_stub); | 122 chromeos::CrosLibrary::Initialize(use_stub); |
| 256 } | 123 } |
| 257 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 124 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
| 258 // implementation. | 125 // implementation. |
| 259 net::NetworkChangeNotifier::SetFactory( | 126 net::NetworkChangeNotifier::SetFactory( |
| 260 new chromeos::CrosNetworkChangeNotifierFactory()); | 127 new chromeos::CrosNetworkChangeNotifierFactory()); |
| 261 | |
| 262 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | |
| 263 } | 128 } |
| 264 | 129 |
| 265 void ChromeBrowserMainPartsChromeos::PreProfileInit() { | 130 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
| 266 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | |
| 267 // -- immediately before Profile creation(). | |
| 268 | |
| 269 // Now that the file thread exists we can record our stats. | |
| 270 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); | |
| 271 | |
| 272 #if defined(TOOLKIT_USES_GTK) | |
| 273 // Read locale-specific GTK resource information. | |
| 274 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); | |
| 275 if (!gtkrc.empty()) | |
| 276 gtk_rc_parse_string(gtkrc.c_str()); | |
| 277 #else | |
| 278 // TODO(saintlou): Need to provide an Aura equivalent. | |
| 279 NOTIMPLEMENTED(); | |
| 280 #endif | |
| 281 | |
| 282 // Trigger prefetching of ownership status. | |
| 283 chromeos::OwnershipService::GetSharedInstance()->Prewarm(); | |
| 284 | |
| 285 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | |
| 286 // -- just before CreateProfile(). | |
| 287 | |
| 288 // This forces the ProfileManager to be created and register for the | |
| 289 // notification it needs to track the logged in user. | |
| 290 g_browser_process->profile_manager(); | |
| 291 | |
| 292 // TODO(abarth): Should this move to InitializeNetworkOptions()? | |
| 293 // Allow access to file:// on ChromeOS for tests. | |
| 294 if (parsed_command_line().HasSwitch(switches::kAllowFileAccess)) | |
| 295 net::URLRequest::AllowFileAccess(); | |
| 296 | |
| 297 // There are two use cases for kLoginUser: | |
| 298 // 1) if passed in tandem with kLoginPassword, to drive a "StubLogin" | |
| 299 // 2) if passed alone, to signal that the indicated user has already | |
| 300 // logged in and we should behave accordingly. | |
| 301 // This handles case 2. | |
| 302 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | |
| 303 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | |
| 304 std::string username = | |
| 305 parsed_command_line().GetSwitchValueASCII(switches::kLoginUser); | |
| 306 VLOG(1) << "Relaunching browser for user: " << username; | |
| 307 chromeos::UserManager::Get()->UserLoggedIn(username); | |
| 308 | |
| 309 // Redirects Chrome logging to the user data dir. | |
| 310 logging::RedirectChromeLogging(parsed_command_line()); | |
| 311 | |
| 312 // Initialize user policy before creating the profile so the profile | |
| 313 // initialization code sees policy settings. | |
| 314 g_browser_process->browser_policy_connector()->InitializeUserPolicy( | |
| 315 username, false /* wait_for_policy_fetch */); | |
| 316 } else if (parsed_command_line().HasSwitch(switches::kLoginManager)) { | |
| 317 // Initialize status area mode early on. | |
| 318 chromeos::StatusAreaViewChromeos:: | |
| 319 SetScreenMode(chromeos::StatusAreaViewChromeos::LOGIN_MODE_WEBUI); | |
| 320 } | |
| 321 | |
| 322 // In Aura builds this will initialize aura_shell::Shell. | |
| 323 ChromeBrowserMainPartsLinux::PreProfileInit(); | |
| 324 } | |
| 325 | |
| 326 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | |
| 327 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | |
| 328 // -- just after CreateProfile(). | |
| 329 | |
| 330 // Pass the TokenService pointer to the policy connector so user policy can | |
| 331 // grab a token and register with the policy server. | |
| 332 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. | |
| 333 if (parsed_command_line().HasSwitch(switches::kLoginUser) && | |
| 334 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { | |
| 335 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( | |
| 336 profile()->GetTokenService()); | |
| 337 } | |
| 338 | |
| 339 // Tests should be able to tune login manager before showing it. | |
| 340 // Thus only show login manager in normal (non-testing) mode. | |
| 341 if (!parameters().ui_task) | |
| 342 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); | |
| 343 | |
| 344 ChromeBrowserMainPartsLinux::PostProfileInit(); | |
| 345 } | |
| 346 | |
| 347 void ChromeBrowserMainPartsChromeos::PreBrowserStart() { | |
| 348 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | |
| 349 // -- just before MetricsService::LogNeedForCleanShutdown(). | |
| 350 | |
| 351 metrics()->StartExternalMetrics(); | |
| 352 | |
| 353 // Initialize the audio handler on ChromeOS. | |
| 354 chromeos::AudioHandler::Initialize(); | |
| 355 | |
| 356 // Listen for system key events so that the user will be able to adjust the | |
| 357 // volume on the login screen, if Chrome is running on Chrome OS | |
| 358 // (i.e. not Linux desktop), and in non-test mode. | |
| 359 if (chromeos::system::runtime_environment::IsRunningOnChromeOS() && | |
| 360 !parameters().ui_task) { // ui_task is non-NULL when running tests. | |
| 361 chromeos::SystemKeyEventListener::Initialize(); | |
| 362 } | |
| 363 | |
| 364 // Listen for XI_HierarchyChanged events. | |
| 365 chromeos::XInputHierarchyChangedEventListener::GetInstance(); | |
| 366 | |
| 367 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() | |
| 368 // -- immediately after ChildProcess::WaitForDebugger(). | |
| 369 | |
| 370 // Start the out-of-memory priority manager here so that we give the most | |
| 371 // amount of time for the other services to start up before we start | |
| 372 // adjusting the oom priority. | |
| 373 g_browser_process->oom_priority_manager()->Start(); | |
| 374 | |
| 375 ChromeBrowserMainPartsLinux::PreBrowserStart(); | |
| 376 } | |
| 377 | |
| 378 void ChromeBrowserMainPartsChromeos::PostBrowserStart() { | |
| 379 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). | 131 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). |
| 380 | 132 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); |
| 381 // Get the statistics provider instance here to start loading statistcs | 133 // Get the statistics provider instance here to start loading statistcs |
| 382 // on the background FILE thread. | 134 // on the background FILE thread. |
| 383 chromeos::system::StatisticsProvider::GetInstance(); | 135 chromeos::system::StatisticsProvider::GetInstance(); |
| 384 | 136 |
| 385 // Initialize the Chrome OS bluetooth subsystem. | 137 // Initialize the Chrome OS bluetooth subsystem. |
| 386 // We defer this to PreMainMessageLoopRun because we don't want to check the | 138 // We defer this to PreMainMessageLoopRun because we don't want to check the |
| 387 // parsed command line until after about_flags::ConvertFlagsToSwitches has | 139 // parsed command line until after about_flags::ConvertFlagsToSwitches has |
| 388 // been called. | 140 // been called. |
| 389 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove | 141 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove |
| 390 // the --enable-bluetooth flag. | 142 // the --enable-bluetooth flag. |
| 391 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { | 143 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { |
| 392 chromeos::BluetoothManager::Initialize(); | 144 chromeos::BluetoothManager::Initialize(); |
| 393 } | 145 } |
| 394 | |
| 395 ChromeBrowserMainPartsLinux::PostBrowserStart(); | |
| 396 } | 146 } |
| 397 | 147 |
| 398 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 148 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
| 149 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
| 399 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 150 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
| 400 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 151 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
| 401 | 152 |
| 402 // Initialize DBusThreadManager for the browser. This must be done after | 153 // Initialize DBusThreadManager for the browser. This must be done after |
| 403 // the main message loop is started, as it uses the message loop. | 154 // the main message loop is started, as it uses the message loop. |
| 404 chromeos::DBusThreadManager::Initialize(); | 155 chromeos::DBusThreadManager::Initialize(); |
| 405 | 156 |
| 406 // Initialize the brightness observer so that we'll display an onscreen | 157 // Initialize the brightness observer so that we'll display an onscreen |
| 407 // indication of brightness changes during login. | 158 // indication of brightness changes during login. |
| 408 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 159 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 438 #if defined(GOOGLE_CHROME_BUILD) | 189 #if defined(GOOGLE_CHROME_BUILD) |
| 439 chromeos::input_method::InputMethodManager::GetInstance()-> | 190 chromeos::input_method::InputMethodManager::GetInstance()-> |
| 440 GetXKeyboard()->SetNumLockEnabled(true); | 191 GetXKeyboard()->SetNumLockEnabled(true); |
| 441 #endif | 192 #endif |
| 442 | 193 |
| 443 #if defined(USE_AURA) | 194 #if defined(USE_AURA) |
| 444 initial_browser_window_observer_.reset( | 195 initial_browser_window_observer_.reset( |
| 445 new chromeos::InitialBrowserWindowObserver); | 196 new chromeos::InitialBrowserWindowObserver); |
| 446 #endif | 197 #endif |
| 447 } | 198 } |
| 448 | |
| 449 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | |
| 450 } | 199 } |
| 451 | 200 |
| 452 // Shut down services before the browser process, etc are destroyed. | 201 // Shut down services before the browser process, etc are destroyed. |
| 453 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { | 202 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
| 454 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", | 203 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); |
| 455 true); | |
| 456 | |
| 457 g_browser_process->oom_priority_manager()->Stop(); | |
| 458 | |
| 459 // The XInput2 event listener needs to be shut down earlier than when | |
| 460 // Singletons are finally destroyed in AtExitManager. | |
| 461 chromeos::XInputHierarchyChangedEventListener::GetInstance()->Stop(); | |
| 462 | |
| 463 // chromeos::SystemKeyEventListener::Shutdown() is always safe to call, | |
| 464 // even if Initialize() wasn't called. | |
| 465 chromeos::SystemKeyEventListener::Shutdown(); | |
| 466 chromeos::AudioHandler::Shutdown(); | |
| 467 | 204 |
| 468 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 205 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
| 469 // stops monitoring changes from the update engine. | 206 // stops monitoring changes from the update engine. |
| 470 if (UpgradeDetectorChromeos::GetInstance()) | 207 if (UpgradeDetectorChromeos::GetInstance()) |
| 471 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | 208 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
| 472 | 209 |
| 473 // Shutdown the network change notifier for Chrome OS. The network | 210 // Shutdown the network change notifier for Chrome OS. The network |
| 474 // change notifier stops monitoring changes from the power manager and | 211 // change notifier stops monitoring changes from the power manager and |
| 475 // the network manager. | 212 // the network manager. |
| 476 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) | 213 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) |
| 477 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | 214 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
| 478 | 215 |
| 479 // We should remove observers attached to D-Bus clients before | 216 // We should remove observers attached to D-Bus clients before |
| 480 // DBusThreadManager is shut down. | 217 // DBusThreadManager is shut down. |
| 481 if (session_manager_observer_.get()) { | 218 if (session_manager_observer_.get()) { |
| 482 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 219 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 483 RemoveObserver(session_manager_observer_.get()); | 220 RemoveObserver(session_manager_observer_.get()); |
| 484 } | 221 } |
| 485 if (brightness_observer_.get()) { | 222 if (brightness_observer_.get()) { |
| 486 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() | 223 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() |
| 487 ->RemoveObserver(brightness_observer_.get()); | 224 ->RemoveObserver(brightness_observer_.get()); |
| 488 } | 225 } |
| 489 | 226 |
| 490 // Shut these down here instead of in the destructor in case we exited before | 227 // Shut these down here instead of in the destructor in case we exited before |
| 491 // running BrowserMainLoop::RunMainMessageLoopParts() and never initialized | 228 // running BrowserMainLoop::RunMainMessageLoopParts() and never initialized |
| 492 // these. | 229 // these. |
| 493 chromeos::accessibility::SystemEventObserver::Shutdown(); | 230 chromeos::accessibility::SystemEventObserver::Shutdown(); |
| 494 chromeos::BluetoothManager::Shutdown(); | 231 chromeos::BluetoothManager::Shutdown(); |
| 495 | |
| 496 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); | |
| 497 } | 232 } |
| OLD | NEW |