Remove no longer needed toolbar layer method.
[chromium-blink-merge.git] / chrome / browser / browser_process_platform_part_chromeos.cc
blob520ba39318fb3ac0a359fef52c7e6e3fb0b614ed
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/net/delay_network_call.h"
16 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
17 #include "chrome/browser/chromeos/profiles/profile_helper.h"
18 #include "chrome/browser/chromeos/settings/cros_settings.h"
19 #include "chrome/browser/chromeos/system/automatic_reboot_manager.h"
20 #include "chrome/browser/chromeos/system/device_disabling_manager.h"
21 #include "chrome/browser/chromeos/system/device_disabling_manager_default_delegate.h"
22 #include "chrome/browser/chromeos/system/timezone_util.h"
23 #include "chrome/browser/profiles/profile.h"
24 #include "chromeos/geolocation/simple_geolocation_provider.h"
25 #include "chromeos/timezone/timezone_resolver.h"
26 #include "components/session_manager/core/session_manager.h"
27 #include "components/user_manager/user_manager.h"
29 BrowserProcessPlatformPart::BrowserProcessPlatformPart()
30 : created_profile_helper_(false) {
33 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
36 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() {
37 DCHECK(!automatic_reboot_manager_);
39 automatic_reboot_manager_.reset(new chromeos::system::AutomaticRebootManager(
40 scoped_ptr<base::TickClock>(new base::DefaultTickClock)));
43 void BrowserProcessPlatformPart::ShutdownAutomaticRebootManager() {
44 automatic_reboot_manager_.reset();
47 void BrowserProcessPlatformPart::InitializeChromeUserManager() {
48 DCHECK(!chrome_user_manager_);
49 chrome_user_manager_ =
50 chromeos::ChromeUserManagerImpl::CreateChromeUserManager();
51 chrome_user_manager_->Initialize();
54 void BrowserProcessPlatformPart::DestroyChromeUserManager() {
55 chrome_user_manager_->Destroy();
56 chrome_user_manager_.reset();
59 void BrowserProcessPlatformPart::InitializeDeviceDisablingManager() {
60 DCHECK(!device_disabling_manager_);
62 device_disabling_manager_delegate_.reset(
63 new chromeos::system::DeviceDisablingManagerDefaultDelegate);
64 device_disabling_manager_.reset(new chromeos::system::DeviceDisablingManager(
65 device_disabling_manager_delegate_.get(),
66 chromeos::CrosSettings::Get(),
67 user_manager::UserManager::Get()));
70 void BrowserProcessPlatformPart::ShutdownDeviceDisablingManager() {
71 device_disabling_manager_.reset();
72 device_disabling_manager_delegate_.reset();
75 void BrowserProcessPlatformPart::InitializeSessionManager(
76 const base::CommandLine& parsed_command_line,
77 Profile* profile,
78 bool is_running_test) {
79 DCHECK(!session_manager_);
80 session_manager_ = chromeos::ChromeSessionManager::CreateSessionManager(
81 parsed_command_line, profile, is_running_test);
84 void BrowserProcessPlatformPart::ShutdownSessionManager() {
85 session_manager_.reset();
88 session_manager::SessionManager* BrowserProcessPlatformPart::SessionManager() {
89 DCHECK(CalledOnValidThread());
90 return session_manager_.get();
93 chromeos::OomPriorityManager*
94 BrowserProcessPlatformPart::oom_priority_manager() {
95 DCHECK(CalledOnValidThread());
96 if (!oom_priority_manager_.get())
97 oom_priority_manager_.reset(new chromeos::OomPriorityManager());
98 return oom_priority_manager_.get();
101 chromeos::ProfileHelper* BrowserProcessPlatformPart::profile_helper() {
102 DCHECK(CalledOnValidThread());
103 if (!created_profile_helper_)
104 CreateProfileHelper();
105 return profile_helper_.get();
108 policy::BrowserPolicyConnectorChromeOS*
109 BrowserProcessPlatformPart::browser_policy_connector_chromeos() {
110 return static_cast<policy::BrowserPolicyConnectorChromeOS*>(
111 g_browser_process->browser_policy_connector());
114 chromeos::TimeZoneResolver* BrowserProcessPlatformPart::GetTimezoneResolver() {
115 if (!timezone_resolver_.get()) {
116 timezone_resolver_.reset(new chromeos::TimeZoneResolver(
117 g_browser_process->system_request_context(),
118 chromeos::SimpleGeolocationProvider::DefaultGeolocationProviderURL(),
119 base::Bind(&chromeos::system::ApplyTimeZone),
120 base::Bind(&chromeos::DelayNetworkCall,
121 base::TimeDelta::FromMilliseconds(
122 chromeos::kDefaultNetworkRetryDelayMS)),
123 g_browser_process->local_state()));
125 return timezone_resolver_.get();
128 void BrowserProcessPlatformPart::StartTearDown() {
129 // interactive_ui_tests check for memory leaks before this object is
130 // destroyed. So we need to destroy |timezone_resolver_| here.
131 timezone_resolver_.reset();
132 profile_helper_.reset();
135 scoped_ptr<policy::BrowserPolicyConnector>
136 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() {
137 return scoped_ptr<policy::BrowserPolicyConnector>(
138 new policy::BrowserPolicyConnectorChromeOS());
141 void BrowserProcessPlatformPart::CreateProfileHelper() {
142 DCHECK(!created_profile_helper_ && profile_helper_.get() == NULL);
143 created_profile_helper_ = true;
144 profile_helper_.reset(new chromeos::ProfileHelper());