OLD | NEW |
---|---|
(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. | |
oshima
2016/01/28 17:46:40
Can this be in components/arc instead? Looks like
khmel
2016/01/28 19:24:01
Yes, we can move.
| |
4 | |
5 #ifndef CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ | |
6 #define CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ | |
7 | |
8 #include <string> | |
9 | |
10 #include "base/macros.h" | |
11 #include "google_apis/gaia/gaia_auth_consumer.h" | |
12 #include "google_apis/gaia/gaia_auth_fetcher.h" | |
13 | |
14 class GURL; | |
15 | |
16 namespace net { | |
17 class URLRequestContextGetter; | |
18 } | |
19 | |
20 namespace arc { | |
21 | |
22 // Fetches ARC auth code. Fetching process starts automatically on creation. | |
23 class ArcAuthFetcher : public GaiaAuthConsumer { | |
24 public: | |
25 // Returns a result of ARC auth code fetching. | |
26 class Delegate { | |
27 public: | |
28 // Called when code was fetched. | |
29 virtual void OnAuthCodeFetched(const std::string& code) = 0; | |
30 // Called when additional UI authorization is required. | |
31 virtual void OnAuthCodeNeedUI() = 0; | |
32 // Called when auth code cannot be received. | |
33 virtual void OnAuthCodeFailed() = 0; | |
34 | |
35 protected: | |
36 virtual ~Delegate() {} | |
oshima
2016/01/28 17:46:40
= default;
same for other default ctor/dtor.
khmel
2016/01/28 19:24:01
Done.
| |
37 }; | |
38 | |
39 ArcAuthFetcher(net::URLRequestContextGetter* getter, Delegate* delegate); | |
40 ~ArcAuthFetcher() override; | |
41 | |
42 // GaiaAuthConsumer overrides. | |
43 void OnClientOAuthCode(const std::string& auth_code) override; | |
44 void OnClientOAuthFailure(const GoogleServiceAuthError& error) override; | |
45 | |
46 // Helper function to compose target URL for current user, also is used in | |
47 // test. | |
48 static GURL CreateURL(); | |
49 | |
50 private: | |
51 void FetchAuthCode(); | |
52 | |
53 // Unowned pointer. | |
54 Delegate* const delegate_; | |
55 | |
56 GaiaAuthFetcher auth_fetcher_; | |
57 | |
58 DISALLOW_COPY_AND_ASSIGN(ArcAuthFetcher); | |
59 }; | |
60 | |
61 } // namespace arc | |
62 | |
63 #endif // CHROME_BROWSER_CHROMEOS_ARC_ARC_AUTH_FETCHER_H_ | |
OLD | NEW |