OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/shell.h" | 10 #include "ash/shell.h" |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 #include "chrome/common/chrome_version_info.h" | 75 #include "chrome/common/chrome_version_info.h" |
76 #include "chrome/common/logging_chrome.h" | 76 #include "chrome/common/logging_chrome.h" |
77 #include "chrome/common/pref_names.h" | 77 #include "chrome/common/pref_names.h" |
78 #include "chromeos/chromeos_switches.h" | 78 #include "chromeos/chromeos_switches.h" |
79 #include "chromeos/cryptohome/async_method_caller.h" | 79 #include "chromeos/cryptohome/async_method_caller.h" |
80 #include "chromeos/dbus/dbus_thread_manager.h" | 80 #include "chromeos/dbus/dbus_thread_manager.h" |
81 #include "chromeos/dbus/power_manager_client.h" | 81 #include "chromeos/dbus/power_manager_client.h" |
82 #include "chromeos/dbus/session_manager_client.h" | 82 #include "chromeos/dbus/session_manager_client.h" |
83 #include "chromeos/disks/disk_mount_manager.h" | 83 #include "chromeos/disks/disk_mount_manager.h" |
84 #include "chromeos/display/output_configurator.h" | 84 #include "chromeos/display/output_configurator.h" |
| 85 #include "chromeos/network/connection_change_notifier_factory.h" |
85 #include "chromeos/network/network_event_log.h" | 86 #include "chromeos/network/network_event_log.h" |
86 #include "chromeos/network/network_state_handler.h" | 87 #include "chromeos/network/network_state_handler.h" |
87 #include "chromeos/power/power_state_override.h" | 88 #include "chromeos/power/power_state_override.h" |
88 #include "content/public/browser/notification_service.h" | 89 #include "content/public/browser/notification_service.h" |
89 #include "content/public/common/main_function_params.h" | 90 #include "content/public/common/main_function_params.h" |
90 #include "grit/platform_locale_settings.h" | 91 #include "grit/platform_locale_settings.h" |
91 #include "net/base/network_change_notifier.h" | 92 #include "net/base/network_change_notifier.h" |
92 #include "net/url_request/url_request.h" | 93 #include "net/url_request/url_request.h" |
93 | 94 |
94 namespace chromeos { | 95 namespace chromeos { |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 CrosDBusService::Initialize(); | 237 CrosDBusService::Initialize(); |
237 | 238 |
238 // This function and SystemKeyEventListener use InputMethodManager. | 239 // This function and SystemKeyEventListener use InputMethodManager. |
239 input_method::InputMethodManager::Initialize(); | 240 input_method::InputMethodManager::Initialize(); |
240 disks::DiskMountManager::Initialize(); | 241 disks::DiskMountManager::Initialize(); |
241 cryptohome::AsyncMethodCaller::Initialize(); | 242 cryptohome::AsyncMethodCaller::Initialize(); |
242 | 243 |
243 // Initialize the network change notifier for Chrome OS. The network | 244 // Initialize the network change notifier for Chrome OS. The network |
244 // change notifier starts to monitor changes from the power manager and | 245 // change notifier starts to monitor changes from the power manager and |
245 // the network manager. | 246 // the network manager. |
246 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); | 247 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 248 chromeos::switches::kEnableNewNetworkHandlers)) { |
| 249 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); |
| 250 } |
247 | 251 |
248 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade | 252 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade |
249 // detector starts to monitor changes from the update engine. | 253 // detector starts to monitor changes from the update engine. |
250 UpgradeDetectorChromeos::GetInstance()->Init(); | 254 UpgradeDetectorChromeos::GetInstance()->Init(); |
251 | 255 |
252 if (base::chromeos::IsRunningOnChromeOS()) { | 256 if (base::chromeos::IsRunningOnChromeOS()) { |
253 // Disable Num Lock on X start up for http://crosbug.com/29169. | 257 // Disable Num Lock on X start up for http://crosbug.com/29169. |
254 input_method::InputMethodManager::GetInstance()-> | 258 input_method::InputMethodManager::GetInstance()-> |
255 GetXKeyboard()->SetNumLockEnabled(false); | 259 GetXKeyboard()->SetNumLockEnabled(false); |
256 } | 260 } |
(...skipping 11 matching lines...) Expand all Loading... |
268 // TODO(stevenjb): Move this into DBusServices() once the switch is no | 272 // TODO(stevenjb): Move this into DBusServices() once the switch is no |
269 // longer required. (Switch is set in about_flags.cc and not applied until | 273 // longer required. (Switch is set in about_flags.cc and not applied until |
270 // after DBusServices() is called). | 274 // after DBusServices() is called). |
271 void InitializeNetworkHandlers() { | 275 void InitializeNetworkHandlers() { |
272 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 276 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
273 chromeos::switches::kEnableNewNetworkHandlers)) | 277 chromeos::switches::kEnableNewNetworkHandlers)) |
274 return; | 278 return; |
275 chromeos::network_event_log::Initialize(); | 279 chromeos::network_event_log::Initialize(); |
276 chromeos::NetworkStateHandler::Initialize(); | 280 chromeos::NetworkStateHandler::Initialize(); |
277 network_handlers_initialized_ = true; | 281 network_handlers_initialized_ = true; |
| 282 // TODO(gauravsh): This needs re-factoring. NetworkChangeNotifier choice |
| 283 // needs to be made before about:flags are processed. |
| 284 ConnectionChangeNotifierFactory::GetInstance()->Initialize(); |
278 } | 285 } |
279 | 286 |
280 ~DBusServices() { | 287 ~DBusServices() { |
281 // CrosLibrary is shut down before DBusThreadManager even though it | 288 // CrosLibrary is shut down before DBusThreadManager even though it |
282 // is initialized first becuase some of its libraries depend on DBus | 289 // is initialized first becuase some of its libraries depend on DBus |
283 // clients. | 290 // clients. |
284 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. | 291 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. |
285 // (crosbug.com/26160) | 292 // (crosbug.com/26160) |
286 if (cros_initialized_ && CrosLibrary::Get()) | 293 if (cros_initialized_ && CrosLibrary::Get()) |
287 CrosLibrary::Shutdown(); | 294 CrosLibrary::Shutdown(); |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
358 ::switches::kLoginProfile).value(); | 365 ::switches::kLoginProfile).value(); |
359 } | 366 } |
360 | 367 |
361 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 368 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
362 } | 369 } |
363 | 370 |
364 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 371 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
365 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 372 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
366 // implementation. This must be done before BrowserMainLoop calls | 373 // implementation. This must be done before BrowserMainLoop calls |
367 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). | 374 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). |
368 net::NetworkChangeNotifier::SetFactory( | 375 net::NetworkChangeNotifierFactory* network_change_factory; |
369 new CrosNetworkChangeNotifierFactory()); | 376 // Note: At the time this is called, we have not processed about:flags |
370 | 377 // so this requires that the network handler flag was passed in at the command |
| 378 // line. |
| 379 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 380 chromeos::switches::kEnableNewNetworkHandlers)) { |
| 381 network_change_factory = new CrosNetworkChangeNotifierFactory(); |
| 382 } else { |
| 383 LOG(ERROR) << "Using new connection change notifier."; |
| 384 network_change_factory = new ConnectionChangeNotifierFactory(); |
| 385 } |
| 386 net::NetworkChangeNotifier::SetFactory(network_change_factory); |
371 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | 387 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
372 } | 388 } |
373 | 389 |
374 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 390 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
375 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 391 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
376 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 392 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
377 | 393 |
378 dbus_services_.reset(new internal::DBusServices(parameters())); | 394 dbus_services_.reset(new internal::DBusServices(parameters())); |
379 | 395 |
380 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | 396 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
381 } | 397 } |
382 | 398 |
383 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. | 399 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. |
384 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. | 400 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. |
385 | |
386 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 401 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
387 // Must be called after about_flags settings are applied (see note above). | 402 // Must be called after about_flags settings are applied (see note above). |
388 dbus_services_->InitializeNetworkHandlers(); | 403 dbus_services_->InitializeNetworkHandlers(); |
389 | 404 |
390 AudioHandler::Initialize(); | 405 AudioHandler::Initialize(); |
391 imageburner::BurnManager::Initialize(); | 406 imageburner::BurnManager::Initialize(); |
392 | 407 |
393 // Listen for system key events so that the user will be able to adjust the | 408 // Listen for system key events so that the user will be able to adjust the |
394 // volume on the login screen, if Chrome is running on Chrome OS | 409 // volume on the login screen, if Chrome is running on Chrome OS |
395 // (i.e. not Linux desktop), and in non-test mode. | 410 // (i.e. not Linux desktop), and in non-test mode. |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
605 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 620 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
606 // stops monitoring changes from the update engine. | 621 // stops monitoring changes from the update engine. |
607 if (UpgradeDetectorChromeos::GetInstance()) | 622 if (UpgradeDetectorChromeos::GetInstance()) |
608 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | 623 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
609 | 624 |
610 // Shutdown the network change notifier for Chrome OS. The network | 625 // Shutdown the network change notifier for Chrome OS. The network |
611 // change notifier stops monitoring changes from the power manager and | 626 // change notifier stops monitoring changes from the power manager and |
612 // the network manager. | 627 // the network manager. |
613 if (CrosNetworkChangeNotifierFactory::GetInstance()) | 628 if (CrosNetworkChangeNotifierFactory::GetInstance()) |
614 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | 629 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
| 630 if (ConnectionChangeNotifierFactory::GetInstance()) |
| 631 ConnectionChangeNotifierFactory::GetInstance()->Shutdown(); |
615 | 632 |
616 if (chromeos::NetworkPortalDetector::IsEnabled() && | 633 if (chromeos::NetworkPortalDetector::IsEnabled() && |
617 chromeos::NetworkPortalDetector::GetInstance()) { | 634 chromeos::NetworkPortalDetector::GetInstance()) { |
618 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); | 635 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); |
619 } | 636 } |
620 | 637 |
621 // Tell DeviceSettingsService to stop talking to session_manager. | 638 // Tell DeviceSettingsService to stop talking to session_manager. |
622 DeviceSettingsService::Get()->Shutdown(); | 639 DeviceSettingsService::Get()->Shutdown(); |
623 | 640 |
624 // We should remove observers attached to D-Bus clients before | 641 // We should remove observers attached to D-Bus clients before |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
706 } else if (trial->group() == margin_200mb) { | 723 } else if (trial->group() == margin_200mb) { |
707 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 724 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
708 LowMemoryObserver::SetLowMemoryMargin(200); | 725 LowMemoryObserver::SetLowMemoryMargin(200); |
709 } else { | 726 } else { |
710 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 727 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
711 } | 728 } |
712 } | 729 } |
713 } | 730 } |
714 | 731 |
715 } // namespace chromeos | 732 } // namespace chromeos |
OLD | NEW |