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 "base/string_number_conversions.h" |
| 13 #include "chrome/browser/browser_process_impl.h" |
12 #include "chrome/browser/chromeos/accessibility/system_event_observer.h" | 14 #include "chrome/browser/chromeos/accessibility/system_event_observer.h" |
| 15 #include "chrome/browser/chromeos/audio_handler.h" |
| 16 #include "chrome/browser/chromeos/audio_handler.h" |
13 #include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" | 17 #include "chrome/browser/chromeos/bluetooth/bluetooth_manager.h" |
14 #include "chrome/browser/chromeos/boot_times_loader.h" | 18 #include "chrome/browser/chromeos/boot_times_loader.h" |
| 19 #include "chrome/browser/chromeos/boot_times_loader.h" |
15 #include "chrome/browser/chromeos/brightness_observer.h" | 20 #include "chrome/browser/chromeos/brightness_observer.h" |
16 #include "chrome/browser/chromeos/cros/cros_library.h" | 21 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 22 #include "chrome/browser/chromeos/cros/cros_library.h" |
| 23 #include "chrome/browser/chromeos/cros/screen_lock_library.h" |
17 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" | 24 #include "chrome/browser/chromeos/dbus/dbus_thread_manager.h" |
18 #include "chrome/browser/chromeos/dbus/power_manager_client.h" | 25 #include "chrome/browser/chromeos/dbus/power_manager_client.h" |
19 #include "chrome/browser/chromeos/dbus/session_manager_client.h" | 26 #include "chrome/browser/chromeos/dbus/session_manager_client.h" |
20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" | 27 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" |
| 28 #include "chrome/browser/chromeos/external_metrics.h" |
21 #include "chrome/browser/chromeos/input_method/input_method_manager.h" | 29 #include "chrome/browser/chromeos/input_method/input_method_manager.h" |
22 #include "chrome/browser/chromeos/input_method/xkeyboard.h" | 30 #include "chrome/browser/chromeos/input_method/xkeyboard.h" |
| 31 #include "chrome/browser/chromeos/login/authenticator.h" |
| 32 #include "chrome/browser/chromeos/login/login_utils.h" |
| 33 #include "chrome/browser/chromeos/login/ownership_service.h" |
| 34 #include "chrome/browser/chromeos/login/screen_locker.h" |
23 #include "chrome/browser/chromeos/login/session_manager_observer.h" | 35 #include "chrome/browser/chromeos/login/session_manager_observer.h" |
| 36 #include "chrome/browser/chromeos/login/user_manager.h" |
24 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" | 37 #include "chrome/browser/chromeos/net/cros_network_change_notifier_factory.h" |
25 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" | 38 #include "chrome/browser/chromeos/net/network_change_notifier_chromeos.h" |
| 39 #include "chrome/browser/chromeos/status/status_area_view_chromeos.h" |
26 #include "chrome/browser/chromeos/system/runtime_environment.h" | 40 #include "chrome/browser/chromeos/system/runtime_environment.h" |
27 #include "chrome/browser/chromeos/system/statistics_provider.h" | 41 #include "chrome/browser/chromeos/system/statistics_provider.h" |
| 42 #include "chrome/browser/chromeos/system_key_event_listener.h" |
28 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" | 43 #include "chrome/browser/chromeos/upgrade_detector_chromeos.h" |
| 44 #include "chrome/browser/chromeos/xinput_hierarchy_changed_event_listener.h" |
29 #include "chrome/browser/defaults.h" | 45 #include "chrome/browser/defaults.h" |
| 46 #include "chrome/browser/metrics/metrics_service.h" |
| 47 #include "chrome/browser/oom_priority_manager.h" |
| 48 #include "chrome/browser/policy/browser_policy_connector.h" |
| 49 #include "chrome/browser/profiles/profile.h" |
| 50 #include "chrome/browser/profiles/profile_manager.h" |
| 51 #include "chrome/browser/ui/views/browser_dialogs.h" |
30 #include "chrome/common/chrome_switches.h" | 52 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/logging_chrome.h" |
31 #include "content/public/common/main_function_params.h" | 54 #include "content/public/common/main_function_params.h" |
| 55 #include "grit/platform_locale_settings.h" |
32 #include "net/base/network_change_notifier.h" | 56 #include "net/base/network_change_notifier.h" |
| 57 #include "net/url_request/url_request.h" |
| 58 #include "ui/base/l10n/l10n_util.h" |
33 | 59 |
34 #if defined(TOOLKIT_USES_GTK) | 60 #if defined(TOOLKIT_USES_GTK) |
35 #include <gtk/gtk.h> | 61 #include <gtk/gtk.h> |
36 #endif | 62 #endif |
37 | 63 |
38 #if defined(USE_AURA) | 64 #if defined(USE_AURA) |
39 #include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_o
bserver.h" | 65 #include "chrome/browser/chromeos/legacy_window_manager/initial_browser_window_o
bserver.h" |
40 #endif | 66 #endif |
41 | 67 |
42 class MessageLoopObserver : public MessageLoopForUI::Observer { | 68 class MessageLoopObserver : public MessageLoopForUI::Observer { |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 } | 101 } |
76 | 102 |
77 virtual void DidProcessEvent(GdkEvent* event) { | 103 virtual void DidProcessEvent(GdkEvent* event) { |
78 } | 104 } |
79 #endif | 105 #endif |
80 }; | 106 }; |
81 | 107 |
82 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = | 108 static base::LazyInstance<MessageLoopObserver> g_message_loop_observer = |
83 LAZY_INSTANCE_INITIALIZER; | 109 LAZY_INSTANCE_INITIALIZER; |
84 | 110 |
| 111 // Login ----------------------------------------------------------------------- |
| 112 |
| 113 // Class is used to login using passed username and password. |
| 114 // The instance will be deleted upon success or failure. |
| 115 class StubLogin : public chromeos::LoginStatusConsumer, |
| 116 public chromeos::LoginUtils::Delegate { |
| 117 public: |
| 118 StubLogin(std::string username, std::string password) |
| 119 : pending_requests_(false), |
| 120 profile_prepared_(false) { |
| 121 authenticator_ = chromeos::LoginUtils::Get()->CreateAuthenticator(this); |
| 122 authenticator_.get()->AuthenticateToLogin( |
| 123 g_browser_process->profile_manager()->GetDefaultProfile(), |
| 124 username, |
| 125 password, |
| 126 std::string(), |
| 127 std::string()); |
| 128 } |
| 129 |
| 130 ~StubLogin() { |
| 131 chromeos::LoginUtils::Get()->DelegateDeleted(this); |
| 132 } |
| 133 |
| 134 void OnLoginFailure(const chromeos::LoginFailure& error) { |
| 135 LOG(ERROR) << "Login Failure: " << error.GetErrorString(); |
| 136 delete this; |
| 137 } |
| 138 |
| 139 void OnLoginSuccess(const std::string& username, |
| 140 const std::string& password, |
| 141 const GaiaAuthConsumer::ClientLoginResult& credentials, |
| 142 bool pending_requests, |
| 143 bool using_oauth) { |
| 144 pending_requests_ = pending_requests; |
| 145 if (!profile_prepared_) { |
| 146 // Will call OnProfilePrepared in the end. |
| 147 chromeos::LoginUtils::Get()->PrepareProfile(username, |
| 148 password, |
| 149 credentials, |
| 150 pending_requests, |
| 151 using_oauth, |
| 152 false, |
| 153 this); |
| 154 } else if (!pending_requests) { |
| 155 delete this; |
| 156 } |
| 157 } |
| 158 |
| 159 // LoginUtils::Delegate implementation: |
| 160 virtual void OnProfilePrepared(Profile* profile) { |
| 161 profile_prepared_ = true; |
| 162 chromeos::LoginUtils::DoBrowserLaunch(profile, NULL); |
| 163 if (!pending_requests_) |
| 164 delete this; |
| 165 } |
| 166 |
| 167 scoped_refptr<chromeos::Authenticator> authenticator_; |
| 168 bool pending_requests_; |
| 169 bool profile_prepared_; |
| 170 }; |
| 171 |
| 172 // Allows authenticator to be invoked without adding refcounting. The instances |
| 173 // will delete themselves upon completion. |
| 174 DISABLE_RUNNABLE_METHOD_REFCOUNT(StubLogin); |
| 175 |
| 176 void OptionallyRunChromeOSLoginManager(const CommandLine& parsed_command_line, |
| 177 Profile* profile) { |
| 178 if (parsed_command_line.HasSwitch(switches::kLoginManager)) { |
| 179 std::string first_screen = |
| 180 parsed_command_line.GetSwitchValueASCII(switches::kLoginScreen); |
| 181 std::string size_arg = |
| 182 parsed_command_line.GetSwitchValueASCII( |
| 183 switches::kLoginScreenSize); |
| 184 gfx::Size size(0, 0); |
| 185 // Allow the size of the login window to be set explicitly. If not set, |
| 186 // default to the entire screen. This is mostly useful for testing. |
| 187 if (size_arg.size()) { |
| 188 std::vector<std::string> dimensions; |
| 189 base::SplitString(size_arg, ',', &dimensions); |
| 190 if (dimensions.size() == 2) { |
| 191 int width, height; |
| 192 if (base::StringToInt(dimensions[0], &width) && |
| 193 base::StringToInt(dimensions[1], &height)) |
| 194 size.SetSize(width, height); |
| 195 } |
| 196 } |
| 197 browser::ShowLoginWizard(first_screen, size); |
| 198 } else if (parsed_command_line.HasSwitch(switches::kLoginUser) && |
| 199 parsed_command_line.HasSwitch(switches::kLoginPassword)) { |
| 200 chromeos::BootTimesLoader::Get()->RecordLoginAttempted(); |
| 201 new StubLogin( |
| 202 parsed_command_line.GetSwitchValueASCII(switches::kLoginUser), |
| 203 parsed_command_line.GetSwitchValueASCII(switches::kLoginPassword)); |
| 204 } else { |
| 205 if (!parsed_command_line.HasSwitch(switches::kTestName)) { |
| 206 // We did not log in (we crashed or are debugging), so we need to |
| 207 // set the user name for sync. |
| 208 chromeos::LoginUtils::Get()->RestoreAuthenticationSession( |
| 209 chromeos::UserManager::Get()->logged_in_user().email(), profile); |
| 210 } |
| 211 } |
| 212 } |
| 213 |
| 214 // ChromeBrowserMainPartsChromeos ---------------------------------------------- |
| 215 |
85 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 216 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
86 const content::MainFunctionParams& parameters) | 217 const content::MainFunctionParams& parameters) |
87 : ChromeBrowserMainPartsLinux(parameters) { | 218 : ChromeBrowserMainPartsLinux(parameters) { |
88 } | 219 } |
89 | 220 |
90 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { | 221 ChromeBrowserMainPartsChromeos::~ChromeBrowserMainPartsChromeos() { |
91 chromeos::disks::DiskMountManager::Shutdown(); | 222 chromeos::disks::DiskMountManager::Shutdown(); |
92 | 223 |
93 chromeos::DBusThreadManager::Shutdown(); | 224 chromeos::DBusThreadManager::Shutdown(); |
94 | 225 |
95 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) | 226 if (!parameters().ui_task && chromeos::CrosLibrary::Get()) |
96 chromeos::CrosLibrary::Shutdown(); | 227 chromeos::CrosLibrary::Shutdown(); |
97 | 228 |
98 // To be precise, logout (browser shutdown) is not yet done, but the | 229 // To be precise, logout (browser shutdown) is not yet done, but the |
99 // remaining work is negligible, hence we say LogoutDone here. | 230 // remaining work is negligible, hence we say LogoutDone here. |
100 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", | 231 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("LogoutDone", |
101 false); | 232 false); |
102 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); | 233 chromeos::BootTimesLoader::Get()->WriteLogoutTimes(); |
103 } | 234 } |
104 | 235 |
| 236 // content::BrowserMainParts and ChromeBrowserMainExtraParts overrides --------- |
| 237 |
105 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { | 238 void ChromeBrowserMainPartsChromeos::PreEarlyInitialization() { |
106 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); | |
107 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { | 239 if (parsed_command_line().HasSwitch(switches::kGuestSession)) { |
108 // Disable sync and extensions if we're in "browse without sign-in" mode. | 240 // Disable sync and extensions if we're in "browse without sign-in" mode. |
109 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); | 241 CommandLine* singleton_command_line = CommandLine::ForCurrentProcess(); |
110 singleton_command_line->AppendSwitch(switches::kDisableSync); | 242 singleton_command_line->AppendSwitch(switches::kDisableSync); |
111 singleton_command_line->AppendSwitch(switches::kDisableExtensions); | 243 singleton_command_line->AppendSwitch(switches::kDisableExtensions); |
112 browser_defaults::bookmarks_enabled = false; | 244 browser_defaults::bookmarks_enabled = false; |
113 } | 245 } |
| 246 |
| 247 ChromeBrowserMainPartsLinux::PreEarlyInitialization(); |
114 } | 248 } |
115 | 249 |
116 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { | 250 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopStart() { |
117 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); | |
118 // Initialize CrosLibrary only for the browser, unless running tests | 251 // Initialize CrosLibrary only for the browser, unless running tests |
119 // (which do their own CrosLibrary setup). | 252 // (which do their own CrosLibrary setup). |
120 if (!parameters().ui_task) { | 253 if (!parameters().ui_task) { |
121 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); | 254 bool use_stub = parameters().command_line.HasSwitch(switches::kStubCros); |
122 chromeos::CrosLibrary::Initialize(use_stub); | 255 chromeos::CrosLibrary::Initialize(use_stub); |
123 } | 256 } |
124 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific | 257 // Replace the default NetworkChangeNotifierFactory with ChromeOS specific |
125 // implementation. | 258 // implementation. |
126 net::NetworkChangeNotifier::SetFactory( | 259 net::NetworkChangeNotifier::SetFactory( |
127 new chromeos::CrosNetworkChangeNotifierFactory()); | 260 new chromeos::CrosNetworkChangeNotifierFactory()); |
| 261 |
| 262 ChromeBrowserMainPartsLinux::PreMainMessageLoopStart(); |
128 } | 263 } |
129 | 264 |
130 void ChromeBrowserMainPartsChromeos::PreMainMessageLoopRun() { | 265 void ChromeBrowserMainPartsChromeos::PreProfileInit() { |
| 266 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 267 // -- immediately before Profile creation(). |
| 268 |
| 269 // Now that the file thread exists we can record our stats. |
| 270 chromeos::BootTimesLoader::Get()->RecordChromeMainStats(); |
| 271 |
| 272 #if defined(TOOLKIT_USES_GTK) |
| 273 // Read locale-specific GTK resource information. |
| 274 std::string gtkrc = l10n_util::GetStringUTF8(IDS_LOCALE_GTKRC); |
| 275 if (!gtkrc.empty()) |
| 276 gtk_rc_parse_string(gtkrc.c_str()); |
| 277 #else |
| 278 // TODO(saintlou): Need to provide an Aura equivalent. |
| 279 NOTIMPLEMENTED(); |
| 280 #endif |
| 281 |
| 282 // Trigger prefetching of ownership status. |
| 283 chromeos::OwnershipService::GetSharedInstance()->Prewarm(); |
| 284 |
| 285 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 286 // -- just before CreateProfile(). |
| 287 |
| 288 // This forces the ProfileManager to be created and register for the |
| 289 // notification it needs to track the logged in user. |
| 290 g_browser_process->profile_manager(); |
| 291 |
| 292 // TODO(abarth): Should this move to InitializeNetworkOptions()? |
| 293 // Allow access to file:// on ChromeOS for tests. |
| 294 if (parsed_command_line().HasSwitch(switches::kAllowFileAccess)) |
| 295 net::URLRequest::AllowFileAccess(); |
| 296 |
| 297 // There are two use cases for kLoginUser: |
| 298 // 1) if passed in tandem with kLoginPassword, to drive a "StubLogin" |
| 299 // 2) if passed alone, to signal that the indicated user has already |
| 300 // logged in and we should behave accordingly. |
| 301 // This handles case 2. |
| 302 if (parsed_command_line().HasSwitch(switches::kLoginUser) && |
| 303 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { |
| 304 std::string username = |
| 305 parsed_command_line().GetSwitchValueASCII(switches::kLoginUser); |
| 306 VLOG(1) << "Relaunching browser for user: " << username; |
| 307 chromeos::UserManager::Get()->UserLoggedIn(username); |
| 308 |
| 309 // Redirects Chrome logging to the user data dir. |
| 310 logging::RedirectChromeLogging(parsed_command_line()); |
| 311 |
| 312 // Initialize user policy before creating the profile so the profile |
| 313 // initialization code sees policy settings. |
| 314 g_browser_process->browser_policy_connector()->InitializeUserPolicy( |
| 315 username, false /* wait_for_policy_fetch */); |
| 316 } else if (parsed_command_line().HasSwitch(switches::kLoginManager)) { |
| 317 // Initialize status area mode early on. |
| 318 chromeos::StatusAreaViewChromeos:: |
| 319 SetScreenMode(chromeos::StatusAreaViewChromeos::LOGIN_MODE_WEBUI); |
| 320 } |
| 321 |
| 322 // In Aura builds this will initialize aura_shell::Shell. |
| 323 ChromeBrowserMainPartsLinux::PreProfileInit(); |
| 324 } |
| 325 |
| 326 void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
| 327 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 328 // -- just after CreateProfile(). |
| 329 |
| 330 // Pass the TokenService pointer to the policy connector so user policy can |
| 331 // grab a token and register with the policy server. |
| 332 // TODO(mnissler): Remove once OAuth is the only authentication mechanism. |
| 333 if (parsed_command_line().HasSwitch(switches::kLoginUser) && |
| 334 !parsed_command_line().HasSwitch(switches::kLoginPassword)) { |
| 335 g_browser_process->browser_policy_connector()->SetUserPolicyTokenService( |
| 336 profile()->GetTokenService()); |
| 337 } |
| 338 |
| 339 // Tests should be able to tune login manager before showing it. |
| 340 // Thus only show login manager in normal (non-testing) mode. |
| 341 if (!parameters().ui_task) |
| 342 OptionallyRunChromeOSLoginManager(parsed_command_line(), profile()); |
| 343 |
| 344 ChromeBrowserMainPartsLinux::PostProfileInit(); |
| 345 } |
| 346 |
| 347 void ChromeBrowserMainPartsChromeos::PreBrowserStart() { |
| 348 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 349 // -- just before MetricsService::LogNeedForCleanShutdown(). |
| 350 |
| 351 metrics()->StartExternalMetrics(); |
| 352 |
| 353 // Initialize the audio handler on ChromeOS. |
| 354 chromeos::AudioHandler::Initialize(); |
| 355 |
| 356 // Listen for system key events so that the user will be able to adjust the |
| 357 // volume on the login screen, if Chrome is running on Chrome OS |
| 358 // (i.e. not Linux desktop), and in non-test mode. |
| 359 if (chromeos::system::runtime_environment::IsRunningOnChromeOS() && |
| 360 !parameters().ui_task) { // ui_task is non-NULL when running tests. |
| 361 chromeos::SystemKeyEventListener::Initialize(); |
| 362 } |
| 363 |
| 364 // Listen for XI_HierarchyChanged events. |
| 365 chromeos::XInputHierarchyChangedEventListener::GetInstance(); |
| 366 |
| 367 // -- This used to be in ChromeBrowserMainParts::PreMainMessageLoopRun() |
| 368 // -- immediately after ChildProcess::WaitForDebugger(). |
| 369 |
| 370 // Start the out-of-memory priority manager here so that we give the most |
| 371 // amount of time for the other services to start up before we start |
| 372 // adjusting the oom priority. |
| 373 g_browser_process->oom_priority_manager()->Start(); |
| 374 |
| 375 ChromeBrowserMainPartsLinux::PreBrowserStart(); |
| 376 } |
| 377 |
| 378 void ChromeBrowserMainPartsChromeos::PostBrowserStart() { |
131 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). | 379 // FILE thread is created in ChromeBrowserMainParts::PreMainMessageLoopRun(). |
132 ChromeBrowserMainPartsLinux::PreMainMessageLoopRun(); | 380 |
133 // Get the statistics provider instance here to start loading statistcs | 381 // Get the statistics provider instance here to start loading statistcs |
134 // on the background FILE thread. | 382 // on the background FILE thread. |
135 chromeos::system::StatisticsProvider::GetInstance(); | 383 chromeos::system::StatisticsProvider::GetInstance(); |
136 | 384 |
137 // Initialize the Chrome OS bluetooth subsystem. | 385 // Initialize the Chrome OS bluetooth subsystem. |
138 // We defer this to PreMainMessageLoopRun because we don't want to check the | 386 // We defer this to PreMainMessageLoopRun because we don't want to check the |
139 // parsed command line until after about_flags::ConvertFlagsToSwitches has | 387 // parsed command line until after about_flags::ConvertFlagsToSwitches has |
140 // been called. | 388 // been called. |
141 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove | 389 // TODO(vlaviano): Move this back to PostMainMessageLoopStart when we remove |
142 // the --enable-bluetooth flag. | 390 // the --enable-bluetooth flag. |
143 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { | 391 if (parsed_command_line().HasSwitch(switches::kEnableBluetooth)) { |
144 chromeos::BluetoothManager::Initialize(); | 392 chromeos::BluetoothManager::Initialize(); |
145 } | 393 } |
| 394 |
| 395 ChromeBrowserMainPartsLinux::PostBrowserStart(); |
146 } | 396 } |
147 | 397 |
148 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { | 398 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopStart() { |
149 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); | |
150 MessageLoopForUI* message_loop = MessageLoopForUI::current(); | 399 MessageLoopForUI* message_loop = MessageLoopForUI::current(); |
151 message_loop->AddObserver(g_message_loop_observer.Pointer()); | 400 message_loop->AddObserver(g_message_loop_observer.Pointer()); |
152 | 401 |
153 // Initialize DBusThreadManager for the browser. This must be done after | 402 // Initialize DBusThreadManager for the browser. This must be done after |
154 // the main message loop is started, as it uses the message loop. | 403 // the main message loop is started, as it uses the message loop. |
155 chromeos::DBusThreadManager::Initialize(); | 404 chromeos::DBusThreadManager::Initialize(); |
156 | 405 |
157 // Initialize the brightness observer so that we'll display an onscreen | 406 // Initialize the brightness observer so that we'll display an onscreen |
158 // indication of brightness changes during login. | 407 // indication of brightness changes during login. |
159 brightness_observer_.reset(new chromeos::BrightnessObserver()); | 408 brightness_observer_.reset(new chromeos::BrightnessObserver()); |
(...skipping 29 matching lines...) Expand all Loading... |
189 #if defined(GOOGLE_CHROME_BUILD) | 438 #if defined(GOOGLE_CHROME_BUILD) |
190 chromeos::input_method::InputMethodManager::GetInstance()-> | 439 chromeos::input_method::InputMethodManager::GetInstance()-> |
191 GetXKeyboard()->SetNumLockEnabled(true); | 440 GetXKeyboard()->SetNumLockEnabled(true); |
192 #endif | 441 #endif |
193 | 442 |
194 #if defined(USE_AURA) | 443 #if defined(USE_AURA) |
195 initial_browser_window_observer_.reset( | 444 initial_browser_window_observer_.reset( |
196 new chromeos::InitialBrowserWindowObserver); | 445 new chromeos::InitialBrowserWindowObserver); |
197 #endif | 446 #endif |
198 } | 447 } |
| 448 |
| 449 ChromeBrowserMainPartsLinux::PostMainMessageLoopStart(); |
199 } | 450 } |
200 | 451 |
201 // Shut down services before the browser process, etc are destroyed. | 452 // Shut down services before the browser process, etc are destroyed. |
202 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { | 453 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
203 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); | 454 chromeos::BootTimesLoader::Get()->AddLogoutTimeMarker("UIMessageLoopEnded", |
| 455 true); |
| 456 |
| 457 g_browser_process->oom_priority_manager()->Stop(); |
| 458 |
| 459 // The XInput2 event listener needs to be shut down earlier than when |
| 460 // Singletons are finally destroyed in AtExitManager. |
| 461 chromeos::XInputHierarchyChangedEventListener::GetInstance()->Stop(); |
| 462 |
| 463 // chromeos::SystemKeyEventListener::Shutdown() is always safe to call, |
| 464 // even if Initialize() wasn't called. |
| 465 chromeos::SystemKeyEventListener::Shutdown(); |
| 466 chromeos::AudioHandler::Shutdown(); |
204 | 467 |
205 // Shutdown the upgrade detector for Chrome OS. The upgrade detector | 468 // Shutdown the upgrade detector for Chrome OS. The upgrade detector |
206 // stops monitoring changes from the update engine. | 469 // stops monitoring changes from the update engine. |
207 if (UpgradeDetectorChromeos::GetInstance()) | 470 if (UpgradeDetectorChromeos::GetInstance()) |
208 UpgradeDetectorChromeos::GetInstance()->Shutdown(); | 471 UpgradeDetectorChromeos::GetInstance()->Shutdown(); |
209 | 472 |
210 // Shutdown the network change notifier for Chrome OS. The network | 473 // Shutdown the network change notifier for Chrome OS. The network |
211 // change notifier stops monitoring changes from the power manager and | 474 // change notifier stops monitoring changes from the power manager and |
212 // the network manager. | 475 // the network manager. |
213 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) | 476 if (chromeos::CrosNetworkChangeNotifierFactory::GetInstance()) |
214 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); | 477 chromeos::CrosNetworkChangeNotifierFactory::GetInstance()->Shutdown(); |
215 | 478 |
216 // We should remove observers attached to D-Bus clients before | 479 // We should remove observers attached to D-Bus clients before |
217 // DBusThreadManager is shut down. | 480 // DBusThreadManager is shut down. |
218 if (session_manager_observer_.get()) { | 481 if (session_manager_observer_.get()) { |
219 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> | 482 chromeos::DBusThreadManager::Get()->GetSessionManagerClient()-> |
220 RemoveObserver(session_manager_observer_.get()); | 483 RemoveObserver(session_manager_observer_.get()); |
221 } | 484 } |
222 if (brightness_observer_.get()) { | 485 if (brightness_observer_.get()) { |
223 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() | 486 chromeos::DBusThreadManager::Get()->GetPowerManagerClient() |
224 ->RemoveObserver(brightness_observer_.get()); | 487 ->RemoveObserver(brightness_observer_.get()); |
225 } | 488 } |
226 | 489 |
227 // Shut these down here instead of in the destructor in case we exited before | 490 // Shut these down here instead of in the destructor in case we exited before |
228 // running BrowserMainLoop::RunMainMessageLoopParts() and never initialized | 491 // running BrowserMainLoop::RunMainMessageLoopParts() and never initialized |
229 // these. | 492 // these. |
230 chromeos::accessibility::SystemEventObserver::Shutdown(); | 493 chromeos::accessibility::SystemEventObserver::Shutdown(); |
231 chromeos::BluetoothManager::Shutdown(); | 494 chromeos::BluetoothManager::Shutdown(); |
| 495 |
| 496 ChromeBrowserMainPartsLinux::PostMainMessageLoopRun(); |
232 } | 497 } |
OLD | NEW |