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

Unified Diff: chrome/browser/profiles/profile_downloader.cc

Issue 8742008: ChromeOS: Use OAuth2 refresh token to download GAIA info (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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/profiles/profile_downloader.cc
diff --git a/chrome/browser/profiles/profile_downloader.cc b/chrome/browser/profiles/profile_downloader.cc
index 4154239fb9e6492e8f61874310a4034537f7d116..2d52884ddec0837dab7816768bf3bed879eed35d 100644
--- a/chrome/browser/profiles/profile_downloader.cc
+++ b/chrome/browser/profiles/profile_downloader.cc
@@ -34,14 +34,8 @@ using content::BrowserThread;
namespace {
-// Template for optional authorization header when using client login access
-// token.
-const char kClientAccessAuthorizationHeader[] =
- "Authorization: GoogleLogin auth=%s";
-
// Template for optional authorization header when using an OAuth access token.
-const char kOAuthAccessAuthorizationHeader[] =
- "Authorization: Bearer %s";
+const char kAuthorizationHeader[] = "Authorization: Bearer %s";
// URL requesting Picasa API for user info.
const char kUserEntryURL[] =
@@ -200,8 +194,7 @@ void ProfileDownloader::Start() {
return;
}
- if (delegate_->GetShouldUseOAuthRefreshToken() &&
- service->HasOAuthLoginToken()) {
+ if (service->HasOAuthLoginToken()) {
std::vector<std::string> scopes;
scopes.push_back(kPicasaScope);
oauth2_access_token_fetcher_.reset(new OAuth2AccessTokenFetcher(
@@ -211,11 +204,6 @@ void ProfileDownloader::Start() {
GaiaUrls::GetInstance()->oauth2_chrome_client_secret(),
service->GetOAuth2LoginRefreshToken(),
scopes);
- } else if (!delegate_->GetShouldUseOAuthRefreshToken() &&
- service->HasTokenForService(GaiaConstants::kPicasaService)) {
- auth_token_ =
- service->GetTokenForService(GaiaConstants::kPicasaService);
- StartFetchingImage();
} else {
Munjal (Google) 2011/11/30 19:29:29 In else you don't want to just wait for token avai
sail 2011/12/01 20:01:49 Ahh, you're right. I'm not sure if this is a probl
Munjal (Google) 2011/12/01 23:25:58 Sure, you can fix it in a separate CL.
registrar_.Add(this,
chrome::NOTIFICATION_TOKEN_AVAILABLE,
@@ -242,16 +230,11 @@ void ProfileDownloader::StartFetchingImage() {
delegate_->GetBrowserProfile()->GetRequestContext());
if (!auth_token_.empty()) {
user_entry_fetcher_->SetExtraRequestHeaders(
- base::StringPrintf(GetAuthorizationHeader(), auth_token_.c_str()));
+ base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
}
user_entry_fetcher_->Start();
}
-const char* ProfileDownloader::GetAuthorizationHeader() const {
- return delegate_->GetShouldUseOAuthRefreshToken() ?
- kOAuthAccessAuthorizationHeader : kClientAccessAuthorizationHeader;
-}
-
ProfileDownloader::~ProfileDownloader() {}
void ProfileDownloader::OnURLFetchComplete(const content::URLFetcher* source) {
@@ -283,7 +266,7 @@ void ProfileDownloader::OnURLFetchComplete(const content::URLFetcher* source) {
delegate_->GetBrowserProfile()->GetRequestContext());
if (!auth_token_.empty()) {
profile_image_fetcher_->SetExtraRequestHeaders(
- base::StringPrintf(GetAuthorizationHeader(), auth_token_.c_str()));
+ base::StringPrintf(kAuthorizationHeader, auth_token_.c_str()));
}
profile_image_fetcher_->Start();
} else if (source == profile_image_fetcher_.get()) {
@@ -320,18 +303,17 @@ void ProfileDownloader::Observe(
TokenService::TokenAvailableDetails* token_details =
content::Details<TokenService::TokenAvailableDetails>(details).ptr();
- std::string service = delegate_->GetShouldUseOAuthRefreshToken() ?
- GaiaConstants::kGaiaOAuth2LoginRefreshToken :
- GaiaConstants::kPicasaService;
if (type == chrome::NOTIFICATION_TOKEN_AVAILABLE) {
- if (token_details->service() == service) {
+ if (token_details->service() ==
+ GaiaConstants::kGaiaOAuth2LoginRefreshToken) {
registrar_.RemoveAll();
auth_token_ = token_details->token();
StartFetchingImage();
}
} else {
- if (token_details->service() == service) {
+ if (token_details->service() ==
+ GaiaConstants::kGaiaOAuth2LoginRefreshToken) {
LOG(WARNING) << "ProfileDownloader: token request failed";
delegate_->OnDownloadComplete(this, false);
}

Powered by Google App Engine
This is Rietveld 408576698