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

Side by Side Diff: chrome/browser/chromeos/login/oauth1_token_fetcher.cc

Issue 11649055: OAuth2 sign-in flow for ChromeOS (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | Annotate | Revision Log
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/chromeos/login/oauth1_token_fetcher.h" 5 #include "chrome/browser/chromeos/login/oauth1_token_fetcher.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #include "chrome/browser/chromeos/cros/cros_library.h" 8 #include "chrome/browser/chromeos/cros/cros_library.h"
9 #include "chrome/browser/chromeos/cros/network_library.h" 9 #include "chrome/browser/chromeos/cros/network_library.h"
10 #include "chrome/browser/profiles/profile.h"
11 #include "content/public/browser/browser_thread.h" 10 #include "content/public/browser/browser_thread.h"
12 #include "google_apis/gaia/google_service_auth_error.h" 11 #include "google_apis/gaia/google_service_auth_error.h"
13 12
14 using content::BrowserThread; 13 using content::BrowserThread;
15 14
16 namespace { 15 namespace {
17 16
18 // OAuth token request max retry count. 17 // OAuth token request max retry count.
19 const int kMaxOAuth1TokenRequestAttemptCount = 5; 18 const int kMaxOAuth1TokenRequestAttemptCount = 5;
20 // OAuth token request retry delay in milliseconds. 19 // OAuth token request retry delay in milliseconds.
21 const int kOAuth1TokenRequestRestartDelay = 3000; 20 const int kOAuth1TokenRequestRestartDelay = 3000;
22 21
23 // The service scope of the OAuth v2 token that ChromeOS login will be 22 // The service scope of the OAuth v2 token that ChromeOS login will be
24 // requesting. 23 // requesting.
25 const char kServiceScopeChromeOS[] = 24 const char kServiceScopeChromeOS[] =
26 "https://www.googleapis.com/auth/chromesync"; 25 "https://www.googleapis.com/auth/chromesync";
27 26
28 } // namespace 27 } // namespace
29 28
30 namespace chromeos { 29 namespace chromeos {
31 30
32 OAuth1TokenFetcher::OAuth1TokenFetcher(OAuth1TokenFetcher::Delegate* delegate, 31 OAuth1TokenFetcher::OAuth1TokenFetcher(
33 Profile* auth_profile) 32 OAuth1TokenFetcher::Delegate* delegate,
33 net::URLRequestContextGetter* auth_context_getter)
34 : delegate_(delegate), 34 : delegate_(delegate),
35 auth_profile_(auth_profile), 35 oauth_fetcher_(this, auth_context_getter, kServiceScopeChromeOS),
36 oauth_fetcher_(this,
37 auth_profile_->GetRequestContext(),
38 kServiceScopeChromeOS),
39 retry_count_(0) { 36 retry_count_(0) {
40 DCHECK(delegate); 37 DCHECK(delegate);
41 } 38 }
42 39
43 OAuth1TokenFetcher::~OAuth1TokenFetcher() { 40 OAuth1TokenFetcher::~OAuth1TokenFetcher() {
44 } 41 }
45 42
46 void OAuth1TokenFetcher::Start() { 43 void OAuth1TokenFetcher::Start() {
47 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 44 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
48 if (CrosLibrary::Get()->libcros_loaded()) { 45 if (CrosLibrary::Get()->libcros_loaded()) {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 99
103 void OAuth1TokenFetcher::OnOAuthGetAccessTokenFailure( 100 void OAuth1TokenFetcher::OnOAuthGetAccessTokenFailure(
104 const GoogleServiceAuthError& error) { 101 const GoogleServiceAuthError& error) {
105 LOG(WARNING) << "Failed fetching OAuth1 access token, error: " 102 LOG(WARNING) << "Failed fetching OAuth1 access token, error: "
106 << error.state(); 103 << error.state();
107 if (!RetryOnError(error)) 104 if (!RetryOnError(error))
108 delegate_->OnOAuth1AccessTokenFetchFailed(); 105 delegate_->OnOAuth1AccessTokenFetchFailed();
109 } 106 }
110 107
111 } // namespace chromeos 108 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698