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

Unified Diff: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc

Issue 1108983002: Fetch policy with refresh token. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix user_cloud_policy_manager_chromeos_unittest Created 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
diff --git a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
index 392968018c716d363f7168a304d3e52208971dd3..35ca56d81fee14caa4a76447e5b6ec3abb4d8a02 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
@@ -13,6 +13,7 @@
#include "base/values.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/login/helper.h"
+#include "chrome/browser/chromeos/login/session/user_session_manager.h"
#include "chrome/browser/chromeos/policy/policy_oauth2_token_fetcher.h"
#include "chrome/browser/chromeos/policy/user_cloud_policy_manager_factory_chromeos.h"
#include "chrome/browser/chromeos/policy/wildcard_login_checker.h"
@@ -212,7 +213,7 @@ void UserCloudPolicyManagerChromeOS::OnInitializationCompleted(
// access token is already available.
if (!client()->is_registered()) {
if (wait_for_policy_fetch_) {
- FetchPolicyOAuthTokenUsingSigninContext();
+ FetchPolicyOAuthToken();
} else if (!access_token_.empty()) {
OnAccessTokenAvailable(access_token_);
}
@@ -286,7 +287,19 @@ void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) {
SetEnterpriseUsersDefaults(policy_map);
}
-void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthTokenUsingSigninContext() {
+void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() {
+ const std::string& refresh_token = chromeos::UserSessionManager::GetInstance()
+ ->user_context()
+ .GetRefreshToken();
+ if (!refresh_token.empty()) {
+ token_fetcher_.reset(new PolicyOAuth2TokenFetcher(
+ std::string(), g_browser_process->system_request_context(),
+ base::Bind(&UserCloudPolicyManagerChromeOS::OnOAuth2PolicyTokenFetched,
+ base::Unretained(this))));
+ token_fetcher_->StartWithRefreshToken(refresh_token);
+ return;
+ }
+
scoped_refptr<net::URLRequestContextGetter> signin_context =
chromeos::login::GetSigninContext();
if (!signin_context.get()) {

Powered by Google App Engine
This is Rietveld 408576698