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

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

Issue 1767443002: Add enterprise enrollment support for fake users. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@lkgr
Patch Set: Check instance before derefing it Created 4 years, 8 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 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 if (!store()->has_policy()) 327 if (!store()->has_policy())
328 return; 328 return;
329 SetEnterpriseUsersDefaults(policy_map); 329 SetEnterpriseUsersDefaults(policy_map);
330 } 330 }
331 331
332 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() { 332 void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() {
333 const std::string& refresh_token = chromeos::UserSessionManager::GetInstance() 333 const std::string& refresh_token = chromeos::UserSessionManager::GetInstance()
334 ->user_context() 334 ->user_context()
335 .GetRefreshToken(); 335 .GetRefreshToken();
336 if (!refresh_token.empty()) { 336 if (!refresh_token.empty()) {
337 token_fetcher_.reset(new PolicyOAuth2TokenFetcher()); 337 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance());
338 token_fetcher_->StartWithRefreshToken( 338 token_fetcher_->StartWithRefreshToken(
339 refresh_token, g_browser_process->system_request_context(), 339 refresh_token, g_browser_process->system_request_context(),
340 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched, 340 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched,
341 base::Unretained(this))); 341 base::Unretained(this)));
342 return; 342 return;
343 } 343 }
344 344
345 scoped_refptr<net::URLRequestContextGetter> signin_context = 345 scoped_refptr<net::URLRequestContextGetter> signin_context =
346 chromeos::login::GetSigninContext(); 346 chromeos::login::GetSigninContext();
347 if (!signin_context.get()) { 347 if (!signin_context.get()) {
348 LOG(ERROR) << "No signin context for policy oauth token fetch!"; 348 LOG(ERROR) << "No signin context for policy oauth token fetch!";
349 OnOAuth2PolicyTokenFetched( 349 OnOAuth2PolicyTokenFetched(
350 std::string(), GoogleServiceAuthError(GoogleServiceAuthError::NONE)); 350 std::string(), GoogleServiceAuthError(GoogleServiceAuthError::NONE));
351 return; 351 return;
352 } 352 }
353 353
354 token_fetcher_.reset(new PolicyOAuth2TokenFetcher()); 354 token_fetcher_.reset(PolicyOAuth2TokenFetcher::CreateInstance());
355 token_fetcher_->StartWithSigninContext( 355 token_fetcher_->StartWithSigninContext(
356 signin_context.get(), g_browser_process->system_request_context(), 356 signin_context.get(), g_browser_process->system_request_context(),
357 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched, 357 base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched,
358 base::Unretained(this))); 358 base::Unretained(this)));
359 } 359 }
360 360
361 void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched( 361 void UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched(
362 const std::string& policy_token, 362 const std::string& policy_token,
363 const GoogleServiceAuthError& error) { 363 const GoogleServiceAuthError& error) {
364 DCHECK(!client()->is_registered()); 364 DCHECK(!client()->is_registered());
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 // OnComponentCloudPolicyUpdated() once it's ready. 455 // OnComponentCloudPolicyUpdated() once it's ready.
456 return; 456 return;
457 } 457 }
458 458
459 core()->StartRefreshScheduler(); 459 core()->StartRefreshScheduler();
460 core()->TrackRefreshDelayPref(local_state_, 460 core()->TrackRefreshDelayPref(local_state_,
461 policy_prefs::kUserPolicyRefreshRate); 461 policy_prefs::kUserPolicyRefreshRate);
462 } 462 }
463 463
464 } // namespace policy 464 } // namespace policy
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698