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

Side by Side Diff: chrome/browser/local_discovery/privet_confirm_api_flow.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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/json/json_reader.h" 5 #include "base/json/json_reader.h"
6 #include "base/strings/stringprintf.h" 6 #include "base/strings/stringprintf.h"
7 #include "base/values.h" 7 #include "base/values.h"
8 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h" 8 #include "chrome/browser/local_discovery/privet_confirm_api_flow.h"
9 #include "chrome/common/cloud_print/cloud_print_constants.h" 9 #include "chrome/common/cloud_print/cloud_print_constants.h"
10 #include "google_apis/gaia/google_service_auth_error.h" 10 #include "google_apis/gaia/google_service_auth_error.h"
11 #include "net/base/load_flags.h" 11 #include "net/base/load_flags.h"
12 #include "net/http/http_status_code.h" 12 #include "net/http/http_status_code.h"
13 #include "net/url_request/url_request_status.h" 13 #include "net/url_request/url_request_status.h"
14 14
15 namespace local_discovery { 15 namespace local_discovery {
16 16
17 namespace { 17 namespace {
18 const char kCloudPrintOAuthHeaderFormat[] = "Authorization: Bearer %s"; 18 const char kCloudPrintOAuthHeaderFormat[] = "Authorization: Bearer %s";
19 } 19 }
20 20
21 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow( 21 PrivetConfirmApiCallFlow::PrivetConfirmApiCallFlow(
22 net::URLRequestContextGetter* request_context, 22 net::URLRequestContextGetter* request_context,
23 OAuth2TokenService* token_service, 23 OAuth2TokenService* token_service,
24 const std::string& account_id,
24 const GURL& automated_claim_url, 25 const GURL& automated_claim_url,
25 const ResponseCallback& callback) 26 const ResponseCallback& callback)
26 : request_context_(request_context), 27 : request_context_(request_context),
27 token_service_(token_service), 28 token_service_(token_service),
29 account_id_(account_id),
28 automated_claim_url_(automated_claim_url), 30 automated_claim_url_(automated_claim_url),
29 callback_(callback) { 31 callback_(callback) {
30 } 32 }
31 33
32 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() { 34 PrivetConfirmApiCallFlow::~PrivetConfirmApiCallFlow() {
33 } 35 }
34 36
35 void PrivetConfirmApiCallFlow::Start() { 37 void PrivetConfirmApiCallFlow::Start() {
36 OAuth2TokenService::ScopeSet oauth_scopes; 38 OAuth2TokenService::ScopeSet oauth_scopes;
37 oauth_scopes.insert(cloud_print::kCloudPrintAuth); 39 oauth_scopes.insert(cloud_print::kCloudPrintAuth);
38 oauth_request_ = token_service_->StartRequest(oauth_scopes, this); 40 oauth_request_ = token_service_->StartRequest(account_id_, oauth_scopes,
41 this);
39 } 42 }
40 43
41 void PrivetConfirmApiCallFlow::OnGetTokenSuccess( 44 void PrivetConfirmApiCallFlow::OnGetTokenSuccess(
42 const OAuth2TokenService::Request* request, 45 const OAuth2TokenService::Request* request,
43 const std::string& access_token, 46 const std::string& access_token,
44 const base::Time& expiration_time) { 47 const base::Time& expiration_time) {
45 url_fetcher_.reset(net::URLFetcher::Create(automated_claim_url_, 48 url_fetcher_.reset(net::URLFetcher::Create(automated_claim_url_,
46 net::URLFetcher::GET, 49 net::URLFetcher::GET,
47 this)); 50 this));
48 url_fetcher_->SetRequestContext(request_context_.get()); 51 url_fetcher_->SetRequestContext(request_context_.get());
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
94 } 97 }
95 98
96 if (success) { 99 if (success) {
97 callback_.Run(SUCCESS); 100 callback_.Run(SUCCESS);
98 } else { 101 } else {
99 callback_.Run(ERROR_FROM_SERVER); 102 callback_.Run(ERROR_FROM_SERVER);
100 } 103 }
101 } 104 }
102 105
103 } // namespace local_discovery 106 } // namespace local_discovery
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698