OLD | NEW |
---|---|
(Empty) | |
1 // 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.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ | |
6 #define CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ | |
7 #pragma once | |
8 | |
9 #include "base/memory/scoped_ptr.h" | |
10 #include "chrome/common/net/gaia/gaia_oauth_client.h" | |
11 #include "content/public/browser/notification_details.h" | |
12 #include "content/public/browser/notification_observer.h" | |
13 #include "content/public/browser/notification_registrar.h" | |
14 #include "content/public/browser/notification_source.h" | |
15 #include "content/public/common/url_fetcher.h" | |
16 #include "content/public/common/url_fetcher_delegate.h" | |
17 | |
18 // 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.
| |
19 // |TokenService| and considers that the user is already logged in. It will then | |
20 // retrieve the OAuth2 refresh token, use it to generate an OAuth2 access token | |
21 // and finally use this access token to generate the über-auth token. | |
22 // | |
23 // This class should be used on a single thread, but it can be whichever thread | |
24 // that you like. | |
25 // | |
26 // This class can handle one request at a time. | |
27 | |
28 class GoogleServiceAuthError; | |
29 class Profile; | |
30 | |
31 // Callback for the |UbertokenFetcher| class. | |
32 class UbertokenConsumer { | |
33 public: | |
34 UbertokenConsumer() {} | |
35 virtual ~UbertokenConsumer() {} | |
36 virtual void OnUbertokenSuccess(const std::string& token) {} | |
37 virtual void OnUbertokenFailure(const GoogleServiceAuthError& error) {} | |
38 }; | |
39 | |
40 // Allows to retrieve an über-auth token. | |
41 class UbertokenFetcher : public content::NotificationObserver, | |
42 public gaia::GaiaOAuthClient::Delegate, | |
43 public content::URLFetcherDelegate { | |
44 public: | |
45 UbertokenFetcher(Profile* profile, | |
46 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.
| |
47 virtual ~UbertokenFetcher(); | |
48 | |
49 // Start fetching the token. | |
50 void StartFetchingToken(); | |
51 | |
52 // Overriden from gaia::GaiaOAuthClient::Delegate: | |
53 virtual void OnGetTokensResponse(const std::string& refresh_token, | |
54 const std::string& access_token, | |
55 int expires_in_seconds) OVERRIDE; | |
56 virtual void OnRefreshTokenResponse(const std::string& access_token, | |
57 int expires_in_seconds) OVERRIDE; | |
58 virtual void OnOAuthError() OVERRIDE; | |
59 virtual void OnNetworkError(int response_code) OVERRIDE; | |
60 | |
61 | |
62 // Overriden from content::NotificationObserver: | |
63 virtual void Observe(int type, | |
64 const content::NotificationSource& source, | |
65 const content::NotificationDetails& details) OVERRIDE; | |
66 | |
67 // Overriden from content::URLFetcherDelegate: | |
68 virtual void OnURLFetchComplete(const content::URLFetcher* source) OVERRIDE; | |
69 | |
70 private: | |
71 void StartFetchingUbertoken(); | |
72 | |
73 Profile* profile_; | |
74 UbertokenConsumer* consumer_; | |
75 content::NotificationRegistrar registrar_; | |
76 scoped_ptr<gaia::GaiaOAuthClient> gaia_oauth_client_; | |
77 scoped_ptr<content::URLFetcher> url_fetcher_; | |
78 | |
79 DISALLOW_COPY_AND_ASSIGN(UbertokenFetcher); | |
80 }; | |
81 | |
82 #endif // CHROME_BROWSER_SIGNIN_UBERTOKEN_FETCHER_H_ | |
OLD | NEW |