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

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: comment and unit test 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..18deb1e3ca0863de3dd0bca47e6092728f5d86de 100644
--- a/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
+++ b/chrome/browser/chromeos/policy/user_cloud_policy_manager_chromeos.cc
@@ -76,6 +76,7 @@ UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS(
scoped_ptr<CloudExternalDataManager> external_data_manager,
const base::FilePath& component_policy_cache_path,
bool wait_for_policy_fetch,
+ const std::string& refresh_token,
base::TimeDelta initial_policy_fetch_timeout,
const scoped_refptr<base::SequencedTaskRunner>& task_runner,
const scoped_refptr<base::SequencedTaskRunner>& file_task_runner,
@@ -90,6 +91,7 @@ UserCloudPolicyManagerChromeOS::UserCloudPolicyManagerChromeOS(
external_data_manager_(external_data_manager.Pass()),
component_policy_cache_path_(component_policy_cache_path),
wait_for_policy_fetch_(wait_for_policy_fetch),
+ refresh_token_(refresh_token),
policy_fetch_timeout_(false, false) {
time_init_started_ = base::Time::Now();
if (wait_for_policy_fetch_ && !initial_policy_fetch_timeout.is_max()) {
@@ -212,7 +214,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 +288,16 @@ void UserCloudPolicyManagerChromeOS::GetChromePolicy(PolicyMap* policy_map) {
SetEnterpriseUsersDefaults(policy_map);
}
-void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthTokenUsingSigninContext() {
+void UserCloudPolicyManagerChromeOS::FetchPolicyOAuthToken() {
+ if (!refresh_token_.empty()) {
Mattias Nissler (ping if slow) 2015/04/28 06:50:43 It's kinda inconsistent that the signin_context be
achuithb 2015/04/28 18:20:08 Done.
+ 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