Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(526)

Side by Side Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc

Issue 2275963004: Apply default policy values also on non-ChromeOS
Patch Set: update tests Created 4 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_chromeos.h" 5 #include "chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 14 matching lines...) Expand all
25 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h" 25 #include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
26 #include "chrome/browser/lifetime/application_lifetime.h" 26 #include "chrome/browser/lifetime/application_lifetime.h"
27 #include "chrome/common/chrome_content_client.h" 27 #include "chrome/common/chrome_content_client.h"
28 #include "chromeos/chromeos_switches.h" 28 #include "chromeos/chromeos_switches.h"
29 #include "components/policy/core/common/cloud/cloud_external_data_manager.h" 29 #include "components/policy/core/common/cloud/cloud_external_data_manager.h"
30 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h" 30 #include "components/policy/core/common/cloud/cloud_policy_refresh_scheduler.h"
31 #include "components/policy/core/common/cloud/device_management_service.h" 31 #include "components/policy/core/common/cloud/device_management_service.h"
32 #include "components/policy/core/common/policy_map.h" 32 #include "components/policy/core/common/policy_map.h"
33 #include "components/policy/core/common/policy_pref_names.h" 33 #include "components/policy/core/common/policy_pref_names.h"
34 #include "components/policy/core/common/policy_types.h" 34 #include "components/policy/core/common/policy_types.h"
35 #include "components/policy/policy_constants.h"
36 #include "components/user_manager/user.h" 35 #include "components/user_manager/user.h"
37 #include "components/user_manager/user_manager.h" 36 #include "components/user_manager/user_manager.h"
38 #include "net/url_request/url_request_context_getter.h" 37 #include "net/url_request/url_request_context_getter.h"
39 #include "url/gurl.h" 38 #include "url/gurl.h"
40 39
41 namespace em = enterprise_management; 40 namespace em = enterprise_management;
42 41
43 namespace policy { 42 namespace policy {
44 43
45 namespace { 44 namespace {
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
305 if (policy_data) { 304 if (policy_data) {
306 chromeos::AffiliationIDSet set_of_user_affiliation_ids( 305 chromeos::AffiliationIDSet set_of_user_affiliation_ids(
307 policy_data->user_affiliation_ids().begin(), 306 policy_data->user_affiliation_ids().begin(),
308 policy_data->user_affiliation_ids().end()); 307 policy_data->user_affiliation_ids().end());
309 308
310 chromeos::ChromeUserManager::Get()->SetUserAffiliation( 309 chromeos::ChromeUserManager::Get()->SetUserAffiliation(
311 policy_data->username(), set_of_user_affiliation_ids); 310 policy_data->username(), set_of_user_affiliation_ids);
312 } 311 }
313 } 312 }
314 313
315 void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) {
316 CloudPolicyManager::GetChromePolicy(policy_map);
317
318 // If the store has a verified policy blob received from the server then apply
319 // the defaults for policies that haven't been configured by the administrator
320 // given that this is an enterprise user.
321 if (!store()->has_policy())
322 return;
323 SetEnterpriseUsersDefaults(policy_map);
324 }
325
326 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() { 314 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() {
327 const std::string& refresh_token = chromeos::UserSessionManager::GetInstance() 315 const std::string& refresh_token = chromeos::UserSessionManager::GetInstance()
328 ->user_context() 316 ->user_context()
329 .GetRefreshToken(); 317 .GetRefreshToken();
330 if (!refresh_token.empty()) { 318 if (!refresh_token.empty()) {
331 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance()); 319 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance());
332 token_fetcher_->StartWithRefreshToken( 320 token_fetcher_->StartWithRefreshToken(
333 refresh_token, g_browser_process->system_request_context(), 321 refresh_token, g_browser_process->system_request_context(),
334 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched, 322 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched,
335 base::Unretained(this))); 323 base::Unretained(this)));
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 // OnComponentCloudPolicyUpdated() once it's ready. 437 // OnComponentCloudPolicyUpdated() once it's ready.
450 return; 438 return;
451 } 439 }
452 440
453 core()->StartRefreshScheduler(); 441 core()->StartRefreshScheduler();
454 core()->TrackRefreshDelayPref(local_state_, 442 core()->TrackRefreshDelayPref(local_state_,
455 policy_prefs::kUserPolicyRefreshRate); 443 policy_prefs::kUserPolicyRefreshRate);
456 } 444 }
457 445
458 } // namespace policy 446 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698