| 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/configuration_policy_provider.h" | 12 #include "chrome/browser/policy/configuration_policy_provider.h" |
| 13 #include "chrome/browser/policy/policy_service_impl.h" | 13 #include "chrome/browser/policy/policy_service_impl.h" |
| 14 #include "chrome/browser/policy/schema_registry_service.h" |
| 15 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 14 | 16 |
| 15 #if defined(OS_CHROMEOS) | 17 #if defined(OS_CHROMEOS) |
| 16 #include "base/bind.h" | 18 #include "base/bind.h" |
| 17 #include "base/prefs/pref_service.h" | 19 #include "base/prefs/pref_service.h" |
| 18 #include "chrome/browser/chromeos/login/user.h" | 20 #include "chrome/browser/chromeos/login/user.h" |
| 19 #include "chrome/browser/chromeos/login/user_manager.h" | 21 #include "chrome/browser/chromeos/login/user_manager.h" |
| 20 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" | 22 #include "chrome/browser/chromeos/policy/device_local_account_policy_provider.h" |
| 21 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" | 23 #include "chrome/browser/chromeos/policy/login_profile_policy_provider.h" |
| 22 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 25 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 UserCloudPolicyManagerChromeOS* cloud_policy_manager = | 57 UserCloudPolicyManagerChromeOS* cloud_policy_manager = |
| 56 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile_); | 58 UserCloudPolicyManagerFactoryChromeOS::GetForProfile(profile_); |
| 57 if (cloud_policy_manager) | 59 if (cloud_policy_manager) |
| 58 providers.push_back(cloud_policy_manager); | 60 providers.push_back(cloud_policy_manager); |
| 59 | 61 |
| 60 bool allow_trusted_certs_from_policy = false; | 62 bool allow_trusted_certs_from_policy = false; |
| 61 chromeos::User* user = NULL; | 63 chromeos::User* user = NULL; |
| 62 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { | 64 if (chromeos::ProfileHelper::IsSigninProfile(profile_)) { |
| 63 special_user_policy_provider_.reset(new LoginProfilePolicyProvider( | 65 special_user_policy_provider_.reset(new LoginProfilePolicyProvider( |
| 64 connector->GetPolicyService())); | 66 connector->GetPolicyService())); |
| 65 special_user_policy_provider_->Init(); | 67 special_user_policy_provider_->Init( |
| 68 SchemaRegistryServiceFactory::GetForContext(profile_)); |
| 66 } else { | 69 } else { |
| 67 // |user| should never be NULL except for the signin profile. | 70 // |user| should never be NULL except for the signin profile. |
| 68 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 71 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 69 user = user_manager->GetUserByProfile(profile_); | 72 user = user_manager->GetUserByProfile(profile_); |
| 70 CHECK(user); | 73 CHECK(user); |
| 71 std::string username = user->email(); | 74 std::string username = user->email(); |
| 72 is_primary_user_ = | 75 is_primary_user_ = |
| 73 chromeos::UserManager::Get()->GetLoggedInUsers().size() == 1; | 76 chromeos::UserManager::Get()->GetLoggedInUsers().size() == 1; |
| 74 if (user->GetType() == chromeos::User::USER_TYPE_PUBLIC_ACCOUNT) | 77 if (user->GetType() == chromeos::User::USER_TYPE_PUBLIC_ACCOUNT) |
| 75 InitializeDeviceLocalAccountPolicyProvider(username); | 78 InitializeDeviceLocalAccountPolicyProvider(username); |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 163 void ProfilePolicyConnector::InitializeDeviceLocalAccountPolicyProvider( | 166 void ProfilePolicyConnector::InitializeDeviceLocalAccountPolicyProvider( |
| 164 const std::string& username) { | 167 const std::string& username) { |
| 165 BrowserPolicyConnector* connector = | 168 BrowserPolicyConnector* connector = |
| 166 g_browser_process->browser_policy_connector(); | 169 g_browser_process->browser_policy_connector(); |
| 167 DeviceLocalAccountPolicyService* device_local_account_policy_service = | 170 DeviceLocalAccountPolicyService* device_local_account_policy_service = |
| 168 connector->GetDeviceLocalAccountPolicyService(); | 171 connector->GetDeviceLocalAccountPolicyService(); |
| 169 if (!device_local_account_policy_service) | 172 if (!device_local_account_policy_service) |
| 170 return; | 173 return; |
| 171 special_user_policy_provider_.reset(new DeviceLocalAccountPolicyProvider( | 174 special_user_policy_provider_.reset(new DeviceLocalAccountPolicyProvider( |
| 172 username, device_local_account_policy_service)); | 175 username, device_local_account_policy_service)); |
| 173 special_user_policy_provider_->Init(); | 176 special_user_policy_provider_->Init( |
| 177 SchemaRegistryServiceFactory::GetForContext(profile_)); |
| 174 } | 178 } |
| 175 #endif | 179 #endif |
| 176 | 180 |
| 177 } // namespace policy | 181 } // namespace policy |
| OLD | NEW |