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

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: rebased Created 4 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
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/28 16:18:07 nit: The header is still here. :)
khmel 2016/01/28 19:24:01 :) My fault. Thanks
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_.StartCookieForOAuthLoginTokenExchange(
41 false, /* fetch_token_from_auth_code */
42 "", /* session_index */
oshima 2016/01/28 17:46:40 std::string() same for other ""s.
khmel 2016/01/28 19:24:01 Done.
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::OnClientOAuthFailure(const GoogleServiceAuthError& error) {
52 // UNEXPECTED_SERVICE_RESPONSE indicates no cookies in response, but request
53 // is completed successfully.
54 if (error.state() == GoogleServiceAuthError::UNEXPECTED_SERVICE_RESPONSE) {
55 delegate_->OnAuthCodeNeedUI();
56 } else {
57 VLOG(2) << "ARC Auth request failed: " << error.ToString() << ".";
58 delegate_->OnAuthCodeFailed();
59 }
60 }
61
62 } // namespace arc
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698