| 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/policy/profile_policy_connector.h" | 5 #include "chrome/browser/policy/profile_policy_connector.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| 11 #include "chrome/browser/policy/browser_policy_connector.h" | 11 #include "chrome/browser/policy/browser_policy_connector.h" |
| 12 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" | 12 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" |
| 13 #include "chrome/browser/policy/configuration_policy_provider.h" | 13 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 14 #include "chrome/browser/policy/policy_service.h" | 14 #include "chrome/browser/policy/policy_service.h" |
| 15 | 15 |
| 16 #if defined(OS_CHROMEOS) | 16 #if defined(OS_CHROMEOS) |
| 17 #include "base/bind.h" | |
| 18 #include "base/prefs/pref_service.h" | |
| 19 #include "chrome/browser/chromeos/login/user.h" | 17 #include "chrome/browser/chromeos/login/user.h" |
| 20 #include "chrome/browser/chromeos/login/user_manager.h" | 18 #include "chrome/browser/chromeos/login/user_manager.h" |
| 21 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" | 19 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
| 22 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" | 20 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" |
| 23 #include "chrome/browser/policy/policy_service.h" | 21 #include "chrome/browser/policy/policy_service.h" |
| 24 #include "chrome/common/pref_names.h" | |
| 25 #endif | 22 #endif |
| 26 | 23 |
| 27 namespace policy { | 24 namespace policy { |
| 28 | 25 |
| 29 ProfilePolicyConnector::ProfilePolicyConnector(Profile* profile) | 26 ProfilePolicyConnector::ProfilePolicyConnector() |
| 30 : | |
| 31 #if defined(OS_CHROMEOS) | 27 #if defined(OS_CHROMEOS) |
| 32 is_primary_user_(false), | 28 : is_primary_user_(false) |
| 33 weak_ptr_factory_(this), | |
| 34 #endif | 29 #endif |
| 35 profile_(profile) {} | 30 {} |
| 36 | 31 |
| 37 ProfilePolicyConnector::~ProfilePolicyConnector() {} | 32 ProfilePolicyConnector::~ProfilePolicyConnector() {} |
| 38 | 33 |
| 39 void ProfilePolicyConnector::Init( | 34 void ProfilePolicyConnector::Init( |
| 40 bool force_immediate_load, | 35 bool force_immediate_load, |
| 41 #if defined(OS_CHROMEOS) | 36 #if defined(OS_CHROMEOS) |
| 42 const chromeos::User* user, | 37 const chromeos::User* user, |
| 43 #endif | 38 #endif |
| 44 CloudPolicyManager* user_cloud_policy_manager) { | 39 CloudPolicyManager* user_cloud_policy_manager) { |
| 45 BrowserPolicyConnector* connector = | 40 BrowserPolicyConnector* connector = |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 86 void ProfilePolicyConnector::Shutdown() { | 81 void ProfilePolicyConnector::Shutdown() { |
| 87 #if defined(OS_CHROMEOS) | 82 #if defined(OS_CHROMEOS) |
| 88 if (is_primary_user_) | 83 if (is_primary_user_) |
| 89 g_browser_process->browser_policy_connector()->SetUserPolicyDelegate(NULL); | 84 g_browser_process->browser_policy_connector()->SetUserPolicyDelegate(NULL); |
| 90 if (special_user_policy_provider_) | 85 if (special_user_policy_provider_) |
| 91 special_user_policy_provider_->Shutdown(); | 86 special_user_policy_provider_->Shutdown(); |
| 92 #endif | 87 #endif |
| 93 } | 88 } |
| 94 | 89 |
| 95 #if defined(OS_CHROMEOS) | 90 #if defined(OS_CHROMEOS) |
| 96 base::Closure ProfilePolicyConnector::GetPolicyCertTrustedCallback() { | |
| 97 return base::Bind(&ProfilePolicyConnector::SetUsedPolicyCertificatesOnce, | |
| 98 weak_ptr_factory_.GetWeakPtr()); | |
| 99 } | |
| 100 #endif | |
| 101 | |
| 102 bool ProfilePolicyConnector::UsedPolicyCertificates() { | |
| 103 #if defined(OS_CHROMEOS) | |
| 104 return profile_->GetPrefs()->GetBoolean(prefs::kUsedPolicyCertificatesOnce); | |
| 105 #else | |
| 106 return false; | |
| 107 #endif | |
| 108 } | |
| 109 | |
| 110 #if defined(OS_CHROMEOS) | |
| 111 void ProfilePolicyConnector::SetUsedPolicyCertificatesOnce() { | |
| 112 profile_->GetPrefs()->SetBoolean(prefs::kUsedPolicyCertificatesOnce, true); | |
| 113 } | |
| 114 | |
| 115 void ProfilePolicyConnector::InitializeDeviceLocalAccountPolicyProvider( | 91 void ProfilePolicyConnector::InitializeDeviceLocalAccountPolicyProvider( |
| 116 const std::string& username) { | 92 const std::string& username) { |
| 117 BrowserPolicyConnector* connector = | 93 BrowserPolicyConnector* connector = |
| 118 g_browser_process->browser_policy_connector(); | 94 g_browser_process->browser_policy_connector(); |
| 119 DeviceLocalAccountPolicyService* device_local_account_policy_service = | 95 DeviceLocalAccountPolicyService* device_local_account_policy_service = |
| 120 connector->GetDeviceLocalAccountPolicyService(); | 96 connector->GetDeviceLocalAccountPolicyService(); |
| 121 if (!device_local_account_policy_service) | 97 if (!device_local_account_policy_service) |
| 122 return; | 98 return; |
| 123 special_user_policy_provider_.reset(new DeviceLocalAccountPolicyProvider( | 99 special_user_policy_provider_.reset(new DeviceLocalAccountPolicyProvider( |
| 124 username, device_local_account_policy_service)); | 100 username, device_local_account_policy_service)); |
| 125 special_user_policy_provider_->Init(); | 101 special_user_policy_provider_->Init(); |
| 126 } | 102 } |
| 127 #endif | 103 #endif |
| 128 | 104 |
| 129 } // namespace policy | 105 } // namespace policy |
| OLD | NEW |