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 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
84 #include "chromeos/disks/disk_mount_manager.h" | 84 #include "chromeos/disks/disk_mount_manager.h" |
85 #include "chromeos/display/output_configurator.h" | 85 #include "chromeos/display/output_configurator.h" |
86 #include "chromeos/network/network_configuration_handler.h" | 86 #include "chromeos/network/network_configuration_handler.h" |
87 #include "chromeos/network/network_event_log.h" | 87 #include "chromeos/network/network_event_log.h" |
88 #include "chromeos/network/network_state_handler.h" | 88 #include "chromeos/network/network_state_handler.h" |
89 #include "chromeos/power/power_state_override.h" | 89 #include "chromeos/power/power_state_override.h" |
90 #include "content/public/browser/notification_service.h" | 90 #include "content/public/browser/notification_service.h" |
91 #include "content/public/common/main_function_params.h" | 91 #include "content/public/common/main_function_params.h" |
92 #include "grit/platform_locale_settings.h" | 92 #include "grit/platform_locale_settings.h" |
93 #include "net/base/network_change_notifier.h" | 93 #include "net/base/network_change_notifier.h" |
94 #include "net/base/network_change_notifier_chromeos.h" | |
95 #include "net/base/network_change_notifier_factory_chromeos.h" | |
94 #include "net/url_request/url_request.h" | 96 #include "net/url_request/url_request.h" |
95 | 97 |
96 namespace chromeos { | 98 namespace chromeos { |
97 | 99 |
98 namespace { | 100 namespace { |
99 | 101 |
100 #if defined(USE_LINUX_BREAKPAD) | 102 #if defined(USE_LINUX_BREAKPAD) |
101 void ChromeOSVersionCallback(const std::string& version) { | 103 void ChromeOSVersionCallback(const std::string& version) { |
102 base::SetLinuxDistro(std::string("CrOS ") + version); | 104 base::SetLinuxDistro(std::string("CrOS ") + version); |
103 } | 105 } |
(...skipping 141 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
245 CrosDBusService::Initialize(); | 247 CrosDBusService::Initialize(); |
246 | 248 |
247 // This function and SystemKeyEventListener use InputMethodManager. | 249 // This function and SystemKeyEventListener use InputMethodManager. |
248 input_method::InputMethodManager::Initialize(); | 250 input_method::InputMethodManager::Initialize(); |
249 disks::DiskMountManager::Initialize(); | 251 disks::DiskMountManager::Initialize(); |
250 cryptohome::AsyncMethodCaller::Initialize(); | 252 cryptohome::AsyncMethodCaller::Initialize(); |
251 | 253 |
252 // Initialize the network change notifier for Chrome OS. The network | 254 // Initialize the network change notifier for Chrome OS. The network |
253 // change notifier starts to monitor changes from the power manager and | 255 // change notifier starts to monitor changes from the power manager and |
254 // the network manager. | 256 // the network manager. |
255 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); | 257 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
258 chromeos::switches::kEnableNewNetworkHandlers)) { | |
259 CrosNetworkChangeNotifierFactory::GetInstance()->Init(); | |
260 } | |
256 | 261 |
257 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade | 262 // Likewise, initialize the upgrade detector for Chrome OS. The upgrade |
258 // detector starts to monitor changes from the update engine. | 263 // detector starts to monitor changes from the update engine. |
259 UpgradeDetectorChromeos::GetInstance()->Init(); | 264 UpgradeDetectorChromeos::GetInstance()->Init(); |
260 | 265 |
261 if (base::chromeos::IsRunningOnChromeOS()) { | 266 if (base::chromeos::IsRunningOnChromeOS()) { |
262 // Disable Num Lock on X start up for http://crosbug.com/29169. | 267 // Disable Num Lock on X start up for http://crosbug.com/29169. |
263 input_method::InputMethodManager::GetInstance()-> | 268 input_method::InputMethodManager::GetInstance()-> |
264 GetXKeyboard()->SetNumLockEnabled(false); | 269 GetXKeyboard()->SetNumLockEnabled(false); |
265 } | 270 } |
(...skipping 12 matching lines...) Expand all Loading... | |
278 // longer required. (Switch is set in about_flags.cc and not applied until | 283 // longer required. (Switch is set in about_flags.cc and not applied until |
279 // after DBusServices() is called). | 284 // after DBusServices() is called). |
280 void InitializeNetworkHandlers() { | 285 void InitializeNetworkHandlers() { |
281 if (!CommandLine::ForCurrentProcess()->HasSwitch( | 286 if (!CommandLine::ForCurrentProcess()->HasSwitch( |
282 chromeos::switches::kEnableNewNetworkHandlers)) | 287 chromeos::switches::kEnableNewNetworkHandlers)) |
283 return; | 288 return; |
284 chromeos::network_event_log::Initialize(); | 289 chromeos::network_event_log::Initialize(); |
285 chromeos::NetworkStateHandler::Initialize(); | 290 chromeos::NetworkStateHandler::Initialize(); |
286 chromeos::NetworkConfigurationHandler::Initialize(); | 291 chromeos::NetworkConfigurationHandler::Initialize(); |
287 network_handlers_initialized_ = true; | 292 network_handlers_initialized_ = true; |
293 // TODO(gauravsh): This needs re-factoring. NetworkChangeNotifier choice | |
294 // needs to be made before about:flags are processed. | |
295 net::NetworkChangeNotifierFactoryChromeos::GetInstance()->Initialize(); | |
288 } | 296 } |
289 | 297 |
290 ~DBusServices() { | 298 ~DBusServices() { |
291 // CrosLibrary is shut down before DBusThreadManager even though it | 299 // CrosLibrary is shut down before DBusThreadManager even though it |
292 // is initialized first becuase some of its libraries depend on DBus | 300 // is initialized first becuase some of its libraries depend on DBus |
293 // clients. | 301 // clients. |
294 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. | 302 // TODO(hashimoto): Resolve this situation by removing CrosLibrary. |
295 // (crosbug.com/26160) | 303 // (crosbug.com/26160) |
296 if (cros_initialized_ && CrosLibrary::Get()) | 304 if (cros_initialized_ && CrosLibrary::Get()) |
297 CrosLibrary::Shutdown(); | 305 CrosLibrary::Shutdown(); |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
369 ::switches::kLoginProfile).value(); | 377 ::switches::kLoginProfile).value(); |
370 } | 378 } |
371 | 379 |
372 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | 380 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
373 } | 381 } |
374 | 382 |
375 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 383 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
376 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 384 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
377 // implementation. This must be done before BrowserMainLoop calls | 385 // implementation. This must be done before BrowserMainLoop calls |
378 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). | 386 // net::NetworkChangeNotifier::Create() in MainMessageLoopStart(). |
379 net::NetworkChangeNotifier::SetFactory( | 387 net::NetworkChangeNotifierFactory* network_change_factory; |
380 new CrosNetworkChangeNotifierFactory()); | 388 // Note: At the time this is called, we have not processed about:flags |
381 | 389 // so this requires that the network handler flag was passed in at the command |
390 // line. | |
391 if (!CommandLine::ForCurrentProcess()->HasSwitch( | |
392 chromeos::switches::kEnableNewNetworkHandlers)) { | |
393 network_change_factory = new CrosNetworkChangeNotifierFactory(); | |
394 } else { | |
395 LOG(ERROR) << "Using new connection change notifier."; | |
stevenjb
2012/12/13 19:28:22
Let's make this a WARNING instead of an ERROR, it
gauravsh
2012/12/15 00:42:45
Done.
| |
396 network_change_factory = new net::NetworkChangeNotifierFactoryChromeos(); | |
397 } | |
398 net::NetworkChangeNotifier::SetFactory(network_change_factory); | |
382 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | 399 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
383 } | 400 } |
384 | 401 |
385 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 402 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
386 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 403 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
387 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 404 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
388 | 405 |
389 dbus_services_.reset(new internal::DBusServices(parameters())); | 406 dbus_services_.reset(new internal::DBusServices(parameters())); |
390 | 407 |
391 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | 408 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
392 } | 409 } |
393 | 410 |
394 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. | 411 // Threads are initialized between MainMessageLoopStart and MainMessageLoopRun. |
395 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. | 412 // about_flags settings are applied in ChromeBrowserMainParts::PreCreateThreads. |
396 | |
397 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 413 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
398 // Must be called after about_flags settings are applied (see note above). | 414 // Must be called after about_flags settings are applied (see note above). |
399 dbus_services_->InitializeNetworkHandlers(); | 415 dbus_services_->InitializeNetworkHandlers(); |
400 | 416 |
401 AudioHandler::Initialize(); | 417 AudioHandler::Initialize(); |
402 imageburner::BurnManager::Initialize(); | 418 imageburner::BurnManager::Initialize(); |
403 | 419 |
404 // Listen for system key events so that the user will be able to adjust the | 420 // Listen for system key events so that the user will be able to adjust the |
405 // volume on the login screen, if Chrome is running on Chrome OS | 421 // volume on the login screen, if Chrome is running on Chrome OS |
406 // (i.e. not Linux desktop), and in non-test mode. | 422 // (i.e. not Linux desktop), and in non-test mode. |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 642 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
627 // stops monitoring changes from the update engine. | 643 // stops monitoring changes from the update engine. |
628 if (UpgradeDetectorChromeos::GetInstance()) | 644 if (UpgradeDetectorChromeos::GetInstance()) |
629 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | 645 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
630 | 646 |
631 // Shutdown the network change notifier for Chrome OS. The network | 647 // Shutdown the network change notifier for Chrome OS. The network |
632 // change notifier stops monitoring changes from the power manager and | 648 // change notifier stops monitoring changes from the power manager and |
633 // the network manager. | 649 // the network manager. |
634 if (CrosNetworkChangeNotifierFactory::GetInstance()) | 650 if (CrosNetworkChangeNotifierFactory::GetInstance()) |
635 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | 651 CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
652 if (net::NetworkChangeNotifierFactoryChromeos::GetInstance()) | |
653 net::NetworkChangeNotifierFactoryChromeos::GetInstance()->Shutdown(); | |
636 | 654 |
637 if (chromeos::NetworkPortalDetector::IsEnabled() && | 655 if (chromeos::NetworkPortalDetector::IsEnabled() && |
638 chromeos::NetworkPortalDetector::GetInstance()) { | 656 chromeos::NetworkPortalDetector::GetInstance()) { |
639 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); | 657 chromeos::NetworkPortalDetector::GetInstance()->Shutdown(); |
640 } | 658 } |
641 | 659 |
642 // Tell DeviceSettingsService to stop talking to session_manager. | 660 // Tell DeviceSettingsService to stop talking to session_manager. |
643 DeviceSettingsService::Get()->Shutdown(); | 661 DeviceSettingsService::Get()->Shutdown(); |
644 | 662 |
645 // We should remove observers attached to D-Bus clients before | 663 // We should remove observers attached to D-Bus clients before |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
728 } else if (trial->group() == margin_200mb) { | 746 } else if (trial->group() == margin_200mb) { |
729 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; | 747 LOG(WARNING) << "low_mem: Part of '200MB' experiment"; |
730 LowMemoryObserver::SetLowMemoryMargin(200); | 748 LowMemoryObserver::SetLowMemoryMargin(200); |
731 } else { | 749 } else { |
732 LOG(WARNING) << "low_mem: Part of 'default' experiment"; | 750 LOG(WARNING) << "low_mem: Part of 'default' experiment"; |
733 } | 751 } |
734 } | 752 } |
735 } | 753 } |
736 | 754 |
737 } // namespace chromeos | 755 } // namespace chromeos |
OLD | NEW |