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

Side by Side Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 144013009: Extensions: Replace PO2TS::GetPrimaryAccountId() with SMB::GetAuthenticatedAccountId. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 10 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_signin_flow.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "chrome/browser/extensions/api/push_messaging/push_messaging_api.h" 5 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
6 6
7 #include <set> 7 #include <set>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/lazy_instance.h" 10 #include "base/lazy_instance.h"
11 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/chrome_notification_types.h" 14 #include "chrome/browser/chrome_notification_types.h"
15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h" 15 #include "chrome/browser/extensions/api/push_messaging/push_messaging_invalidati on_handler.h"
16 #include "chrome/browser/extensions/extension_service.h" 16 #include "chrome/browser/extensions/extension_service.h"
17 #include "chrome/browser/extensions/extension_system_factory.h" 17 #include "chrome/browser/extensions/extension_system_factory.h"
18 #include "chrome/browser/extensions/token_cache/token_cache_service.h" 18 #include "chrome/browser/extensions/token_cache/token_cache_service.h"
19 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h" 19 #include "chrome/browser/extensions/token_cache/token_cache_service_factory.h"
20 #include "chrome/browser/invalidation/invalidation_service.h" 20 #include "chrome/browser/invalidation/invalidation_service.h"
21 #include "chrome/browser/invalidation/invalidation_service_factory.h" 21 #include "chrome/browser/invalidation/invalidation_service_factory.h"
22 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
23 #include "chrome/browser/signin/profile_oauth2_token_service.h" 23 #include "chrome/browser/signin/profile_oauth2_token_service.h"
24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" 24 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
25 #include "chrome/browser/signin/signin_manager.h"
26 #include "chrome/browser/signin/signin_manager_factory.h"
25 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 27 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
26 #include "chrome/common/extensions/api/push_messaging.h" 28 #include "chrome/common/extensions/api/push_messaging.h"
27 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
28 #include "content/public/browser/notification_details.h" 30 #include "content/public/browser/notification_details.h"
29 #include "content/public/browser/notification_source.h" 31 #include "content/public/browser/notification_source.h"
30 #include "extensions/browser/event_router.h" 32 #include "extensions/browser/event_router.h"
31 #include "extensions/browser/extension_system.h" 33 #include "extensions/browser/extension_system.h"
32 #include "extensions/common/extension.h" 34 #include "extensions/common/extension.h"
33 #include "extensions/common/permissions/api_permission.h" 35 #include "extensions/common/permissions/api_permission.h"
34 #include "google_apis/gaia/gaia_constants.h" 36 #include "google_apis/gaia/gaia_constants.h"
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 StartAccessTokenFetch(); 119 StartAccessTokenFetch();
118 return true; 120 return true;
119 } 121 }
120 122
121 void PushMessagingGetChannelIdFunction::StartAccessTokenFetch() { 123 void PushMessagingGetChannelIdFunction::StartAccessTokenFetch() {
122 std::vector<std::string> scope_vector = 124 std::vector<std::string> scope_vector =
123 extensions::ObfuscatedGaiaIdFetcher::GetScopes(); 125 extensions::ObfuscatedGaiaIdFetcher::GetScopes();
124 OAuth2TokenService::ScopeSet scopes(scope_vector.begin(), scope_vector.end()); 126 OAuth2TokenService::ScopeSet scopes(scope_vector.begin(), scope_vector.end());
125 ProfileOAuth2TokenService* token_service = 127 ProfileOAuth2TokenService* token_service =
126 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()); 128 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile());
129 SigninManagerBase* signin_manager =
130 SigninManagerFactory::GetForProfile(GetProfile());
127 fetcher_access_token_request_ = token_service->StartRequest( 131 fetcher_access_token_request_ = token_service->StartRequest(
128 token_service->GetPrimaryAccountId(), scopes, this); 132 signin_manager->GetAuthenticatedAccountId(), scopes, this);
129 } 133 }
130 134
131 void PushMessagingGetChannelIdFunction::OnRefreshTokenAvailable( 135 void PushMessagingGetChannelIdFunction::OnRefreshTokenAvailable(
132 const std::string& account_id) { 136 const std::string& account_id) {
133 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()) 137 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile())
134 ->RemoveObserver(this); 138 ->RemoveObserver(this);
135 DVLOG(2) << "Newly logged in: " << GetProfile()->GetProfileName(); 139 DVLOG(2) << "Newly logged in: " << GetProfile()->GetProfileName();
136 StartAccessTokenFetch(); 140 StartAccessTokenFetch();
137 } 141 }
138 142
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 ReportResult(gaia_id, std::string()); 184 ReportResult(gaia_id, std::string());
181 return; 185 return;
182 } 186 }
183 187
184 fetcher_->Start(); 188 fetcher_->Start();
185 } 189 }
186 190
187 // Check if the user is logged in. 191 // Check if the user is logged in.
188 bool PushMessagingGetChannelIdFunction::IsUserLoggedIn() const { 192 bool PushMessagingGetChannelIdFunction::IsUserLoggedIn() const {
189 ProfileOAuth2TokenService* token_service = 193 ProfileOAuth2TokenService* token_service =
190 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile()); 194 ProfileOAuth2TokenServiceFactory::GetForProfile(GetProfile());
dcheng 2014/02/04 22:37:21 Can all references to POA2TSF be deleted from this
Roger Tawa OOO till Jul 10th 2014/02/05 01:00:49 Nope. You can see that the token service is still
195 SigninManagerBase* signin_manager =
196 SigninManagerFactory::GetForProfile(GetProfile());
191 return token_service->RefreshTokenIsAvailable( 197 return token_service->RefreshTokenIsAvailable(
192 token_service->GetPrimaryAccountId()); 198 signin_manager->GetAuthenticatedAccountId());
193 } 199 }
194 200
195 void PushMessagingGetChannelIdFunction::ReportResult( 201 void PushMessagingGetChannelIdFunction::ReportResult(
196 const std::string& gaia_id, const std::string& error_string) { 202 const std::string& gaia_id, const std::string& error_string) {
197 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 203 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
198 204
199 BuildAndSendResult(gaia_id, error_string); 205 BuildAndSendResult(gaia_id, error_string);
200 206
201 // Cache the obfuscated ID locally. It never changes for this user, 207 // Cache the obfuscated ID locally. It never changes for this user,
202 // and if we call the web API too often, we get errors due to rate limiting. 208 // and if we call the web API too often, we get errors due to rate limiting.
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
355 handler_ = mapper.Pass(); 361 handler_ = mapper.Pass();
356 } 362 }
357 363
358 template <> 364 template <>
359 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() { 365 void ProfileKeyedAPIFactory<PushMessagingAPI>::DeclareFactoryDependencies() {
360 DependsOn(ExtensionSystemFactory::GetInstance()); 366 DependsOn(ExtensionSystemFactory::GetInstance());
361 DependsOn(invalidation::InvalidationServiceFactory::GetInstance()); 367 DependsOn(invalidation::InvalidationServiceFactory::GetInstance());
362 } 368 }
363 369
364 } // namespace extensions 370 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/identity/identity_signin_flow.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698