| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/ash_switches.h" | 10 #include "ash/ash_switches.h" |
| (...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 | 246 |
| 247 } // namespace | 247 } // namespace |
| 248 | 248 |
| 249 namespace internal { | 249 namespace internal { |
| 250 | 250 |
| 251 // Wrapper class for initializing dbus related services and shutting them | 251 // Wrapper class for initializing dbus related services and shutting them |
| 252 // down. This gets instantiated in a scoped_ptr so that shutdown methods in the | 252 // down. This gets instantiated in a scoped_ptr so that shutdown methods in the |
| 253 // destructor will get called if and only if this has been instantiated. | 253 // destructor will get called if and only if this has been instantiated. |
| 254 class DBusServices { | 254 class DBusServices { |
| 255 public: | 255 public: |
| 256 explicit DBusServices(const content::MainFunctionParams& parameters) | 256 explicit DBusServices(const content::MainFunctionParams& parameters) { |
| 257 : network_library_initialized_(false) { | |
| 258 if (!base::chromeos::IsRunningOnChromeOS()) { | 257 if (!base::chromeos::IsRunningOnChromeOS()) { |
| 259 // Override this path on the desktop, so that the user policy key can be | 258 // Override this path on the desktop, so that the user policy key can be |
| 260 // stored by the stub SessionManagerClient. | 259 // stored by the stub SessionManagerClient. |
| 261 base::FilePath user_data_dir; | 260 base::FilePath user_data_dir; |
| 262 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { | 261 if (PathService::Get(chrome::DIR_USER_DATA, &user_data_dir)) { |
| 263 PathService::Override(chromeos::DIR_USER_POLICY_KEYS, | 262 PathService::Override(chromeos::DIR_USER_POLICY_KEYS, |
| 264 user_data_dir.AppendASCII("stub_user_policy")); | 263 user_data_dir.AppendASCII("stub_user_policy")); |
| 265 } | 264 } |
| 266 } | 265 } |
| 267 | 266 |
| 268 // Initialize DBusThreadManager for the browser. This must be done after | 267 // Initialize DBusThreadManager for the browser. This must be done after |
| 269 // the main message loop is started, as it uses the message loop. | 268 // the main message loop is started, as it uses the message loop. |
| 270 DBusThreadManager::Initialize(); | 269 DBusThreadManager::Initialize(); |
| 271 CrosDBusService::Initialize(); | 270 CrosDBusService::Initialize(); |
| 272 | 271 |
| 273 LoginState::Initialize(); | 272 LoginState::Initialize(); |
| 274 CryptohomeLibrary::Initialize(); | 273 CryptohomeLibrary::Initialize(); |
| 275 CertLoader::Initialize(); | 274 CertLoader::Initialize(); |
| 276 | 275 |
| 277 // This function and SystemKeyEventListener use InputMethodManager. | 276 // This function and SystemKeyEventListener use InputMethodManager. |
| 278 chromeos::input_method::Initialize( | 277 chromeos::input_method::Initialize( |
| 279 content::BrowserThread::GetMessageLoopProxyForThread( | 278 content::BrowserThread::GetMessageLoopProxyForThread( |
| 280 content::BrowserThread::UI), | 279 content::BrowserThread::UI), |
| 281 content::BrowserThread::GetMessageLoopProxyForThread( | 280 content::BrowserThread::GetMessageLoopProxyForThread( |
| 282 content::BrowserThread::FILE)); | 281 content::BrowserThread::FILE)); |
| 283 disks::DiskMountManager::Initialize(); | 282 disks::DiskMountManager::Initialize(); |
| 284 cryptohome::AsyncMethodCaller::Initialize(); | 283 cryptohome::AsyncMethodCaller::Initialize(); |
| 285 | 284 |
| 286 // Initialize NetworkLibrary only for the browser, unless running tests | |
| 287 // (which do their own NetworkLibrary setup with | |
| 288 // ScopedStubNetworkLibraryEnabler in InProcessBrowserTest). | |
| 289 if (!parameters.ui_task) { | |
| 290 const bool use_stub = !base::chromeos::IsRunningOnChromeOS(); | |
| 291 NetworkLibrary::Initialize(use_stub); | |
| 292 network_library_initialized_ = true; | |
| 293 } | |
| 294 | |
| 295 // Always initialize these handlers which should not conflict with | 285 // Always initialize these handlers which should not conflict with |
| 296 // NetworkLibrary. | 286 // NetworkLibrary. |
| 297 NetworkHandler::Initialize(); | 287 NetworkHandler::Initialize(); |
| 298 CertLibrary::Initialize(); | 288 CertLibrary::Initialize(); |
| 299 | 289 |
| 300 // Initialize the network change notifier for Chrome OS. The network | 290 // Initialize the network change notifier for Chrome OS. The network |
| 301 // change notifier starts to monitor changes from the power manager and | 291 // change notifier starts to monitor changes from the power manager and |
| 302 // the network manager. | 292 // the network manager. |
| 303 NetworkChangeNotifierFactoryChromeos::GetInstance()->Initialize(); | 293 NetworkChangeNotifierFactoryChromeos::GetInstance()->Initialize(); |
| 304 | 294 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 317 // g_browser_process initializes BrowserPolicyConnector. | 307 // g_browser_process initializes BrowserPolicyConnector. |
| 318 DeviceSettingsService::Initialize(); | 308 DeviceSettingsService::Initialize(); |
| 319 DeviceSettingsService::Get()->SetSessionManager( | 309 DeviceSettingsService::Get()->SetSessionManager( |
| 320 DBusThreadManager::Get()->GetSessionManagerClient(), | 310 DBusThreadManager::Get()->GetSessionManagerClient(), |
| 321 OwnerKeyUtil::Create()); | 311 OwnerKeyUtil::Create()); |
| 322 } | 312 } |
| 323 | 313 |
| 324 ~DBusServices() { | 314 ~DBusServices() { |
| 325 CertLibrary::Shutdown(); | 315 CertLibrary::Shutdown(); |
| 326 NetworkHandler::Shutdown(); | 316 NetworkHandler::Shutdown(); |
| 327 if (network_library_initialized_) | |
| 328 NetworkLibrary::Shutdown(); | |
| 329 | 317 |
| 330 cryptohome::AsyncMethodCaller::Shutdown(); | 318 cryptohome::AsyncMethodCaller::Shutdown(); |
| 331 disks::DiskMountManager::Shutdown(); | 319 disks::DiskMountManager::Shutdown(); |
| 332 input_method::Shutdown(); | 320 input_method::Shutdown(); |
| 333 | 321 |
| 334 CryptohomeLibrary::Shutdown(); | 322 CryptohomeLibrary::Shutdown(); |
| 335 LoginState::Shutdown(); | 323 LoginState::Shutdown(); |
| 336 | 324 |
| 337 CrosDBusService::Shutdown(); | 325 CrosDBusService::Shutdown(); |
| 338 | 326 |
| 339 // NOTE: This must only be called if Initialize() was called. | 327 // NOTE: This must only be called if Initialize() was called. |
| 340 DBusThreadManager::Shutdown(); | 328 DBusThreadManager::Shutdown(); |
| 341 } | 329 } |
| 342 | 330 |
| 343 private: | 331 private: |
| 344 bool network_library_initialized_; | |
| 345 | 332 |
| 346 DISALLOW_COPY_AND_ASSIGN(DBusServices); | 333 DISALLOW_COPY_AND_ASSIGN(DBusServices); |
| 347 }; | 334 }; |
| 348 | 335 |
| 349 } // namespace internal | 336 } // namespace internal |
| 350 | 337 |
| 351 // ChromeBrowserMainPartsChromeos ---------------------------------------------- | 338 // ChromeBrowserMainPartsChromeos ---------------------------------------------- |
| 352 | 339 |
| 353 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 340 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
| 354 const content::MainFunctionParams& parameters) | 341 const content::MainFunctionParams& parameters) |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 | 787 |
| 801 // Destroy DeviceSettingsService after g_browser_process. | 788 // Destroy DeviceSettingsService after g_browser_process. |
| 802 DeviceSettingsService::Shutdown(); | 789 DeviceSettingsService::Shutdown(); |
| 803 } | 790 } |
| 804 | 791 |
| 805 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { | 792 void ChromeBrowserMainPartsChromeos::SetupPlatformFieldTrials() { |
| 806 default_pinned_apps_field_trial::SetupTrial(); | 793 default_pinned_apps_field_trial::SetupTrial(); |
| 807 } | 794 } |
| 808 | 795 |
| 809 } // namespace chromeos | 796 } // namespace chromeos |
| OLD | NEW |