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

Side by Side Diff: chrome/browser/ui/webui/print_preview/print_preview_handler.cc

Issue 23382008: Making OAuth2TokenService multi-login aware, updating callers, minor fixes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 4 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 (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/ui/webui/print_preview/print_preview_handler.h" 5 #include "chrome/browser/ui/webui/print_preview/print_preview_handler.h"
6 6
7 #include <ctype.h> 7 #include <ctype.h>
8 8
9 #include <string> 9 #include <string>
10 10
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 public: 271 public:
272 explicit AccessTokenService(PrintPreviewHandler* handler) 272 explicit AccessTokenService(PrintPreviewHandler* handler)
273 : handler_(handler) { 273 : handler_(handler) {
274 } 274 }
275 275
276 void RequestToken(const std::string& type) { 276 void RequestToken(const std::string& type) {
277 if (requests_.find(type) != requests_.end()) 277 if (requests_.find(type) != requests_.end())
278 return; // Already in progress. 278 return; // Already in progress.
279 279
280 OAuth2TokenService* service = NULL; 280 OAuth2TokenService* service = NULL;
281 std::string account_id;
281 if (type == "profile") { 282 if (type == "profile") {
282 Profile* profile = Profile::FromWebUI(handler_->web_ui()); 283 Profile* profile = Profile::FromWebUI(handler_->web_ui());
283 if (profile) 284 if (profile) {
284 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 285 ProfileOAuth2TokenService* token_service =
286 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
287 account_id = token_service->GetPrimaryAccountId();
288 service = token_service;
289 }
285 } else if (type == "device") { 290 } else if (type == "device") {
286 #if defined(OS_CHROMEOS) 291 #if defined(OS_CHROMEOS)
287 service = chromeos::DeviceOAuth2TokenServiceFactory::Get(); 292 service = chromeos::DeviceOAuth2TokenServiceFactory::Get();
288 #endif 293 #endif
289 } 294 }
290 295
291 if (service) { 296 if (service) {
292 OAuth2TokenService::ScopeSet oauth_scopes; 297 OAuth2TokenService::ScopeSet oauth_scopes;
293 oauth_scopes.insert(cloud_print::kCloudPrintAuth); 298 oauth_scopes.insert(cloud_print::kCloudPrintAuth);
294 scoped_ptr<OAuth2TokenService::Request> request( 299 scoped_ptr<OAuth2TokenService::Request> request(
295 service->StartRequest(oauth_scopes, this)); 300 service->StartRequest(account_id, oauth_scopes, this));
296 requests_[type].reset(request.release()); 301 requests_[type].reset(request.release());
297 } else { 302 } else {
298 handler_->SendAccessToken(type, std::string()); // Unknown type. 303 handler_->SendAccessToken(type, std::string()); // Unknown type.
299 } 304 }
300 } 305 }
301 306
302 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 307 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
303 const std::string& access_token, 308 const std::string& access_token,
304 const base::Time& expiration_time) OVERRIDE { 309 const base::Time& expiration_time) OVERRIDE {
305 OnServiceResponce(request, access_token); 310 OnServiceResponce(request, access_token);
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1078 if (!tmp_data.get()) { 1083 if (!tmp_data.get()) {
1079 // Nothing to print, no preview available. 1084 // Nothing to print, no preview available.
1080 return false; 1085 return false;
1081 } 1086 }
1082 DCHECK(tmp_data->size() && tmp_data->front()); 1087 DCHECK(tmp_data->size() && tmp_data->front());
1083 1088
1084 *data = tmp_data; 1089 *data = tmp_data;
1085 *title = print_preview_ui->initiator_title(); 1090 *title = print_preview_ui->initiator_title();
1086 return true; 1091 return true;
1087 } 1092 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698