| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_
H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_
H_ |
| 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_
H_ | 6 #define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_
H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "google_apis/gaia/oauth2_api_call_flow.h" | 10 #include "google_apis/gaia/oauth2_api_call_flow.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 virtual void OnObfuscatedGaiaIdFetchSuccess( | 34 virtual void OnObfuscatedGaiaIdFetchSuccess( |
| 35 const std::string& obfuscated_id) {} | 35 const std::string& obfuscated_id) {} |
| 36 virtual void OnObfuscatedGaiaIdFetchFailure( | 36 virtual void OnObfuscatedGaiaIdFetchFailure( |
| 37 const GoogleServiceAuthError& error) {} | 37 const GoogleServiceAuthError& error) {} |
| 38 virtual ~Delegate() {} | 38 virtual ~Delegate() {} |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 // TODO(petewil): Someday let's make a profile keyed service to cache | 41 // TODO(petewil): Someday let's make a profile keyed service to cache |
| 42 // the Gaia ID. | 42 // the Gaia ID. |
| 43 explicit ObfuscatedGaiaIdFetcher(Delegate* delegate); | 43 explicit ObfuscatedGaiaIdFetcher(Delegate* delegate); |
| 44 virtual ~ObfuscatedGaiaIdFetcher(); | 44 ~ObfuscatedGaiaIdFetcher() override; |
| 45 | 45 |
| 46 static OAuth2TokenService::ScopeSet GetScopes(); | 46 static OAuth2TokenService::ScopeSet GetScopes(); |
| 47 | 47 |
| 48 protected: | 48 protected: |
| 49 // OAuth2ApiCallFlow implementation | 49 // OAuth2ApiCallFlow implementation |
| 50 virtual GURL CreateApiCallUrl() override; | 50 GURL CreateApiCallUrl() override; |
| 51 virtual std::string CreateApiCallBody() override; | 51 std::string CreateApiCallBody() override; |
| 52 virtual void ProcessApiCallSuccess( | 52 void ProcessApiCallSuccess(const net::URLFetcher* source) override; |
| 53 const net::URLFetcher* source) override; | 53 void ProcessApiCallFailure(const net::URLFetcher* source) override; |
| 54 virtual void ProcessApiCallFailure( | |
| 55 const net::URLFetcher* source) override; | |
| 56 | 54 |
| 57 private: | 55 private: |
| 58 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp); | 56 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp); |
| 59 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse); | 57 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse); |
| 60 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess); | 58 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess); |
| 61 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure); | 59 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure); |
| 62 | 60 |
| 63 void ReportSuccess(const std::string& obfuscated_id); | 61 void ReportSuccess(const std::string& obfuscated_id); |
| 64 void ReportFailure(const GoogleServiceAuthError& error); | 62 void ReportFailure(const GoogleServiceAuthError& error); |
| 65 | 63 |
| 66 // Get the obfuscated Gaia ID out of the response body. | 64 // Get the obfuscated Gaia ID out of the response body. |
| 67 static bool ParseResponse( | 65 static bool ParseResponse( |
| 68 const std::string& data, std::string* obfuscated_id); | 66 const std::string& data, std::string* obfuscated_id); |
| 69 | 67 |
| 70 // Unowned pointer to the delegate. Normally the delegate owns | 68 // Unowned pointer to the delegate. Normally the delegate owns |
| 71 // this fetcher class. | 69 // this fetcher class. |
| 72 Delegate* delegate_; | 70 Delegate* delegate_; |
| 73 | 71 |
| 74 DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher); | 72 DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher); |
| 75 }; | 73 }; |
| 76 | 74 |
| 77 } // namespace extensions | 75 } // namespace extensions |
| 78 | 76 |
| 79 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCH
ER_H_ | 77 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCH
ER_H_ |
| OLD | NEW |