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" |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 | 80 |
81 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = | 81 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = |
82 LAZY_INSTANCE_INITIALIZER; | 82 LAZY_INSTANCE_INITIALIZER; |
83 | 83 |
84 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 84 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
85 const content::MainFunctionParams& parameters) | 85 const content::MainFunctionParams& parameters) |
86 : ChromeBrowserMainPartsLinux(parameters) { | 86 : ChromeBrowserMainPartsLinux(parameters) { |
87 } | 87 } |
88 | 88 |
89 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 89 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
90 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | |
91 // stops monitoring changes from the update engine. | |
92 if (UpgradeDetectorChromeos::GetInstance()) | |
93 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | |
94 | |
95 // Shutdown the network change notifier for Chrome OS. The network | |
96 // change notifier stops monitoring changes from the power manager and | |
97 // the network manager. | |
98 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) | |
99 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | |
100 | |
101 chromeos::disks::DiskMountManager::Shutdown(); | 90 chromeos::disks::DiskMountManager::Shutdown(); |
102 | 91 |
103 chromeos::BluetoothManager::Shutdown(); | 92 chromeos::BluetoothManager::Shutdown(); |
104 | 93 |
105 // We should remove observers attached to D-Bus clients before | |
106 // DBusThreadManager is shut down. | |
107 if (session_manager_observer_.get()) { | |
108 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | |
109 RemoveObserver(session_manager_observer_.get()); | |
110 } | |
111 if (brightness_observer_.get()) { | |
112 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() | |
113 ->RemoveObserver(brightness_observer_.get()); | |
114 } | |
115 | |
116 chromeos::DBusThreadManager::Shutdown(); | 94 chromeos::DBusThreadManager::Shutdown(); |
117 | 95 |
118 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 96 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
119 chromeos::CrosLibrary::Shutdown(); | 97 chromeos::CrosLibrary::Shutdown(); |
120 | 98 |
121 // To be precise, logout (browser shutdown) is not yet done, but the | 99 // To be precise, logout (browser shutdown) is not yet done, but the |
122 // remaining work is negligible, hence we say LogoutDone here. | 100 // remaining work is negligible, hence we say LogoutDone here. |
123 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 101 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
124 false); | 102 false); |
125 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 103 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // parsed command line until after about_flags::ConvertFlagsToSwitches has | 140 // parsed command line until after about_flags::ConvertFlagsToSwitches has |
163 // been called. | 141 // been called. |
164 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove | 142 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove |
165 // the --enable-bluetooth flag. | 143 // the --enable-bluetooth flag. |
166 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { | 144 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { |
167 chromeos::BluetoothManager::Initialize(); | 145 chromeos::BluetoothManager::Initialize(); |
168 } | 146 } |
169 } | 147 } |
170 | 148 |
171 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 149 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
172 ChromeBrowserMainPartsPosix::PostMainMessageLoopStart(); | 150 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
173 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 151 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
174 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 152 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
175 | 153 |
176 // Initialize DBusThreadManager for the browser. This must be done after | 154 // Initialize DBusThreadManager for the browser. This must be done after |
177 // the main message loop is started, as it uses the message loop. | 155 // the main message loop is started, as it uses the message loop. |
178 chromeos::DBusThreadManager::Initialize(); | 156 chromeos::DBusThreadManager::Initialize(); |
179 | 157 |
180 // Initialize the brightness observer so that we'll display an onscreen | 158 // Initialize the brightness observer so that we'll display an onscreen |
181 // indication of brightness changes during login. | 159 // indication of brightness changes during login. |
182 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 160 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
(...skipping 22 matching lines...) Expand all Loading... |
205 // Enable Num Lock on X start up. | 183 // Enable Num Lock on X start up. |
206 chromeos::input_method::InputMethodManager::GetInstance()-> | 184 chromeos::input_method::InputMethodManager::GetInstance()-> |
207 GetXKeyboard()->SetNumLockEnabled(true); | 185 GetXKeyboard()->SetNumLockEnabled(true); |
208 | 186 |
209 #if defined(USE_AURA) | 187 #if defined(USE_AURA) |
210 initial_browser_window_observer_.reset( | 188 initial_browser_window_observer_.reset( |
211 new chromeos::InitialBrowserWindowObserver); | 189 new chromeos::InitialBrowserWindowObserver); |
212 #endif | 190 #endif |
213 } | 191 } |
214 } | 192 } |
| 193 |
| 194 // Shut down services before the browser process, etc are destroyed. |
| 195 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
| 196 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); |
| 197 |
| 198 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
| 199 // stops monitoring changes from the update engine. |
| 200 if (UpgradeDetectorChromeos::GetInstance()) |
| 201 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
| 202 |
| 203 // Shutdown the network change notifier for Chrome OS. The network |
| 204 // change notifier stops monitoring changes from the power manager and |
| 205 // the network manager. |
| 206 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) |
| 207 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
| 208 |
| 209 // We should remove observers attached to D-Bus clients before |
| 210 // DBusThreadManager is shut down. |
| 211 if (session_manager_observer_.get()) { |
| 212 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
| 213 RemoveObserver(session_manager_observer_.get()); |
| 214 } |
| 215 if (brightness_observer_.get()) { |
| 216 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() |
| 217 ->RemoveObserver(brightness_observer_.get()); |
| 218 } |
| 219 } |
OLD | NEW |