Roll src/third_party/WebKit 4652693:6e25bba (svn 187518:187521)
[chromium-blink-merge.git] / chrome / browser / browser_process_platform_part_chromeos.cc
blob9ae7863744c1f7a3376b9ef05e2fd6629ce9fdf4
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
3 // found in the LICENSE file.
5 #include "chrome/browser/browser_process_platform_part_chromeos.h"
7 #include "base/command_line.h"
8 #include "base/logging.h"
9 #include "base/time/default_tick_clock.h"
10 #include "base/time/tick_clock.h"
11 #include "chrome/browser/browser_process.h"
12 #include "chrome/browser/chromeos/login/session/chrome_session_manager.h"
13 #include "chrome/browser/chromeos/login/users/chrome_user_manager_impl.h"
14 #include "chrome/browser/chromeos/memory/oom_priority_manager.h"
15 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
16 #include "chrome/browser/chromeos/profiles/profile_helper.h"
17 #include "chrome/browser/chromeos/settings/cros_settings.h"
18 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
19 #include "chrome/browser/chromeos/system/device_disabling_manager.h"
20 #include "chrome/browser/chromeos/system/device_disabling_manager_default_delegate.h"
21 #include "chrome/browser/profiles/profile.h"
22 #include "components/session_manager/core/session_manager.h"
23 #include "components/user_manager/user_manager.h"
25 BrowserProcessPlatformPart::BrowserProcessPlatformPart()
26 : created_profile_helper_(false) {
29 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
32 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() {
33 DCHECK(!automatic_reboot_manager_);
35 automatic_reboot_manager_.reset(new chromeos::system::AutomaticRebootManager(
36 scoped_ptr<base::TickClock>(new base::DefaultTickClock)));
39 void BrowserProcessPlatformPart::ShutdownAutomaticRebootManager() {
40 automatic_reboot_manager_.reset();
43 void BrowserProcessPlatformPart::InitializeChromeUserManager() {
44 DCHECK(!chrome_user_manager_);
45 chrome_user_manager_ =
46 chromeos::ChromeUserManagerImpl::CreateChromeUserManager();
47 chrome_user_manager_->Initialize();
50 void BrowserProcessPlatformPart::DestroyChromeUserManager() {
51 chrome_user_manager_->Destroy();
52 chrome_user_manager_.reset();
55 void BrowserProcessPlatformPart::InitializeDeviceDisablingManager() {
56 DCHECK(!device_disabling_manager_);
58 device_disabling_manager_delegate_.reset(
59 new chromeos::system::DeviceDisablingManagerDefaultDelegate);
60 device_disabling_manager_.reset(new chromeos::system::DeviceDisablingManager(
61 device_disabling_manager_delegate_.get(),
62 chromeos::CrosSettings::Get(),
63 user_manager::UserManager::Get()));
66 void BrowserProcessPlatformPart::ShutdownDeviceDisablingManager() {
67 device_disabling_manager_.reset();
68 device_disabling_manager_delegate_.reset();
71 void BrowserProcessPlatformPart::InitializeSessionManager(
72 const base::CommandLine& parsed_command_line,
73 Profile* profile,
74 bool is_running_test) {
75 DCHECK(!session_manager_);
76 session_manager_ = chromeos::ChromeSessionManager::CreateSessionManager(
77 parsed_command_line, profile, is_running_test);
80 void BrowserProcessPlatformPart::ShutdownSessionManager() {
81 session_manager_.reset();
84 session_manager::SessionManager* BrowserProcessPlatformPart::SessionManager() {
85 DCHECK(CalledOnValidThread());
86 return session_manager_.get();
89 chromeos::OomPriorityManager*
90 BrowserProcessPlatformPart::oom_priority_manager() {
91 DCHECK(CalledOnValidThread());
92 if (!oom_priority_manager_.get())
93 oom_priority_manager_.reset(new chromeos::OomPriorityManager());
94 return oom_priority_manager_.get();
97 chromeos::ProfileHelper* BrowserProcessPlatformPart::profile_helper() {
98 DCHECK(CalledOnValidThread());
99 if (!created_profile_helper_)
100 CreateProfileHelper();
101 return profile_helper_.get();
104 policy::BrowserPolicyConnectorChromeOS*
105 BrowserProcessPlatformPart::browser_policy_connector_chromeos() {
106 return static_cast<policy::BrowserPolicyConnectorChromeOS*>(
107 g_browser_process->browser_policy_connector());
110 void BrowserProcessPlatformPart::StartTearDown() {
111 profile_helper_.reset();
114 scoped_ptr<policy::BrowserPolicyConnector>
115 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() {
116 return scoped_ptr<policy::BrowserPolicyConnector>(
117 new policy::BrowserPolicyConnectorChromeOS());
120 void BrowserProcessPlatformPart::CreateProfileHelper() {
121 DCHECK(!created_profile_helper_ && profile_helper_.get() == NULL);
122 created_profile_helper_ = true;
123 profile_helper_.reset(new chromeos::ProfileHelper());