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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
78 #include "chrome/common/chrome_version_info.h" | 78 #include "chrome/common/chrome_version_info.h" |
79 #include "chrome/common/logging_chrome.h" | 79 #include "chrome/common/logging_chrome.h" |
80 #include "chrome/common/pref_names.h" | 80 #include "chrome/common/pref_names.h" |
81 #include "chromeos/chromeos_switches.h" | 81 #include "chromeos/chromeos_switches.h" |
82 #include "chromeos/cryptohome/async_method_caller.h" | 82 #include "chromeos/cryptohome/async_method_caller.h" |
83 #include "chromeos/dbus/dbus_thread_manager.h" | 83 #include "chromeos/dbus/dbus_thread_manager.h" |
84 #include "chromeos/dbus/power_manager_client.h" | 84 #include "chromeos/dbus/power_manager_client.h" |
85 #include "chromeos/dbus/session_manager_client.h" | 85 #include "chromeos/dbus/session_manager_client.h" |
86 #include "chromeos/disks/disk_mount_manager.h" | 86 #include "chromeos/disks/disk_mount_manager.h" |
87 #include "chromeos/display/output_configurator.h" | 87 #include "chromeos/display/output_configurator.h" |
| 88 #include "chromeos/network/network_change_notifier_chromeos.h" |
| 89 #include "chromeos/network/network_change_notifier_factory_chromeos.h" |
88 #include "chromeos/network/network_configuration_handler.h" | 90 #include "chromeos/network/network_configuration_handler.h" |
89 #include "chromeos/network/network_event_log.h" | 91 #include "chromeos/network/network_event_log.h" |
90 #include "chromeos/network/network_state_handler.h" | 92 #include "chromeos/network/network_state_handler.h" |
91 #include "chromeos/power/power_state_override.h" | 93 #include "chromeos/power/power_state_override.h" |
92 #include "content/public/browser/notification_service.h" | 94 #include "content/public/browser/notification_service.h" |
93 #include "content/public/common/main_function_params.h" | 95 #include "content/public/common/main_function_params.h" |
94 #include "grit/platform_locale_settings.h" | 96 #include "grit/platform_locale_settings.h" |
95 #include "net/base/network_change_notifier.h" | 97 #include "net/base/network_change_notifier.h" |
96 #include "net/url_request/url_request.h" | 98 #include "net/url_request/url_request.h" |
97 | 99 |
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
247 CrosDBusService::Initialize(); | 249 CrosDBusService::Initialize(); |
248 | 250 |
249 // This function and SystemKeyEventListener use InputMethodManager. | 251 // This function and SystemKeyEventListener use InputMethodManager. |
250 chromeos::input_method::Initialize(); | 252 chromeos::input_method::Initialize(); |
251 disks::DiskMountManager::Initialize(); | 253 disks::DiskMountManager::Initialize(); |
252 cryptohome::AsyncMethodCaller::Initialize(); | 254 cryptohome::AsyncMethodCaller::Initialize(); |
253 | 255 |
254 // Initialize the network change notifier for Chrome OS. The network | 256 // Initialize the network change notifier for Chrome OS. The network |
255 // change notifier starts to monitor changes from the power manager and | 257 // change notifier starts to monitor changes from the power manager and |
256 // the network manager. | 258 // the network manager. |
257 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); | 259 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 260 chromeos::switches::kEnableNewNetworkHandlers)) { |
| 261 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); |
| 262 } |
258 | 263 |
259 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade | 264 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade |
260 // detector starts to monitor changes from the update engine. | 265 // detector starts to monitor changes from the update engine. |
261 UpgradeDetectorChromeos::GetInstance()->Init(); | 266 UpgradeDetectorChromeos::GetInstance()->Init(); |
262 | 267 |
263 if (base::chromeos::IsRunningOnChromeOS()) { | 268 if (base::chromeos::IsRunningOnChromeOS()) { |
264 // Disable Num Lock on X start up for http://crosbug.com/29169. | 269 // Disable Num Lock on X start up for http://crosbug.com/29169. |
265 input_method::GetInputMethodManager()->GetXKeyboard()-> | 270 input_method::GetInputMethodManager()->GetXKeyboard()-> |
266 SetNumLockEnabled(false); | 271 SetNumLockEnabled(false); |
267 } | 272 } |
(...skipping 12 matching lines...) Expand all Loading... |
280 // longer required. (Switch is set in about_flags.cc and not applied until | 285 // longer required. (Switch is set in about_flags.cc and not applied until |
281 // after DBusServices() is called). | 286 // after DBusServices() is called). |
282 void InitializeNetworkHandlers() { | 287 void InitializeNetworkHandlers() { |
283 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 288 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
284 chromeos::switches::kEnableNewNetworkHandlers)) | 289 chromeos::switches::kEnableNewNetworkHandlers)) |
285 return; | 290 return; |
286 chromeos::network_event_log::Initialize(); | 291 chromeos::network_event_log::Initialize(); |
287 chromeos::NetworkStateHandler::Initialize(); | 292 chromeos::NetworkStateHandler::Initialize(); |
288 chromeos::NetworkConfigurationHandler::Initialize(); | 293 chromeos::NetworkConfigurationHandler::Initialize(); |
289 network_handlers_initialized_ = true; | 294 network_handlers_initialized_ = true; |
| 295 // TODO(gauravsh): This needs re-factoring. NetworkChangeNotifier choice |
| 296 // needs to be made before about:flags are processed. |
| 297 NetworkChangeNotifierFactoryChromeos::GetInstance()->Initialize(); |
290 } | 298 } |
291 | 299 |
292 ~DBusServices() { | 300 ~DBusServices() { |
293 // CrosLibrary is shut down before DBusThreadManager even though it | 301 // CrosLibrary is shut down before DBusThreadManager even though it |
294 // is initialized first becuase some of its libraries depend on DBus | 302 // is initialized first becuase some of its libraries depend on DBus |
295 // clients. | 303 // clients. |
296 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. | 304 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. |
297 // (crosbug.com/26160) | 305 // (crosbug.com/26160) |
298 if (cros_initialized_ && CrosLibrary::Get()) | 306 if (cros_initialized_ && CrosLibrary::Get()) |
299 CrosLibrary::Shutdown(); | 307 CrosLibrary::Shutdown(); |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
375 // channel info is read and made available early. | 383 // channel info is read and made available early. |
376 system::StatisticsProvider::GetInstance()->Init(); | 384 system::StatisticsProvider::GetInstance()->Init(); |
377 | 385 |
378 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 386 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
379 } | 387 } |
380 | 388 |
381 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 389 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
382 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 390 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
383 // implementation. This must be done before BrowserMainLoop calls | 391 // implementation. This must be done before BrowserMainLoop calls |
384 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). | 392 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). |
385 net::NetworkChangeNotifier::SetFactory( | 393 net::NetworkChangeNotifierFactory* network_change_factory; |
386 new CrosNetworkChangeNotifierFactory()); | 394 // Note: At the time this is called, we have not processed about:flags |
387 | 395 // so this requires that the network handler flag was passed in at the command |
| 396 // line. |
| 397 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
| 398 chromeos::switches::kEnableNewNetworkHandlers)) { |
| 399 network_change_factory = new CrosNetworkChangeNotifierFactory(); |
| 400 } else { |
| 401 LOG(WARNING) << "Using new connection change notifier."; |
| 402 network_change_factory = new NetworkChangeNotifierFactoryChromeos(); |
| 403 } |
| 404 net::NetworkChangeNotifier::SetFactory(network_change_factory); |
388 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | 405 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
389 } | 406 } |
390 | 407 |
391 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 408 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
392 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 409 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
393 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 410 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
394 | 411 |
395 dbus_services_.reset(new internal::DBusServices(parameters())); | 412 dbus_services_.reset(new internal::DBusServices(parameters())); |
396 | 413 |
397 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | 414 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
398 } | 415 } |
399 | 416 |
400 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. | 417 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. |
401 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. | 418 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. |
402 | |
403 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 419 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
404 // Must be called after about_flags settings are applied (see note above). | 420 // Must be called after about_flags settings are applied (see note above). |
405 dbus_services_->InitializeNetworkHandlers(); | 421 dbus_services_->InitializeNetworkHandlers(); |
406 | 422 |
407 AudioHandler::Initialize(); | 423 AudioHandler::Initialize(); |
408 imageburner::BurnManager::Initialize(); | 424 imageburner::BurnManager::Initialize(); |
409 | 425 |
410 // Listen for system key events so that the user will be able to adjust the | 426 // Listen for system key events so that the user will be able to adjust the |
411 // volume on the login screen, if Chrome is running on Chrome OS | 427 // volume on the login screen, if Chrome is running on Chrome OS |
412 // (i.e. not Linux desktop), and in non-test mode. | 428 // (i.e. not Linux desktop), and in non-test mode. |
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 650 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
635 // stops monitoring changes from the update engine. | 651 // stops monitoring changes from the update engine. |
636 if (UpgradeDetectorChromeos::GetInstance()) | 652 if (UpgradeDetectorChromeos::GetInstance()) |
637 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | 653 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
638 | 654 |
639 // Shutdown the network change notifier for Chrome OS. The network | 655 // Shutdown the network change notifier for Chrome OS. The network |
640 // change notifier stops monitoring changes from the power manager and | 656 // change notifier stops monitoring changes from the power manager and |
641 // the network manager. | 657 // the network manager. |
642 if (CrosNetworkChangeNotifierFactory::GetInstance()) | 658 if (CrosNetworkChangeNotifierFactory::GetInstance()) |
643 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | 659 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
| 660 if (NetworkChangeNotifierFactoryChromeos::GetInstance()) |
| 661 NetworkChangeNotifierFactoryChromeos::GetInstance()->Shutdown(); |
644 | 662 |
645 if (chromeos::NetworkPortalDetector::IsEnabled() && | 663 if (chromeos::NetworkPortalDetector::IsEnabled() && |
646 chromeos::NetworkPortalDetector::GetInstance()) { | 664 chromeos::NetworkPortalDetector::GetInstance()) { |
647 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); | 665 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); |
648 } | 666 } |
649 | 667 |
650 // Tell DeviceSettingsService to stop talking to session_manager. | 668 // Tell DeviceSettingsService to stop talking to session_manager. |
651 DeviceSettingsService::Get()->Shutdown(); | 669 DeviceSettingsService::Get()->Shutdown(); |
652 | 670 |
653 // We should remove observers attached to D-Bus clients before | 671 // We should remove observers attached to D-Bus clients before |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
736 } else if (trial->group() == margin_200mb) { | 754 } else if (trial->group() == margin_200mb) { |
737 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 755 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
738 LowMemoryObserver::SetLowMemoryMargin(200); | 756 LowMemoryObserver::SetLowMemoryMargin(200); |
739 } else { | 757 } else { |
740 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 758 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
741 } | 759 } |
742 } | 760 } |
743 } | 761 } |
744 | 762 |
745 } // namespace chromeos | 763 } // namespace chromeos |
OLD | NEW |