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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_fetcher.cc

Issue 1618193003: arc: Pass auth token from Chrome to ARC instance. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix accidental change Created 4 years, 11 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
(Empty)
1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/browser/chromeos/arc/arc_auth_fetcher.h"
6
7 #include "base/strings/stringprintf.h"
8 #include "google_apis/gaia/gaia_auth_fetcher.h"
xiyuan 2016/01/27 23:56:05 nit: not needed since we included it in header
khmel 2016/01/28 05:22:08 Done.
9 #include "google_apis/gaia/gaia_constants.h"
10 #include "google_apis/gaia/gaia_urls.h"
11
12 namespace arc {
13
14 namespace {
15
16 const char kGMSCoreClientId[] =
17 "1070009224336-sdh77n7uot3oc99ais00jmuft6sk2fg9.apps.googleusercontent.com";
18
19 } // namespace
20
21 ArcAuthFetcher::ArcAuthFetcher(net::URLRequestContextGetter* getter,
22 Delegate* delegate)
23 : delegate_(delegate), auth_fetcher_(this, "", getter) {
24 FetchAuthCode();
25 }
26
27 ArcAuthFetcher::~ArcAuthFetcher() {}
28
29 // static
30 GURL ArcAuthFetcher::CreateURL() {
31 std::string query_string =
32 base::StringPrintf("?scope=%s&client_id=%s",
33 GaiaConstants::kOAuth1LoginScope, kGMSCoreClientId);
34 return GaiaUrls::GetInstance()->client_login_to_oauth2_url().Resolve(
35 query_string);
36 }
37
38 void ArcAuthFetcher::FetchAuthCode() {
39 DCHECK(!auth_fetcher_.HasPendingFetch());
40 auth_fetcher_.StartCookieForOAuthLoginTokenExchangeWithClientIdAndDeviceId(
41 false, /* fetch_token_from_auth_code */
42 "", /* session_index */
43 kGMSCoreClientId, "" /* device_id */);
44 }
45
46 void ArcAuthFetcher::OnClientOAuthCode(const std::string& auth_code) {
47 DCHECK(!auth_fetcher_.HasPendingFetch());
48 delegate_->OnAuthCodeFetched(auth_code);
49 }
50
51 void ArcAuthFetcher::OnClientOAuthSuccess(const ClientOAuthResult& result) {
52 NOTREACHED();
53 }
xiyuan 2016/01/27 23:56:05 Seems we don't really need OnClientOAuthSuccess. R
khmel 2016/01/28 05:22:08 Yes, this is redundant. I added this check for gai
54 void ArcAuthFetcher::OnClientOAuthFailure(const GoogleServiceAuthError& error) {
55 // UNEXPECTED_SERVICE_RESPONSE indicates no cookies in response, but request
56 // is completed successfully.
57 if (error.state() == GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE) {
58 delegate_->OnAuthCodeNeedUI();
59 } else {
60 VLOG(2) << "ARC Auth request failed: " << error.ToString() << ".";
61 delegate_->OnAuthCodeFailed();
62 }
63 }
64
65 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698