| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 |
| 8 #include <string> | 9 #include <string> |
| 9 #include <utility> | 10 #include <utility> |
| 10 #include <vector> | 11 #include <vector> |
| 11 | 12 |
| 12 #include "ash/ash_switches.h" | 13 #include "ash/ash_switches.h" |
| 13 #include "ash/shell.h" | 14 #include "ash/shell.h" |
| 14 #include "base/bind.h" | 15 #include "base/bind.h" |
| 15 #include "base/callback.h" | 16 #include "base/callback.h" |
| 16 #include "base/command_line.h" | 17 #include "base/command_line.h" |
| 17 #include "base/files/file_util.h" | 18 #include "base/files/file_util.h" |
| 18 #include "base/lazy_instance.h" | 19 #include "base/lazy_instance.h" |
| 19 #include "base/linux_util.h" | 20 #include "base/linux_util.h" |
| 20 #include "base/macros.h" | 21 #include "base/macros.h" |
| 22 #include "base/memory/ptr_util.h" |
| 21 #include "base/path_service.h" | 23 #include "base/path_service.h" |
| 22 #include "base/strings/string_number_conversions.h" | 24 #include "base/strings/string_number_conversions.h" |
| 23 #include "base/strings/string_split.h" | 25 #include "base/strings/string_split.h" |
| 24 #include "base/sys_info.h" | 26 #include "base/sys_info.h" |
| 25 #include "base/task_runner_util.h" | 27 #include "base/task_runner_util.h" |
| 26 #include "chrome/browser/browser_process.h" | 28 #include "chrome/browser/browser_process.h" |
| 27 #include "chrome/browser/browser_process_platform_part_chromeos.h" | 29 #include "chrome/browser/browser_process_platform_part_chromeos.h" |
| 28 #include "chrome/browser/chrome_notification_types.h" | 30 #include "chrome/browser/chrome_notification_types.h" |
| 29 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" | 31 #include "chrome/browser/chromeos/accessibility/accessibility_manager.h" |
| 30 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" | 32 #include "chrome/browser/chromeos/accessibility/magnification_manager.h" |
| (...skipping 181 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 bluez::BluezDBusManager::Initialize( | 214 bluez::BluezDBusManager::Initialize( |
| 213 DBusThreadManager::Get()->GetSystemBus(), | 215 DBusThreadManager::Get()->GetSystemBus(), |
| 214 chromeos::DBusThreadManager::Get()->IsUsingStub( | 216 chromeos::DBusThreadManager::Get()->IsUsingStub( |
| 215 chromeos::DBusClientBundle::BLUETOOTH)); | 217 chromeos::DBusClientBundle::BLUETOOTH)); |
| 216 | 218 |
| 217 PowerPolicyController::Initialize( | 219 PowerPolicyController::Initialize( |
| 218 DBusThreadManager::Get()->GetPowerManagerClient()); | 220 DBusThreadManager::Get()->GetPowerManagerClient()); |
| 219 | 221 |
| 220 ScopedVector<CrosDBusService::ServiceProviderInterface> service_providers; | 222 ScopedVector<CrosDBusService::ServiceProviderInterface> service_providers; |
| 221 service_providers.push_back(ProxyResolutionServiceProvider::Create( | 223 service_providers.push_back(ProxyResolutionServiceProvider::Create( |
| 222 make_scoped_ptr(new ChromeProxyResolverDelegate()))); | 224 base::WrapUnique(new ChromeProxyResolverDelegate()))); |
| 223 service_providers.push_back(new DisplayPowerServiceProvider( | 225 service_providers.push_back(new DisplayPowerServiceProvider( |
| 224 make_scoped_ptr(new ChromeDisplayPowerServiceProviderDelegate))); | 226 base::WrapUnique(new ChromeDisplayPowerServiceProviderDelegate))); |
| 225 service_providers.push_back(new LivenessServiceProvider); | 227 service_providers.push_back(new LivenessServiceProvider); |
| 226 service_providers.push_back(new ScreenLockServiceProvider); | 228 service_providers.push_back(new ScreenLockServiceProvider); |
| 227 service_providers.push_back(new ConsoleServiceProvider( | 229 service_providers.push_back(new ConsoleServiceProvider( |
| 228 make_scoped_ptr(new ChromeConsoleServiceProviderDelegate))); | 230 base::WrapUnique(new ChromeConsoleServiceProviderDelegate))); |
| 229 service_providers.push_back(new KioskInfoService); | 231 service_providers.push_back(new KioskInfoService); |
| 230 CrosDBusService::Initialize(std::move(service_providers)); | 232 CrosDBusService::Initialize(std::move(service_providers)); |
| 231 | 233 |
| 232 // Initialize PowerDataCollector after DBusThreadManager is initialized. | 234 // Initialize PowerDataCollector after DBusThreadManager is initialized. |
| 233 PowerDataCollector::Initialize(); | 235 PowerDataCollector::Initialize(); |
| 234 | 236 |
| 235 LoginState::Initialize(); | 237 LoginState::Initialize(); |
| 236 SystemSaltGetter::Initialize(); | 238 SystemSaltGetter::Initialize(); |
| 237 TPMTokenLoader::Initialize(); | 239 TPMTokenLoader::Initialize(); |
| 238 CertLoader::Initialize(); | 240 CertLoader::Initialize(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 PowerDataCollector::Shutdown(); | 283 PowerDataCollector::Shutdown(); |
| 282 PowerPolicyController::Shutdown(); | 284 PowerPolicyController::Shutdown(); |
| 283 device::BluetoothAdapterFactory::Shutdown(); | 285 device::BluetoothAdapterFactory::Shutdown(); |
| 284 bluez::BluezDBusManager::Shutdown(); | 286 bluez::BluezDBusManager::Shutdown(); |
| 285 | 287 |
| 286 // NOTE: This must only be called if Initialize() was called. | 288 // NOTE: This must only be called if Initialize() was called. |
| 287 DBusThreadManager::Shutdown(); | 289 DBusThreadManager::Shutdown(); |
| 288 } | 290 } |
| 289 | 291 |
| 290 private: | 292 private: |
| 291 scoped_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_; | 293 std::unique_ptr<NetworkConnectDelegateChromeOS> network_connect_delegate_; |
| 292 | 294 |
| 293 DISALLOW_COPY_AND_ASSIGN(DBusServices); | 295 DISALLOW_COPY_AND_ASSIGN(DBusServices); |
| 294 }; | 296 }; |
| 295 | 297 |
| 296 } // namespace internal | 298 } // namespace internal |
| 297 | 299 |
| 298 // ChromeBrowserMainPartsChromeos ---------------------------------------------- | 300 // ChromeBrowserMainPartsChromeos ---------------------------------------------- |
| 299 | 301 |
| 300 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( | 302 ChromeBrowserMainPartsChromeos::ChromeBrowserMainPartsChromeos( |
| 301 const content::MainFunctionParams& parameters) | 303 const content::MainFunctionParams& parameters) |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 394 | 396 |
| 395 // Set the crypto thread after the IO thread has been created/started. | 397 // Set the crypto thread after the IO thread has been created/started. |
| 396 TPMTokenLoader::Get()->SetCryptoTaskRunner( | 398 TPMTokenLoader::Get()->SetCryptoTaskRunner( |
| 397 content::BrowserThread::GetMessageLoopProxyForThread( | 399 content::BrowserThread::GetMessageLoopProxyForThread( |
| 398 content::BrowserThread::IO)); | 400 content::BrowserThread::IO)); |
| 399 | 401 |
| 400 CrasAudioHandler::Initialize( | 402 CrasAudioHandler::Initialize( |
| 401 new AudioDevicesPrefHandlerImpl(g_browser_process->local_state())); | 403 new AudioDevicesPrefHandlerImpl(g_browser_process->local_state())); |
| 402 | 404 |
| 403 quirks::QuirksManager::Initialize( | 405 quirks::QuirksManager::Initialize( |
| 404 scoped_ptr<quirks::QuirksManager::Delegate>( | 406 std::unique_ptr<quirks::QuirksManager::Delegate>( |
| 405 new quirks::QuirksManagerDelegateImpl()), | 407 new quirks::QuirksManagerDelegateImpl()), |
| 406 content::BrowserThread::GetBlockingPool(), | 408 content::BrowserThread::GetBlockingPool(), |
| 407 g_browser_process->local_state(), | 409 g_browser_process->local_state(), |
| 408 g_browser_process->system_request_context()); | 410 g_browser_process->system_request_context()); |
| 409 | 411 |
| 410 // Start loading machine statistics here. StatisticsProvider::Shutdown() | 412 // Start loading machine statistics here. StatisticsProvider::Shutdown() |
| 411 // will ensure that loading is aborted on early exit. | 413 // will ensure that loading is aborted on early exit. |
| 412 bool load_oem_statistics = !StartupUtils::IsOobeCompleted(); | 414 bool load_oem_statistics = !StartupUtils::IsOobeCompleted(); |
| 413 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics( | 415 system::StatisticsProvider::GetInstance()->StartLoadingMachineStatistics( |
| 414 content::BrowserThread::GetMessageLoopProxyForThread( | 416 content::BrowserThread::GetMessageLoopProxyForThread( |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 << " with hash: " << user_id_hash; | 554 << " with hash: " << user_id_hash; |
| 553 } | 555 } |
| 554 } | 556 } |
| 555 | 557 |
| 556 class GuestLanguageSetCallbackData { | 558 class GuestLanguageSetCallbackData { |
| 557 public: | 559 public: |
| 558 explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { | 560 explicit GuestLanguageSetCallbackData(Profile* profile) : profile(profile) { |
| 559 } | 561 } |
| 560 | 562 |
| 561 // Must match SwitchLanguageCallback type. | 563 // Must match SwitchLanguageCallback type. |
| 562 static void Callback(const scoped_ptr<GuestLanguageSetCallbackData>& self, | 564 static void Callback( |
| 563 const locale_util::LanguageSwitchResult& result); | 565 const std::unique_ptr<GuestLanguageSetCallbackData>& self, |
| 566 const locale_util::LanguageSwitchResult& result); |
| 564 | 567 |
| 565 Profile* profile; | 568 Profile* profile; |
| 566 }; | 569 }; |
| 567 | 570 |
| 568 // static | 571 // static |
| 569 void GuestLanguageSetCallbackData::Callback( | 572 void GuestLanguageSetCallbackData::Callback( |
| 570 const scoped_ptr<GuestLanguageSetCallbackData>& self, | 573 const std::unique_ptr<GuestLanguageSetCallbackData>& self, |
| 571 const locale_util::LanguageSwitchResult& result) { | 574 const locale_util::LanguageSwitchResult& result) { |
| 572 input_method::InputMethodManager* manager = | 575 input_method::InputMethodManager* manager = |
| 573 input_method::InputMethodManager::Get(); | 576 input_method::InputMethodManager::Get(); |
| 574 scoped_refptr<input_method::InputMethodManager::State> ime_state = | 577 scoped_refptr<input_method::InputMethodManager::State> ime_state = |
| 575 manager->GetActiveIMEState(); | 578 manager->GetActiveIMEState(); |
| 576 // For guest mode, we should always use the first login input methods. | 579 // For guest mode, we should always use the first login input methods. |
| 577 // This is to keep consistency with UserSessionManager::SetFirstLoginPrefs(). | 580 // This is to keep consistency with UserSessionManager::SetFirstLoginPrefs(). |
| 578 // See crbug.com/530808. | 581 // See crbug.com/530808. |
| 579 std::vector<std::string> input_methods; | 582 std::vector<std::string> input_methods; |
| 580 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( | 583 manager->GetInputMethodUtil()->GetFirstLoginInputMethodIds( |
| (...skipping 19 matching lines...) Expand all Loading... |
| 600 } | 603 } |
| 601 | 604 |
| 602 // Finally, activate the first login input method. | 605 // Finally, activate the first login input method. |
| 603 const std::vector<std::string>& login_input_methods = | 606 const std::vector<std::string>& login_input_methods = |
| 604 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); | 607 manager->GetInputMethodUtil()->GetHardwareLoginInputMethodIds(); |
| 605 ime_state->ChangeInputMethod(login_input_methods[0], | 608 ime_state->ChangeInputMethod(login_input_methods[0], |
| 606 false /* show_message */); | 609 false /* show_message */); |
| 607 } | 610 } |
| 608 | 611 |
| 609 void SetGuestLocale(Profile* const profile) { | 612 void SetGuestLocale(Profile* const profile) { |
| 610 scoped_ptr<GuestLanguageSetCallbackData> data( | 613 std::unique_ptr<GuestLanguageSetCallbackData> data( |
| 611 new GuestLanguageSetCallbackData(profile)); | 614 new GuestLanguageSetCallbackData(profile)); |
| 612 locale_util::SwitchLanguageCallback callback(base::Bind( | 615 locale_util::SwitchLanguageCallback callback(base::Bind( |
| 613 &GuestLanguageSetCallbackData::Callback, base::Passed(std::move(data)))); | 616 &GuestLanguageSetCallbackData::Callback, base::Passed(std::move(data)))); |
| 614 const user_manager::User* const user = | 617 const user_manager::User* const user = |
| 615 ProfileHelper::Get()->GetUserByProfile(profile); | 618 ProfileHelper::Get()->GetUserByProfile(profile); |
| 616 UserSessionManager::GetInstance()->RespectLocalePreference( | 619 UserSessionManager::GetInstance()->RespectLocalePreference( |
| 617 profile, user, callback); | 620 profile, user, callback); |
| 618 } | 621 } |
| 619 | 622 |
| 620 void ChromeBrowserMainPartsChromeos::PostProfileInit() { | 623 void ChromeBrowserMainPartsChromeos::PostProfileInit() { |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 668 g_browser_process->platform_part()->SessionManager()->Start(); | 671 g_browser_process->platform_part()->SessionManager()->Start(); |
| 669 | 672 |
| 670 // Guest user profile is never initialized with locale settings, | 673 // Guest user profile is never initialized with locale settings, |
| 671 // so we need special handling for Guest session. | 674 // so we need special handling for Guest session. |
| 672 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) | 675 if (user_manager::UserManager::Get()->IsLoggedInAsGuest()) |
| 673 SetGuestLocale(profile()); | 676 SetGuestLocale(profile()); |
| 674 | 677 |
| 675 peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); | 678 peripheral_battery_observer_.reset(new PeripheralBatteryObserver()); |
| 676 | 679 |
| 677 renderer_freezer_.reset( | 680 renderer_freezer_.reset( |
| 678 new RendererFreezer(scoped_ptr<RendererFreezer::Delegate>( | 681 new RendererFreezer(std::unique_ptr<RendererFreezer::Delegate>( |
| 679 new FreezerCgroupProcessManager()))); | 682 new FreezerCgroupProcessManager()))); |
| 680 | 683 |
| 681 g_browser_process->platform_part()->InitializeAutomaticRebootManager(); | 684 g_browser_process->platform_part()->InitializeAutomaticRebootManager(); |
| 682 g_browser_process->platform_part()->InitializeDeviceDisablingManager(); | 685 g_browser_process->platform_part()->InitializeDeviceDisablingManager(); |
| 683 | 686 |
| 684 // This observer cannot be created earlier because it requires the shell to be | 687 // This observer cannot be created earlier because it requires the shell to be |
| 685 // available. | 688 // available. |
| 686 idle_action_warning_observer_.reset(new IdleActionWarningObserver()); | 689 idle_action_warning_observer_.reset(new IdleActionWarningObserver()); |
| 687 | 690 |
| 688 ChromeBrowserMainPartsLinux::PostProfileInit(); | 691 ChromeBrowserMainPartsLinux::PostProfileInit(); |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 735 // These are dependent on the ash::Shell singleton already having been | 738 // These are dependent on the ash::Shell singleton already having been |
| 736 // initialized. Consequently, these cannot be used when running as a mus | 739 // initialized. Consequently, these cannot be used when running as a mus |
| 737 // client. | 740 // client. |
| 738 // TODO(oshima): Remove ash dependency in PowerButtonObserver. | 741 // TODO(oshima): Remove ash dependency in PowerButtonObserver. |
| 739 // crbug.com/408832. | 742 // crbug.com/408832. |
| 740 power_button_observer_.reset(new PowerButtonObserver); | 743 power_button_observer_.reset(new PowerButtonObserver); |
| 741 data_promo_notification_.reset(new DataPromoNotification()); | 744 data_promo_notification_.reset(new DataPromoNotification()); |
| 742 | 745 |
| 743 keyboard_event_rewriters_.reset(new EventRewriterController()); | 746 keyboard_event_rewriters_.reset(new EventRewriterController()); |
| 744 keyboard_event_rewriters_->AddEventRewriter( | 747 keyboard_event_rewriters_->AddEventRewriter( |
| 745 scoped_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter())); | 748 std::unique_ptr<ui::EventRewriter>(new KeyboardDrivenEventRewriter())); |
| 746 keyboard_event_rewriters_->AddEventRewriter( | 749 keyboard_event_rewriters_->AddEventRewriter( |
| 747 scoped_ptr<ui::EventRewriter>(new SpokenFeedbackEventRewriter())); | 750 std::unique_ptr<ui::EventRewriter>(new SpokenFeedbackEventRewriter())); |
| 748 keyboard_event_rewriters_->AddEventRewriter( | 751 keyboard_event_rewriters_->AddEventRewriter( |
| 749 scoped_ptr<ui::EventRewriter>(new EventRewriter( | 752 std::unique_ptr<ui::EventRewriter>(new EventRewriter( |
| 750 ash::Shell::GetInstance()->sticky_keys_controller()))); | 753 ash::Shell::GetInstance()->sticky_keys_controller()))); |
| 751 keyboard_event_rewriters_->Init(); | 754 keyboard_event_rewriters_->Init(); |
| 752 } | 755 } |
| 753 | 756 |
| 754 ChromeBrowserMainPartsLinux::PostBrowserStart(); | 757 ChromeBrowserMainPartsLinux::PostBrowserStart(); |
| 755 } | 758 } |
| 756 | 759 |
| 757 // Shut down services before the browser process, etc are destroyed. | 760 // Shut down services before the browser process, etc are destroyed. |
| 758 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { | 761 void ChromeBrowserMainPartsChromeos::PostMainMessageLoopRun() { |
| 759 chromeos::ResourceReporter::GetInstance()->StopMonitoring(); | 762 chromeos::ResourceReporter::GetInstance()->StopMonitoring(); |
| (...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 // Destroy DBus services immediately after threads are stopped. | 876 // Destroy DBus services immediately after threads are stopped. |
| 874 dbus_services_.reset(); | 877 dbus_services_.reset(); |
| 875 | 878 |
| 876 ChromeBrowserMainPartsLinux::PostDestroyThreads(); | 879 ChromeBrowserMainPartsLinux::PostDestroyThreads(); |
| 877 | 880 |
| 878 // Destroy DeviceSettingsService after g_browser_process. | 881 // Destroy DeviceSettingsService after g_browser_process. |
| 879 DeviceSettingsService::Shutdown(); | 882 DeviceSettingsService::Shutdown(); |
| 880 } | 883 } |
| 881 | 884 |
| 882 } // namespace chromeos | 885 } // namespace chromeos |
| OLD | NEW |