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 21BrowserProcessPlatformPart::BrowserProcessPlatformPart() 22 : created_profile_helper_(false) { 23} 24 25BrowserProcessPlatformPart::~BrowserProcessPlatformPart() { 26} 27 28void 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 35void BrowserProcessPlatformPart::ShutdownAutomaticRebootManager() { 36 automatic_reboot_manager_.reset(); 37} 38 39void BrowserProcessPlatformPart::InitializeChromeUserManager() { 40 DCHECK(!chrome_user_manager_); 41 chrome_user_manager_ = 42 chromeos::ChromeUserManagerImpl::CreateChromeUserManager(); 43 chrome_user_manager_->Initialize(); 44} 45 46void BrowserProcessPlatformPart::DestroyChromeUserManager() { 47 chrome_user_manager_->Destroy(); 48 chrome_user_manager_.reset(); 49} 50 51void 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 60void BrowserProcessPlatformPart::ShutdownSessionManager() { 61 session_manager_.reset(); 62} 63 64session_manager::SessionManager* BrowserProcessPlatformPart::SessionManager() { 65 DCHECK(CalledOnValidThread()); 66 return session_manager_.get(); 67} 68 69chromeos::OomPriorityManager* 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 77chromeos::ProfileHelper* BrowserProcessPlatformPart::profile_helper() { 78 DCHECK(CalledOnValidThread()); 79 if (!created_profile_helper_) 80 CreateProfileHelper(); 81 return profile_helper_.get(); 82} 83 84policy::BrowserPolicyConnectorChromeOS* 85BrowserProcessPlatformPart::browser_policy_connector_chromeos() { 86 return static_cast<policy::BrowserPolicyConnectorChromeOS*>( 87 g_browser_process->browser_policy_connector()); 88} 89 90void BrowserProcessPlatformPart::StartTearDown() { 91 profile_helper_.reset(); 92} 93 94scoped_ptr<policy::BrowserPolicyConnector> 95BrowserProcessPlatformPart::CreateBrowserPolicyConnector() { 96 return scoped_ptr<policy::BrowserPolicyConnector>( 97 new policy::BrowserPolicyConnectorChromeOS()); 98} 99 100void 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