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

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: Addressing CR comments. 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 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
252 public: 252 public:
253 explicit AccessTokenService(PrintPreviewHandler* handler) 253 explicit AccessTokenService(PrintPreviewHandler* handler)
254 : handler_(handler) { 254 : handler_(handler) {
255 } 255 }
256 256
257 void RequestToken(const std::string& type) { 257 void RequestToken(const std::string& type) {
258 if (requests_.find(type) != requests_.end()) 258 if (requests_.find(type) != requests_.end())
259 return; // Already in progress. 259 return; // Already in progress.
260 260
261 OAuth2TokenService* service = NULL; 261 OAuth2TokenService* service = NULL;
262 std::string account_id;
262 if (type == "profile") { 263 if (type == "profile") {
263 Profile* profile = Profile::FromWebUI(handler_->web_ui()); 264 Profile* profile = Profile::FromWebUI(handler_->web_ui());
264 if (profile) 265 if (profile) {
265 service = ProfileOAuth2TokenServiceFactory::GetForProfile(profile); 266 ProfileOAuth2TokenService* token_service =
267 ProfileOAuth2TokenServiceFactory::GetForProfile(profile);
268 account_id = token_service->GetPrimaryAccountId();
269 service = token_service;
270 }
266 } else if (type == "device") { 271 } else if (type == "device") {
267 #if defined(OS_CHROMEOS) 272 #if defined(OS_CHROMEOS)
268 service = chromeos::DeviceOAuth2TokenServiceFactory::Get(); 273 service = chromeos::DeviceOAuth2TokenServiceFactory::Get();
269 #endif 274 #endif
270 } 275 }
271 276
272 if (service) { 277 if (service) {
273 OAuth2TokenService::ScopeSet oauth_scopes; 278 OAuth2TokenService::ScopeSet oauth_scopes;
274 oauth_scopes.insert(cloud_print::kCloudPrintAuth); 279 oauth_scopes.insert(cloud_print::kCloudPrintAuth);
275 scoped_ptr<OAuth2TokenService::Request> request( 280 scoped_ptr<OAuth2TokenService::Request> request(
276 service->StartRequest(oauth_scopes, this)); 281 service->StartRequest(account_id, oauth_scopes, this));
Roger Tawa OOO till Jul 10th 2013/08/26 21:04:53 I the case of chromeos and type=="device", account
fgorski 2013/08/26 23:30:54 It's exactly what I expect to happen. I'll documen
277 requests_[type].reset(request.release()); 282 requests_[type].reset(request.release());
278 } else { 283 } else {
279 handler_->SendAccessToken(type, std::string()); // Unknown type. 284 handler_->SendAccessToken(type, std::string()); // Unknown type.
280 } 285 }
281 } 286 }
282 287
283 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, 288 virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request,
284 const std::string& access_token, 289 const std::string& access_token,
285 const base::Time& expiration_time) OVERRIDE { 290 const base::Time& expiration_time) OVERRIDE {
286 OnServiceResponce(request, access_token); 291 OnServiceResponce(request, access_token);
(...skipping 762 matching lines...) Expand 10 before | Expand all | Expand 10 after
1049 if (!tmp_data.get()) { 1054 if (!tmp_data.get()) {
1050 // Nothing to print, no preview available. 1055 // Nothing to print, no preview available.
1051 return false; 1056 return false;
1052 } 1057 }
1053 DCHECK(tmp_data->size() && tmp_data->front()); 1058 DCHECK(tmp_data->size() && tmp_data->front());
1054 1059
1055 *data = tmp_data; 1060 *data = tmp_data;
1056 *title = print_preview_ui->initiator_title(); 1061 *title = print_preview_ui->initiator_title();
1057 return true; 1062 return true;
1058 } 1063 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698