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

Side by Side Diff: components/enhanced_bookmarks/bookmark_server_service.cc

Issue 617183003: Make sure GetAuthenticatedAccountId() returns a canonicalized id. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address review comments Created 6 years, 2 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "components/enhanced_bookmarks/bookmark_server_service.h" 5 #include "components/enhanced_bookmarks/bookmark_server_service.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h" 8 #include "components/enhanced_bookmarks/enhanced_bookmark_model.h"
9 #include "components/signin/core/browser/profile_oauth2_token_service.h" 9 #include "components/signin/core/browser/profile_oauth2_token_service.h"
10 #include "components/signin/core/browser/signin_manager_base.h" 10 #include "components/signin/core/browser/signin_manager_base.h"
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this)); 64 FOR_EACH_OBSERVER(BookmarkServerServiceObserver, observers_, OnChange(this));
65 } 65 }
66 66
67 void BookmarkServerService::TriggerTokenRequest(bool cancel_previous) { 67 void BookmarkServerService::TriggerTokenRequest(bool cancel_previous) {
68 if (cancel_previous) 68 if (cancel_previous)
69 url_fetcher_.reset(); 69 url_fetcher_.reset();
70 70
71 if (token_request_ || url_fetcher_) 71 if (token_request_ || url_fetcher_)
72 return; // Fetcher is already running. 72 return; // Fetcher is already running.
73 73
74 const std::string username(signin_manager_->GetAuthenticatedUsername()); 74 if (!signin_manager_->IsAuthenticated()) {
75 if (!username.length()) {
76 // User is not signed in. 75 // User is not signed in.
77 CleanAfterFailure(); 76 CleanAfterFailure();
78 Notify(); 77 Notify();
79 return; 78 return;
80 } 79 }
81 // Find a token. 80 // Find a token.
82 OAuth2TokenService::ScopeSet scopes; 81 OAuth2TokenService::ScopeSet scopes;
83 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope); 82 scopes.insert(GaiaConstants::kChromeSyncOAuth2Scope);
84 token_request_ = token_service_->StartRequest(username, scopes, this); 83 token_request_ = token_service_->StartRequest(
84 signin_manager_->GetAuthenticatedAccountId(), scopes, this);
85 } 85 }
86 86
87 // 87 //
88 // OAuth2AccessTokenConsumer methods. 88 // OAuth2AccessTokenConsumer methods.
89 // 89 //
90 void BookmarkServerService::OnGetTokenSuccess( 90 void BookmarkServerService::OnGetTokenSuccess(
91 const OAuth2TokenService::Request* request, 91 const OAuth2TokenService::Request* request,
92 const std::string& access_token, 92 const std::string& access_token,
93 const base::Time& expiration_time) { 93 const base::Time& expiration_time) {
94 url_fetcher_.reset(CreateFetcher()); 94 url_fetcher_.reset(CreateFetcher());
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() { 146 void BookmarkServerService::EnhancedBookmarkModelShuttingDown() {
147 NOTREACHED(); 147 NOTREACHED();
148 } 148 }
149 149
150 SigninManagerBase* BookmarkServerService::GetSigninManager() { 150 SigninManagerBase* BookmarkServerService::GetSigninManager() {
151 DCHECK(signin_manager_); 151 DCHECK(signin_manager_);
152 return signin_manager_; 152 return signin_manager_;
153 } 153 }
154 154
155 } // namespace enhanced_bookmarks 155 } // namespace enhanced_bookmarks
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698