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

Unified Diff: components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc

Issue 197313004: Support policy registration using a preobtained access token. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 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
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_client_registration_helper.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc
diff --git a/components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc b/components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc
index 5c49e18fbc73110ca7f12afa7c4958d4dae119a8..c7b184b033116cf933dd8b1df43413e487c23748 100644
--- a/components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc
+++ b/components/policy/core/common/cloud/cloud_policy_client_registration_helper.cc
@@ -4,8 +4,6 @@
#include "components/policy/core/common/cloud/cloud_policy_client_registration_helper.h"
-#include <vector>
-
#include "base/bind.h"
#include "base/bind_helpers.h"
#include "base/logging.h"
@@ -24,10 +22,6 @@
namespace policy {
-// OAuth2 scope for the userinfo service.
-const char kServiceScopeGetUserInfo[] =
- "https://www.googleapis.com/auth/userinfo.email";
-
// The key under which the hosted-domain value is stored in the UserInfo
// response.
const char kGetHostedDomainKey[] = "hd";
@@ -77,7 +71,7 @@ void CloudPolicyClientRegistrationHelper::TokenServiceHelper::FetchAccessToken(
OAuth2TokenService::ScopeSet scopes;
scopes.insert(GaiaConstants::kDeviceManagementServiceOAuth);
- scopes.insert(kServiceScopeGetUserInfo);
+ scopes.insert(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
token_request_ = token_service->StartRequest(account_id, scopes, this);
}
@@ -135,14 +129,11 @@ void CloudPolicyClientRegistrationHelper::LoginTokenHelper::FetchAccessToken(
// userinfo services.
oauth2_access_token_fetcher_.reset(
new OAuth2AccessTokenFetcherImpl(this, context, login_refresh_token));
- std::vector<std::string> scopes;
- scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth);
- scopes.push_back(kServiceScopeGetUserInfo);
GaiaUrls* gaia_urls = GaiaUrls::GetInstance();
oauth2_access_token_fetcher_->Start(
gaia_urls->oauth2_chrome_client_id(),
gaia_urls->oauth2_chrome_client_secret(),
- scopes);
+ GetScopes());
}
void CloudPolicyClientRegistrationHelper::LoginTokenHelper::OnGetTokenSuccess(
@@ -210,6 +201,24 @@ void CloudPolicyClientRegistrationHelper::StartRegistrationWithLoginToken(
base::Bind(&CloudPolicyClientRegistrationHelper::OnTokenFetched,
base::Unretained(this)));
}
+
+void CloudPolicyClientRegistrationHelper::StartRegistrationWithAccessToken(
+ const std::string& access_token,
+ const base::Closure& callback) {
+ DCHECK(!client_->is_registered());
+ callback_ = callback;
+ client_->AddObserver(this);
+ OnTokenFetched(access_token);
+}
+
+// static
+std::vector<std::string>
+CloudPolicyClientRegistrationHelper::GetScopes() {
+ std::vector<std::string> scopes;
+ scopes.push_back(GaiaConstants::kDeviceManagementServiceOAuth);
+ scopes.push_back(GaiaConstants::kOAuthWrapBridgeUserInfoScope);
+ return scopes;
+}
#endif
void CloudPolicyClientRegistrationHelper::OnTokenFetched(
« no previous file with comments | « components/policy/core/common/cloud/cloud_policy_client_registration_helper.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698