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" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { | 142 BrowserPolicyConnector::IsNonEnterpriseUser(username)) { |
143 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); | 143 return scoped_ptr<UserCloudPolicyManagerChromeOS>(); |
144 } | 144 } |
145 | 145 |
146 policy::BrowserPolicyConnectorChromeOS* connector = | 146 policy::BrowserPolicyConnectorChromeOS* connector = |
147 g_browser_process->platform_part()->browser_policy_connector_chromeos(); | 147 g_browser_process->platform_part()->browser_policy_connector_chromeos(); |
148 UserAffiliation affiliation = connector->GetUserAffiliation(username); | 148 UserAffiliation affiliation = connector->GetUserAffiliation(username); |
149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED; | 149 const bool is_affiliated_user = affiliation == USER_AFFILIATION_MANAGED; |
150 const bool is_browser_restart = | 150 const bool is_browser_restart = |
151 command_line->HasSwitch(chromeos::switches::kLoginUser); | 151 command_line->HasSwitch(chromeos::switches::kLoginUser); |
152 // TODO(xiyuan): Update the code below after http://crbug.com/462036. | |
153 const bool wait_for_initial_policy = | 152 const bool wait_for_initial_policy = |
154 !is_browser_restart && | 153 !is_browser_restart && |
155 chromeos::UserSessionManager::GetInstance()->has_auth_cookies() && | |
156 (user_manager::UserManager::Get()->IsCurrentUserNew() || | 154 (user_manager::UserManager::Get()->IsCurrentUserNew() || |
157 is_affiliated_user); | 155 is_affiliated_user); |
158 | 156 |
159 const base::TimeDelta initial_policy_fetch_timeout = | 157 const base::TimeDelta initial_policy_fetch_timeout = |
160 user_manager::UserManager::Get()->IsCurrentUserNew() | 158 user_manager::UserManager::Get()->IsCurrentUserNew() |
161 ? base::TimeDelta::Max() | 159 ? base::TimeDelta::Max() |
162 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); | 160 : base::TimeDelta::FromSeconds(kInitialPolicyFetchTimeoutSeconds); |
163 | 161 |
164 DeviceManagementService* device_management_service = | 162 DeviceManagementService* device_management_service = |
165 connector->device_management_service(); | 163 connector->device_management_service(); |
(...skipping 30 matching lines...) Expand all Loading... |
196 io_task_runner, | 194 io_task_runner, |
197 external_data_dir, | 195 external_data_dir, |
198 store.get())); | 196 store.get())); |
199 if (force_immediate_load) | 197 if (force_immediate_load) |
200 store->LoadImmediately(); | 198 store->LoadImmediately(); |
201 | 199 |
202 scoped_refptr<base::SequencedTaskRunner> file_task_runner = | 200 scoped_refptr<base::SequencedTaskRunner> file_task_runner = |
203 content::BrowserThread::GetMessageLoopProxyForThread( | 201 content::BrowserThread::GetMessageLoopProxyForThread( |
204 content::BrowserThread::FILE); | 202 content::BrowserThread::FILE); |
205 | 203 |
| 204 const std::string& refresh_token = chromeos::UserSessionManager::GetInstance() |
| 205 ->user_context() |
| 206 .GetRefreshToken(); |
206 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( | 207 scoped_ptr<UserCloudPolicyManagerChromeOS> manager( |
207 new UserCloudPolicyManagerChromeOS(store.Pass(), | 208 new UserCloudPolicyManagerChromeOS( |
208 external_data_manager.Pass(), | 209 store.Pass(), external_data_manager.Pass(), |
209 component_policy_cache_dir, | 210 component_policy_cache_dir, wait_for_initial_policy, refresh_token, |
210 wait_for_initial_policy, | 211 initial_policy_fetch_timeout, base::MessageLoopProxy::current(), |
211 initial_policy_fetch_timeout, | 212 file_task_runner, io_task_runner)); |
212 base::MessageLoopProxy::current(), | |
213 file_task_runner, | |
214 io_task_runner)); | |
215 | 213 |
216 bool wildcard_match = false; | 214 bool wildcard_match = false; |
217 if (connector->IsEnterpriseManaged() && | 215 if (connector->IsEnterpriseManaged() && |
218 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && | 216 chromeos::CrosSettings::IsWhitelisted(username, &wildcard_match) && |
219 wildcard_match && !connector->IsNonEnterpriseUser(username)) { | 217 wildcard_match && !connector->IsNonEnterpriseUser(username)) { |
220 manager->EnableWildcardLoginCheck(username); | 218 manager->EnableWildcardLoginCheck(username); |
221 } | 219 } |
222 | 220 |
223 manager->Init( | 221 manager->Init( |
224 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); | 222 SchemaRegistryServiceFactory::GetForContext(profile)->registry()); |
(...skipping 29 matching lines...) Expand all Loading... |
254 | 252 |
255 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( | 253 bool UserCloudPolicyManagerFactoryChromeOS::HasTestingFactory( |
256 content::BrowserContext* context) { | 254 content::BrowserContext* context) { |
257 return false; | 255 return false; |
258 } | 256 } |
259 | 257 |
260 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( | 258 void UserCloudPolicyManagerFactoryChromeOS::CreateServiceNow( |
261 content::BrowserContext* context) {} | 259 content::BrowserContext* context) {} |
262 | 260 |
263 } // namespace policy | 261 } // namespace policy |
OLD | NEW |