Chromium Code Reviews| 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 "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" | 12 #include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" |
| 13 #include "chrome/browser/chromeos/boot_times_loader.h" | 13 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 14 #include "chrome/browser/chromeos/brightness_observer.h" | 14 #include "chrome/browser/chromeos/brightness_observer.h" |
| 15 #include "chrome/browser/chromeos/cros/cros_library.h" | 15 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 16 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 16 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
| 17 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | |
| 17 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 18 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
| 18 #include "chrome/browser/chromeos/login/session_manager_observer.h" | 19 #include "chrome/browser/chromeos/login/session_manager_observer.h" |
| 19 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 20 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
| 20 #include "chrome/browser/chromeos/system/statistics_provider.h" | 21 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 21 #include "chrome/browser/defaults.h" | 22 #include "chrome/browser/defaults.h" |
| 22 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 23 #include "content/common/main_function_params.h" | 24 #include "content/common/main_function_params.h" |
| 24 #include "net/base/network_change_notifier.h" | 25 #include "net/base/network_change_notifier.h" |
| 25 | 26 |
| 26 #if defined(TOOLKIT_USES_GTK) | 27 #if defined(TOOLKIT_USES_GTK) |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 113 } | 114 } |
| 114 | 115 |
| 115 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 116 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
| 116 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | 117 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
| 117 // Initialize CrosLibrary only for the browser, unless running tests | 118 // Initialize CrosLibrary only for the browser, unless running tests |
| 118 // (which do their own CrosLibrary setup). | 119 // (which do their own CrosLibrary setup). |
| 119 if (!parameters().ui_task) { | 120 if (!parameters().ui_task) { |
| 120 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); | 121 bool use_stub = parameters().command_line_.HasSwitch(switches::kStubCros); |
| 121 chromeos::CrosLibrary::Initialize(use_stub); | 122 chromeos::CrosLibrary::Initialize(use_stub); |
| 122 } | 123 } |
| 123 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | |
| 124 // implementation. | |
| 125 net::NetworkChangeNotifier::SetFactory( | |
| 126 new chromeos::CrosNetworkChangeNotifierFactory()); | |
| 127 } | 124 } |
| 128 | 125 |
| 129 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 126 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { |
| 130 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). | 127 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). |
| 131 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); | 128 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); |
| 132 // Get the statistics provider instance here to start loading statistcs | 129 // Get the statistics provider instance here to start loading statistcs |
| 133 // on the background FILE thread. | 130 // on the background FILE thread. |
| 134 chromeos::system::StatisticsProvider::GetInstance(); | 131 chromeos::system::StatisticsProvider::GetInstance(); |
| 135 } | 132 } |
| 136 | 133 |
| 137 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 134 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
| 138 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 135 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); |
| 139 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 136 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
| 140 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 137 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
| 141 | 138 |
| 142 // Initialize DBusThreadManager for the browser. This must be done after | 139 // Initialize DBusThreadManager for the browser. This must be done after |
| 143 // the main message loop is started, as it uses the message loop. | 140 // the main message loop is started, as it uses the message loop. |
| 144 chromeos::DBusThreadManager::Initialize(); | 141 chromeos::DBusThreadManager::Initialize(); |
| 145 | 142 |
| 143 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | |
| 144 // implementation. | |
|
satorux1
2011/10/29 02:28:48
Please add some comment that this needs to be done
Simon Que
2011/11/02 00:13:43
Done.
| |
| 145 net::NetworkChangeNotifier::SetFactory( | |
| 146 new chromeos::CrosNetworkChangeNotifierFactory()); | |
| 147 | |
| 146 // Initialize the brightness observer so that we'll display an onscreen | 148 // Initialize the brightness observer so that we'll display an onscreen |
| 147 // indication of brightness changes during login. | 149 // indication of brightness changes. |
| 148 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 150 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
| 149 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( | 151 chromeos::DBusThreadManager::Get()->power_manager_client()->AddObserver( |
| 150 brightness_observer_.get()); | 152 brightness_observer_.get()); |
| 153 | |
| 151 // Initialize the session manager observer so that we'll take actions | 154 // Initialize the session manager observer so that we'll take actions |
| 152 // per signals sent from the session manager. | 155 // per signals sent from the session manager. |
| 153 session_manager_observer_.reset(new chromeos::SessionManagerObserver); | 156 session_manager_observer_.reset(new chromeos::SessionManagerObserver); |
| 154 chromeos::DBusThreadManager::Get()->session_manager_client()-> | 157 chromeos::DBusThreadManager::Get()->session_manager_client()-> |
| 155 AddObserver(session_manager_observer_.get()); | 158 AddObserver(session_manager_observer_.get()); |
| 156 | 159 |
| 157 // Initialize the Chrome OS bluetooth subsystem | 160 // Initialize the Chrome OS bluetooth subsystem |
| 158 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { | 161 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { |
| 159 chromeos::BluetoothManager::Initialize(); | 162 chromeos::BluetoothManager::Initialize(); |
| 160 } | 163 } |
| 161 } | 164 } |
| OLD | NEW |