| 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/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" | 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chrom
eos.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| 11 #include "chrome/browser/browser_process.h" | 11 #include "chrome/browser/browser_process.h" |
| 12 #include "chrome/browser/chromeos/login/user.h" | 12 #include "chrome/browser/chromeos/login/user.h" |
| 13 #include "chrome/browser/chromeos/login/user_manager.h" | 13 #include "chrome/browser/chromeos/login/user_manager.h" |
| 14 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 14 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 15 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 16 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 17 #include "chrome/browser/policy/browser_policy_connector.h" | 17 #include "chrome/browser/policy/browser_policy_connector.h" |
| 18 #include "chrome/browser/policy/cloud/cloud_policy_manager.h" | |
| 19 #include "chrome/browser/policy/cloud/device_management_service.h" | 18 #include "chrome/browser/policy/cloud/device_management_service.h" |
| 20 #include "chrome/browser/policy/cloud/resource_cache.h" | 19 #include "chrome/browser/policy/cloud/resource_cache.h" |
| 21 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 22 #include "chrome/browser/profiles/profile_dependency_manager.h" | 21 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 23 #include "chrome/common/chrome_switches.h" | 22 #include "chrome/common/chrome_switches.h" |
| 24 #include "chromeos/chromeos_paths.h" | 23 #include "chromeos/chromeos_paths.h" |
| 25 #include "chromeos/chromeos_switches.h" | 24 #include "chromeos/chromeos_switches.h" |
| 26 #include "chromeos/dbus/dbus_thread_manager.h" | 25 #include "chromeos/dbus/dbus_thread_manager.h" |
| 27 #include "net/url_request/url_request_context_getter.h" | 26 #include "net/url_request/url_request_context_getter.h" |
| 28 | 27 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 if (chromeos::ProfileHelper::IsSigninProfile(profile)) | 90 if (chromeos::ProfileHelper::IsSigninProfile(profile)) |
| 92 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 91 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
| 93 | 92 |
| 94 // |user| should never be NULL except for the signin profile. This object is | 93 // |user| should never be NULL except for the signin profile. This object is |
| 95 // created as part of the Profile creation, which happens right after | 94 // created as part of the Profile creation, which happens right after |
| 96 // sign-in. The just-signed-in User is the active user during that time. | 95 // sign-in. The just-signed-in User is the active user during that time. |
| 97 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); | 96 chromeos::UserManager* user_manager = chromeos::UserManager::Get(); |
| 98 chromeos::User* user = user_manager->GetActiveUser(); | 97 chromeos::User* user = user_manager->GetActiveUser(); |
| 99 CHECK(user); | 98 CHECK(user); |
| 100 | 99 |
| 101 // TODO(joaodasilva): Initialize user policy for all accounts once the session | |
| 102 // manager is ready for multi-profile policy. Note that there can still be | |
| 103 // only one delegate for the global user policy provider. | |
| 104 // http://crbug.com/230349 | |
| 105 const bool is_primary_user = | |
| 106 chromeos::UserManager::Get()->GetLoggedInUsers().size() == 1; | |
| 107 // Only USER_TYPE_REGULAR users have user cloud policy. | 100 // Only USER_TYPE_REGULAR users have user cloud policy. |
| 108 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP and USER_TYPE_GUEST are not | 101 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP and USER_TYPE_GUEST are not |
| 109 // signed in and can't authenticate the policy registration. | 102 // signed in and can't authenticate the policy registration. |
| 110 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the | 103 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the |
| 111 // DeviceLocalAccountPolicyService. | 104 // DeviceLocalAccountPolicyService. |
| 112 // USER_TYPE_LOCALLY_MANAGED gets its policy from the | 105 // USER_TYPE_LOCALLY_MANAGED gets its policy from the |
| 113 // ManagedModePolicyProvider. | 106 // ManagedModePolicyProvider. |
| 114 const std::string& username = user->email(); | 107 const std::string& username = user->email(); |
| 115 if (!is_primary_user || | 108 if (user->GetType() != chromeos::User::USER_TYPE_REGULAR || |
| 116 user->GetType() != chromeos::User::USER_TYPE_REGULAR || | |
| 117 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { | 109 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { |
| 118 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 110 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
| 119 } | 111 } |
| 120 | 112 |
| 121 BrowserPolicyConnector* connector = | 113 BrowserPolicyConnector* connector = |
| 122 g_browser_process->browser_policy_connector(); | 114 g_browser_process->browser_policy_connector(); |
| 123 UserAffiliation affiliation = connector->GetUserAffiliation(username); | 115 UserAffiliation affiliation = connector->GetUserAffiliation(username); |
| 124 const bool is_managed_user = affiliation == USER_AFFILIATION_MANAGED; | 116 const bool is_managed_user = affiliation == USER_AFFILIATION_MANAGED; |
| 125 const bool is_browser_restart = | 117 const bool is_browser_restart = |
| 126 command_line->HasSwitch(chromeos::switches::kLoginUser) && | 118 command_line->HasSwitch(chromeos::switches::kLoginUser) && |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 181 ProfileKeyedBaseFactory::ProfileDestroyed(context); | 173 ProfileKeyedBaseFactory::ProfileDestroyed(context); |
| 182 } | 174 } |
| 183 | 175 |
| 184 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( | 176 void UserCloudPolicyManagerFactoryChromeOS::SetEmptyTestingFactory( |
| 185 content::BrowserContext* context) {} | 177 content::BrowserContext* context) {} |
| 186 | 178 |
| 187 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 179 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
| 188 content::BrowserContext* context) {} | 180 content::BrowserContext* context) {} |
| 189 | 181 |
| 190 } // namespace policy | 182 } // namespace policy |
| OLD | NEW |