Chromium Code Reviews| Index: chrome/browser/chromeos/arc/arc_auth_fetcher.h |
| diff --git a/chrome/browser/chromeos/arc/arc_auth_fetcher.h b/chrome/browser/chromeos/arc/arc_auth_fetcher.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..f79621d86846c62c405ea38aac3d213b59a6a83f |
| --- /dev/null |
| +++ b/chrome/browser/chromeos/arc/arc_auth_fetcher.h |
| @@ -0,0 +1,61 @@ |
| +// Copyright 2016 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_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ |
| +#define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ |
| + |
| +#include <string> |
| + |
| +#include "base/macros.h" |
| +#include "google_apis/gaia/gaia_auth_consumer.h" |
| +#include "google_apis/gaia/gaia_auth_fetcher.h" |
| + |
| +class GURL; |
| + |
| +namespace net { |
| +class URLRequestContextGetter; |
| +} // namespace net |
| + |
| +namespace arc { |
| + |
| +// Fetches ARC auth code. Fetching process starts automatically on creation. |
| +class ArcAuthFetcher : public GaiaAuthConsumer { |
| + public: |
| + // Returns a result of ARC auth code fetching. |
| + class Delegate { |
| + public: |
| + // Called when code was fetched. |
| + virtual void OnAuthCodeFetched(const std::string& code) = 0; |
| + // Called when additional UI authorization is required. |
| + virtual void OnAuthCodeNeedUI() = 0; |
| + // Called when auth code cannot be received. |
| + virtual void OnAuthCodeFailed() = 0; |
| + }; |
|
xiyuan
2016/01/27 23:56:05
nit: add
protected:
virtual ~Delegate() {}
jus
khmel
2016/01/28 05:22:08
Done.
|
| + |
| + ArcAuthFetcher(net::URLRequestContextGetter* getter, Delegate* delegate); |
| + ~ArcAuthFetcher() override; |
| + |
| + // GaiaAuthConsumer overrides. |
| + void OnClientOAuthCode(const std::string& auth_code) override; |
| + void OnClientOAuthSuccess(const ClientOAuthResult& result) override; |
| + void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; |
| + |
| + // Helper function to compose target URL for current user, also is used in |
| + // test. |
| + static GURL CreateURL(); |
| + |
| + private: |
| + void FetchAuthCode(); |
| + |
| + // Unowned pointer. |
| + Delegate* delegate_; |
|
xiyuan
2016/01/27 23:56:05
nit: Delegate* const since it should never change.
khmel
2016/01/28 05:22:08
Done.
|
| + |
| + GaiaAuthFetcher auth_fetcher_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ArcAuthFetcher); |
| +}; |
| + |
| +} // namespace arc |
| + |
| +#endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ |