| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/memory/ref_counted.h" | 11 #include "base/memory/ref_counted.h" |
| 12 #include "base/message_loop/message_loop_proxy.h" | 12 #include "base/message_loop/message_loop_proxy.h" |
| 13 #include "base/path_service.h" | 13 #include "base/path_service.h" |
| 14 #include "base/sequenced_task_runner.h" | 14 #include "base/sequenced_task_runner.h" |
| 15 #include "base/threading/sequenced_worker_pool.h" | 15 #include "base/threading/sequenced_worker_pool.h" |
| 16 #include "base/time/time.h" | 16 #include "base/time/time.h" |
| 17 #include "chrome/browser/browser_process.h" | 17 #include "chrome/browser/browser_process.h" |
| 18 #include "chrome/browser/chromeos/login/login_utils.h" | 18 #include "chrome/browser/chromeos/login/login_utils.h" |
| 19 #include "chrome/browser/chromeos/login/users/user.h" | 19 #include "chrome/browser/chromeos/login/users/user.h" |
| 20 #include "chrome/browser/chromeos/login/users/user_manager.h" |
| 20 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" | 21 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h" |
| 21 #include "chrome/browser/chromeos/policy/user_cloud_external_data_manager.h" | 22 #include "chrome/browser/chromeos/policy/user_cloud_external_data_manager.h" |
| 22 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" | 23 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h" |
| 23 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" | 24 #include "chrome/browser/chromeos/policy/user_cloud_policy_store_chromeos.h" |
| 24 #include "chrome/browser/chromeos/profiles/profile_helper.h" | 25 #include "chrome/browser/chromeos/profiles/profile_helper.h" |
| 25 #include "chrome/browser/policy/schema_registry_service.h" | 26 #include "chrome/browser/policy/schema_registry_service.h" |
| 26 #include "chrome/browser/policy/schema_registry_service_factory.h" | 27 #include "chrome/browser/policy/schema_registry_service_factory.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 28 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chromeos/chromeos_paths.h" | 29 #include "chromeos/chromeos_paths.h" |
| 29 #include "chromeos/chromeos_switches.h" | 30 #include "chromeos/chromeos_switches.h" |
| 30 #include "chromeos/dbus/dbus_thread_manager.h" | 31 #include "chromeos/dbus/dbus_thread_manager.h" |
| 31 #include "components/keyed_service/content/browser_context_dependency_manager.h" | 32 #include "components/keyed_service/content/browser_context_dependency_manager.h" |
| 33 #include "components/policy/core/browser/browser_policy_connector.h" |
| 32 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" | 34 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" |
| 33 #include "components/policy/core/common/cloud/device_management_service.h" | 35 #include "components/policy/core/common/cloud/device_management_service.h" |
| 34 #include "components/user_manager/user_type.h" | 36 #include "components/user_manager/user_type.h" |
| 35 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 36 #include "net/url_request/url_request_context_getter.h" | 38 #include "net/url_request/url_request_context_getter.h" |
| 37 #include "policy/policy_constants.h" | 39 #include "policy/policy_constants.h" |
| 38 | 40 |
| 39 namespace policy { | 41 namespace policy { |
| 40 | 42 |
| 41 namespace { | 43 namespace { |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 126 chromeos::User* user = | 128 chromeos::User* user = |
| 127 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); | 129 chromeos::ProfileHelper::Get()->GetUserByProfile(profile); |
| 128 CHECK(user); | 130 CHECK(user); |
| 129 | 131 |
| 130 // Only USER_TYPE_REGULAR users have user cloud policy. | 132 // Only USER_TYPE_REGULAR users have user cloud policy. |
| 131 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP, USER_TYPE_GUEST and | 133 // USER_TYPE_RETAIL_MODE, USER_TYPE_KIOSK_APP, USER_TYPE_GUEST and |
| 132 // USER_TYPE_LOCALLY_MANAGED are not signed in and can't authenticate the | 134 // USER_TYPE_LOCALLY_MANAGED are not signed in and can't authenticate the |
| 133 // policy registration. | 135 // policy registration. |
| 134 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the | 136 // USER_TYPE_PUBLIC_ACCOUNT gets its policy from the |
| 135 // DeviceLocalAccountPolicyService. | 137 // DeviceLocalAccountPolicyService. |
| 138 // Non-managed domains will be skipped by the below check |
| 136 const std::string& username = user->email(); | 139 const std::string& username = user->email(); |
| 137 if (user->GetType() != user_manager::USER_TYPE_REGULAR || | 140 if (user->GetType() != user_manager::USER_TYPE_REGULAR || |
| 138 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { | 141 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { |
| 139 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 142 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
| 140 } | 143 } |
| 141 | 144 |
| 142 policy::BrowserPolicyConnectorChromeOS* connector = | 145 policy::BrowserPolicyConnectorChromeOS* connector = |
| 143 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 146 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
| 144 UserAffiliation affiliation = connector->GetUserAffiliation(username); | 147 UserAffiliation affiliation = connector->GetUserAffiliation(username); |
| 145 const bool is_managed_user = affiliation == USER_AFFILIATION_MANAGED; | 148 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED; |
| 146 const bool is_browser_restart = | 149 const bool is_browser_restart = |
| 147 command_line->HasSwitch(chromeos::switches::kLoginUser); | 150 command_line->HasSwitch(chromeos::switches::kLoginUser); |
| 148 const bool wait_for_initial_policy = is_managed_user && !is_browser_restart; | 151 const bool wait_for_initial_policy = |
| 152 !is_browser_restart && |
| 153 (chromeos::UserManager::Get()->IsCurrentUserNew() || is_affiliated_user); |
| 154 |
| 155 const base::TimeDelta initial_policy_fetch_timeout = |
| 156 chromeos::UserManager::Get()->IsCurrentUserNew() |
| 157 ? base::TimeDelta::Max() |
| 158 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); |
| 149 | 159 |
| 150 DeviceManagementService* device_management_service = | 160 DeviceManagementService* device_management_service = |
| 151 connector->device_management_service(); | 161 connector->device_management_service(); |
| 152 if (wait_for_initial_policy) | 162 if (wait_for_initial_policy) |
| 153 device_management_service->ScheduleInitialization(0); | 163 device_management_service->ScheduleInitialization(0); |
| 154 | 164 |
| 155 base::FilePath profile_dir = profile->GetPath(); | 165 base::FilePath profile_dir = profile->GetPath(); |
| 156 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); | 166 const base::FilePath legacy_dir = profile_dir.Append(kDeviceManagementDir); |
| 157 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); | 167 const base::FilePath policy_cache_file = legacy_dir.Append(kPolicy); |
| 158 const base::FilePath token_cache_file = legacy_dir.Append(kToken); | 168 const base::FilePath token_cache_file = legacy_dir.Append(kToken); |
| (...skipping 29 matching lines...) Expand all Loading... |
| 188 scoped_refptr<base::SequencedTaskRunner> file_task_runner = | 198 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
| 189 content::BrowserThread::GetMessageLoopProxyForThread( | 199 content::BrowserThread::GetMessageLoopProxyForThread( |
| 190 content::BrowserThread::FILE); | 200 content::BrowserThread::FILE); |
| 191 | 201 |
| 192 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( | 202 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( |
| 193 new UserCloudPolicyManagerChromeOS( | 203 new UserCloudPolicyManagerChromeOS( |
| 194 store.PassAs<CloudPolicyStore>(), | 204 store.PassAs<CloudPolicyStore>(), |
| 195 external_data_manager.Pass(), | 205 external_data_manager.Pass(), |
| 196 component_policy_cache_dir, | 206 component_policy_cache_dir, |
| 197 wait_for_initial_policy, | 207 wait_for_initial_policy, |
| 198 base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds), | 208 initial_policy_fetch_timeout, |
| 199 base::MessageLoopProxy::current(), | 209 base::MessageLoopProxy::current(), |
| 200 file_task_runner, | 210 file_task_runner, |
| 201 io_task_runner)); | 211 io_task_runner)); |
| 202 | 212 |
| 203 bool wildcard_match = false; | 213 bool wildcard_match = false; |
| 204 if (connector->IsEnterpriseManaged() && | 214 if (connector->IsEnterpriseManaged() && |
| 205 chromeos::LoginUtils::IsWhitelisted(username, &wildcard_match) && | 215 chromeos::LoginUtils::IsWhitelisted(username, &wildcard_match) && |
| 206 wildcard_match && | 216 wildcard_match && |
| 207 !connector->IsNonEnterpriseUser(username)) { | 217 !connector->IsNonEnterpriseUser(username)) { |
| 208 manager->EnableWildcardLoginCheck(username); | 218 manager->EnableWildcardLoginCheck(username); |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 | 252 |
| 243 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( | 253 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( |
| 244 content::BrowserContext* context) { | 254 content::BrowserContext* context) { |
| 245 return false; | 255 return false; |
| 246 } | 256 } |
| 247 | 257 |
| 248 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 258 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
| 249 content::BrowserContext* context) {} | 259 content::BrowserContext* context) {} |
| 250 | 260 |
| 251 } // namespace policy | 261 } // namespace policy |
| OLD | NEW |