Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright (c) 2012 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. | |
| 4 | |
| 5 // This file has code to fetch the Obfuscated GAIA ID from the server | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_ H_ | |
| 8 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_ H_ | |
| 9 | |
| 10 #include <string> | |
| 11 #include <vector> | |
| 12 | |
| 13 #include "base/memory/ref_counted.h" | |
| 14 #include "base/string16.h" | |
| 15 #include "chrome/common/net/gaia/oauth2_api_call_flow.h" | |
| 16 | |
| 17 class GoogleServiceAuthError; | |
| 18 | |
| 19 namespace base { | |
| 20 class DictionaryValue; | |
|
dcheng
2012/08/20 19:10:01
This is unused.
dcheng
2012/08/20 19:10:01
Unused.
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 21 } | |
| 22 | |
| 23 namespace content { | |
| 24 class URLFetcher; | |
| 25 } | |
| 26 | |
| 27 namespace net { | |
| 28 class URLRequestContextGetter; | |
| 29 } | |
| 30 | |
| 31 namespace extensions { | |
| 32 | |
| 33 // Fetches obfuscated gaia id of the Google Account that is logged in to Chrome. | |
| 34 // This starts an asynchronous operation which reports success to the delegate. | |
| 35 // Call "Start()" to start the async fetch. | |
| 36 class ObfuscatedGaiaIdFetcher : public OAuth2ApiCallFlow { | |
| 37 public: | |
| 38 // Delegate interface that is called when obfuscated gaia id fetch | |
| 39 // succeeds or fails. | |
| 40 class Delegate { | |
| 41 public: | |
| 42 virtual void OnObfuscatedGaiaIdFetchSuccess( | |
| 43 const std::string& obfuscated_id) {} | |
| 44 virtual void OnObfuscatedGaiaIdFetchFailure( | |
| 45 const GoogleServiceAuthError& error) {} | |
| 46 virtual ~Delegate() {} | |
| 47 }; | |
| 48 | |
| 49 // TODO: Someday let's make a profile keyed service to cache the GAIA ID. | |
|
dcheng
2012/08/20 19:10:01
Should be TODO(petewil)
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 50 | |
| 51 ObfuscatedGaiaIdFetcher(net::URLRequestContextGetter* context, | |
| 52 Delegate* delegate, | |
| 53 const std::string& refresh_token); | |
| 54 virtual ~ObfuscatedGaiaIdFetcher(); | |
| 55 | |
| 56 protected: | |
| 57 // OAuth2ApiCallFlow implementation | |
| 58 virtual GURL CreateApiCallUrl() OVERRIDE; | |
| 59 virtual std::string CreateApiCallBody() OVERRIDE; | |
| 60 virtual void ProcessApiCallSuccess( | |
| 61 const net::URLFetcher* source) OVERRIDE; | |
| 62 virtual void ProcessApiCallFailure( | |
| 63 const net::URLFetcher* source) OVERRIDE; | |
| 64 virtual void ProcessNewAccessToken(const std::string& access_token) OVERRIDE; | |
| 65 virtual void ProcessMintAccessTokenFailure( | |
| 66 const GoogleServiceAuthError& error) OVERRIDE; | |
| 67 | |
| 68 private: | |
| 69 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp); | |
| 70 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse); | |
| 71 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess); | |
| 72 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure); | |
| 73 | |
| 74 void ReportSuccess(const std::string& obfuscated_id); | |
| 75 void ReportFailure(const GoogleServiceAuthError& error); | |
| 76 | |
| 77 // Get the obfuscated GAIA ID out of the response body. | |
| 78 static bool ParseResponse( | |
| 79 const std::string& data, std::string* obfuscated_id); | |
| 80 | |
| 81 // Unowned, weak pointer to the delegate. Normally the delegate owns | |
|
dcheng
2012/08/20 19:10:01
Don't use "weak" since we have WeakPtr<T> as well.
Munjal (Google)
2012/08/20 20:01:25
Agree with Daniel.
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 82 // this fetcher class. | |
| 83 Delegate* delegate_; | |
| 84 std::string obfuscated_gaia_id_; | |
|
dcheng
2012/08/20 19:10:01
It seems like this is unused.
Pete Williamson
2012/08/20 20:53:05
Done.
| |
| 85 | |
| 86 DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher); | |
| 87 }; | |
| 88 | |
| 89 } // namespace extensions | |
| 90 | |
| 91 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCH ER_H_ | |
| OLD | NEW |