• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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.
4 
5 #include "chrome/browser/browser_process_platform_part_chromeos.h"
6 
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/system/automatic_reboot_manager.h"
18 #include "chrome/browser/profiles/profile.h"
19 #include "components/session_manager/core/session_manager.h"
20 
BrowserProcessPlatformPart()21 BrowserProcessPlatformPart::BrowserProcessPlatformPart()
22     : created_profile_helper_(false) {
23 }
24 
~BrowserProcessPlatformPart()25 BrowserProcessPlatformPart::~BrowserProcessPlatformPart() {
26 }
27 
InitializeAutomaticRebootManager()28 void BrowserProcessPlatformPart::InitializeAutomaticRebootManager() {
29   DCHECK(!automatic_reboot_manager_);
30 
31   automatic_reboot_manager_.reset(new chromeos::system::AutomaticRebootManager(
32       scoped_ptr<base::TickClock>(new base::DefaultTickClock)));
33 }
34 
ShutdownAutomaticRebootManager()35 void BrowserProcessPlatformPart::ShutdownAutomaticRebootManager() {
36   automatic_reboot_manager_.reset();
37 }
38 
InitializeChromeUserManager()39 void BrowserProcessPlatformPart::InitializeChromeUserManager() {
40   DCHECK(!chrome_user_manager_);
41   chrome_user_manager_ =
42       chromeos::ChromeUserManagerImpl::CreateChromeUserManager();
43   chrome_user_manager_->Initialize();
44 }
45 
DestroyChromeUserManager()46 void BrowserProcessPlatformPart::DestroyChromeUserManager() {
47   chrome_user_manager_->Destroy();
48   chrome_user_manager_.reset();
49 }
50 
InitializeSessionManager(const base::CommandLine & parsed_command_line,Profile * profile,bool is_running_test)51 void BrowserProcessPlatformPart::InitializeSessionManager(
52     const base::CommandLine& parsed_command_line,
53     Profile* profile,
54     bool is_running_test) {
55   DCHECK(!session_manager_);
56   session_manager_ = chromeos::ChromeSessionManager::CreateSessionManager(
57       parsed_command_line, profile, is_running_test);
58 }
59 
ShutdownSessionManager()60 void BrowserProcessPlatformPart::ShutdownSessionManager() {
61   session_manager_.reset();
62 }
63 
SessionManager()64 session_manager::SessionManager* BrowserProcessPlatformPart::SessionManager() {
65   DCHECK(CalledOnValidThread());
66   return session_manager_.get();
67 }
68 
69 chromeos::OomPriorityManager*
oom_priority_manager()70     BrowserProcessPlatformPart::oom_priority_manager() {
71   DCHECK(CalledOnValidThread());
72   if (!oom_priority_manager_.get())
73     oom_priority_manager_.reset(new chromeos::OomPriorityManager());
74   return oom_priority_manager_.get();
75 }
76 
profile_helper()77 chromeos::ProfileHelper* BrowserProcessPlatformPart::profile_helper() {
78   DCHECK(CalledOnValidThread());
79   if (!created_profile_helper_)
80     CreateProfileHelper();
81   return profile_helper_.get();
82 }
83 
84 policy::BrowserPolicyConnectorChromeOS*
browser_policy_connector_chromeos()85 BrowserProcessPlatformPart::browser_policy_connector_chromeos() {
86   return static_cast<policy::BrowserPolicyConnectorChromeOS*>(
87       g_browser_process->browser_policy_connector());
88 }
89 
StartTearDown()90 void BrowserProcessPlatformPart::StartTearDown() {
91   profile_helper_.reset();
92 }
93 
94 scoped_ptr<policy::BrowserPolicyConnector>
CreateBrowserPolicyConnector()95 BrowserProcessPlatformPart::CreateBrowserPolicyConnector() {
96   return scoped_ptr<policy::BrowserPolicyConnector>(
97       new policy::BrowserPolicyConnectorChromeOS());
98 }
99 
CreateProfileHelper()100 void BrowserProcessPlatformPart::CreateProfileHelper() {
101   DCHECK(!created_profile_helper_ && profile_helper_.get() == NULL);
102   created_profile_helper_ = true;
103   profile_helper_.reset(new chromeos::ProfileHelper());
104 }
105