Chromium Code Reviews| Index: chrome/browser/signin/account_service_flag_fetcher.h |
| diff --git a/chrome/browser/signin/account_service_flag_fetcher.h b/chrome/browser/signin/account_service_flag_fetcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..02b1a99d28db22d6245adbb80e11b92be799ef29 |
| --- /dev/null |
| +++ b/chrome/browser/signin/account_service_flag_fetcher.h |
| @@ -0,0 +1,72 @@ |
| +// Copyright 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_ |
| +#define CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_ |
| + |
| +#include <string> |
| +#include <vector> |
| + |
| +#include "base/callback.h" |
| +#include "base/memory/scoped_ptr.h" |
| +#include "google_apis/gaia/gaia_auth_consumer.h" |
| +#include "google_apis/gaia/gaia_auth_fetcher.h" |
| +#include "google_apis/gaia/oauth2_token_service.h" |
| + |
| +class Profile; |
| + |
| +// Downloads an account's list of Gaia service flags. |
| +class AccountServiceFlagFetcher : public GaiaAuthConsumer, |
|
Bernhard Bauer
2014/05/16 08:19:38
Gaia account maybe? This is very specific to Gaia.
Marc Treib
2014/05/20 10:46:40
Drew, WDYT? "Account" is used as a synonym for "Ga
Bernhard Bauer
2014/05/20 12:35:27
Oh, right. OK, if account in here means Gaia accou
|
| + public OAuth2TokenService::Observer, |
| + public OAuth2TokenService::Consumer { |
| + public: |
| + // Callback for Start() below. If the flag download is successful, this will |
| + // return the list of service flags that are set for the primary account. |
| + typedef base::Callback<void(const std::vector<std::string>& /* flags */)> |
|
Andrew T Wilson (Slow)
2014/05/16 08:44:44
What do you do in case of error?
Marc Treib
2014/05/20 10:46:40
I've added a status enum to the callback to report
|
| + Callback; |
| + |
| + explicit AccountServiceFlagFetcher(Profile* profile); |
|
Andrew T Wilson (Slow)
2014/05/16 08:44:44
Please put this in components/signin. To do this,
Marc Treib
2014/05/20 10:46:40
Done. The SigninManager actually isn't required, i
|
| + virtual ~AccountServiceFlagFetcher(); |
| + |
| + // Starts fetching the flags. Must not be called again while a previous call |
| + // is still pending. The callback will be called iff the flags are |
| + // successfully fetched. |
| + void Start(const Callback& callback); |
| + |
| + // Cancels the pending request (if any). |
| + void Cancel(); |
|
Andrew T Wilson (Slow)
2014/05/16 08:44:44
Do you have to call Cancel() before destroying the
Marc Treib
2014/05/20 10:46:40
Okay, now the constructor immediately starts the r
|
| + |
| + // Returns whether a previous call to Start() is still pending. |
| + bool IsPending() const; |
| + |
| + private: |
| + void StartFetchingOAuth2AccessToken(const std::string& account_id); |
| + |
| + // Overridden from OAuth2TokenService::Observer: |
| + virtual void OnRefreshTokenAvailable(const std::string& account_id) OVERRIDE; |
| + |
| + // Overridden from OAuth2TokenService::Consumer: |
| + virtual void OnGetTokenSuccess(const OAuth2TokenService::Request* request, |
| + const std::string& access_token, |
| + const base::Time& expiration_time) OVERRIDE; |
| + virtual void OnGetTokenFailure(const OAuth2TokenService::Request* request, |
| + const GoogleServiceAuthError& error) OVERRIDE; |
| + |
| + // Overridden from GaiaAuthConsumer: |
| + virtual void OnClientLoginSuccess(const ClientLoginResult& result) OVERRIDE; |
| + virtual void OnClientLoginFailure(const GoogleServiceAuthError& error) |
| + OVERRIDE; |
| + virtual void OnGetUserInfoSuccess(const UserInfoMap& data) OVERRIDE; |
| + virtual void OnGetUserInfoFailure(const GoogleServiceAuthError& error) |
| + OVERRIDE; |
| + |
| + Profile* profile_; |
| + |
| + Callback callback_; |
| + |
| + scoped_ptr<OAuth2TokenService::Request> oauth2_access_token_request_; |
| + GaiaAuthFetcher gaia_auth_fetcher_; |
| +}; |
| + |
| +#endif // CHROME_BROWSER_SIGNIN_ACCOUNT_SERVICE_FLAG_FETCHER_H_ |