Chromium Code Reviews| Index: chrome/browser/signin/ubertoken_fetcher.h |
| diff --git a/chrome/browser/signin/ubertoken_fetcher.h b/chrome/browser/signin/ubertoken_fetcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..6b80d6facb3986a8b8504667e45667a0b684bfe6 |
| --- /dev/null |
| +++ b/chrome/browser/signin/ubertoken_fetcher.h |
| @@ -0,0 +1,82 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
|
Roger Tawa OOO till Jul 10th
2012/01/31 21:38:23
should this file live in chrome/common/net/gaia/?
qsr
2012/02/01 14:59:18
This file depends on TokenService so it cannot liv
Roger Tawa OOO till Jul 10th
2012/02/01 15:29:55
OK, makes sense.
|
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ |
| +#define CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ |
| +#pragma once |
| + |
| +#include "base/memory/scoped_ptr.h" |
| +#include "chrome/common/net/gaia/gaia_oauth_client.h" |
| +#include "content/public/browser/notification_details.h" |
| +#include "content/public/browser/notification_observer.h" |
| +#include "content/public/browser/notification_registrar.h" |
| +#include "content/public/browser/notification_source.h" |
| +#include "content/public/common/url_fetcher.h" |
| +#include "content/public/common/url_fetcher_delegate.h" |
| + |
| +// Allow to retrieves an über-auth token for the user. This class uses the |
|
Roger Tawa OOO till Jul 10th
2012/01/31 21:38:23
Do we allow ü in source code?
qsr
2012/02/01 14:59:18
Changed to u, just in case.
|
| +// |TokenService| and considers that the user is already logged in. It will then |
| +// retrieve the OAuth2 refresh token, use it to generate an OAuth2 access token |
| +// and finally use this access token to generate the über-auth token. |
| +// |
| +// This class should be used on a single thread, but it can be whichever thread |
| +// that you like. |
| +// |
| +// This class can handle one request at a time. |
| + |
| +class GoogleServiceAuthError; |
| +class Profile; |
| + |
| +// Callback for the |UbertokenFetcher| class. |
| +class UbertokenConsumer { |
| + public: |
| + UbertokenConsumer() {} |
| + virtual ~UbertokenConsumer() {} |
| + virtual void OnUbertokenSuccess(const std::string& token) {} |
| + virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) {} |
| +}; |
| + |
| +// Allows to retrieve an über-auth token. |
| +class UbertokenFetcher : public content::NotificationObserver, |
| + public gaia::GaiaOAuthClient::Delegate, |
| + public content::URLFetcherDelegate { |
| + public: |
| + UbertokenFetcher(Profile* profile, |
| + UbertokenConsumer* consumer); |
|
Roger Tawa OOO till Jul 10th
2012/01/31 21:38:23
put on one line
qsr
2012/02/01 14:59:18
Done.
|
| + virtual ~UbertokenFetcher(); |
| + |
| + // Start fetching the token. |
| + void StartFetchingToken(); |
| + |
| + // Overriden from gaia::GaiaOAuthClient::Delegate: |
| + virtual void OnGetTokensResponse(const std::string& refresh_token, |
| + const std::string& access_token, |
| + int expires_in_seconds) OVERRIDE; |
| + virtual void OnRefreshTokenResponse(const std::string& access_token, |
| + int expires_in_seconds) OVERRIDE; |
| + virtual void OnOAuthError() OVERRIDE; |
| + virtual void OnNetworkError(int response_code) OVERRIDE; |
| + |
| + |
| + // Overriden from content::NotificationObserver: |
| + virtual void Observe(int type, |
| + const content::NotificationSource& source, |
| + const content::NotificationDetails& details) OVERRIDE; |
| + |
| + // Overriden from content::URLFetcherDelegate: |
| + virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; |
| + |
| + private: |
| + void StartFetchingUbertoken(); |
| + |
| + Profile* profile_; |
| + UbertokenConsumer* consumer_; |
| + content::NotificationRegistrar registrar_; |
| + scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; |
| + scoped_ptr<content::URLFetcher> url_fetcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(UbertokenFetcher); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ |