Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h

Issue 10836182: Obfuscated Gaia ID fetcher (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: CR fixes per Mihai Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(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 #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_
7
8 #include <string>
9
10 #include "chrome/common/net/gaia/oauth2_api_call_flow.h"
11
12 class GoogleServiceAuthError;
13
14 namespace content {
15 class URLFetcher;
16 }
17
18 namespace net {
19 class URLRequestContextGetter;
20 }
21
22 namespace extensions {
23
24 // Fetches obfuscated Gaia ID of the Google Account that is logged in to Chrome.
25 // This starts an asynchronous operation which reports success to the delegate.
26 // Call "Start()" to start the async fetch.
27 class ObfuscatedGaiaIdFetcher : public OAuth2ApiCallFlow {
28 public:
29 // Delegate interface that is called when obfuscated Gaia id fetch
30 // succeeds or fails.
31 class Delegate {
32 public:
33 virtual void OnObfuscatedGaiaIdFetchSuccess(
34 const std::string& obfuscated_id) {}
35 virtual void OnObfuscatedGaiaIdFetchFailure(
36 const GoogleServiceAuthError& error) {}
37 virtual ~Delegate() {}
38 };
39
40 // TODO(petewil): Someday let's make a profile keyed service to cache
41 // the Gaia ID.
42
43 ObfuscatedGaiaIdFetcher(net::URLRequestContextGetter* context,
44 Delegate* delegate,
45 const std::string& refresh_token);
46 virtual ~ObfuscatedGaiaIdFetcher();
47
48 protected:
49 // OAuth2ApiCallFlow implementation
50 virtual GURL CreateApiCallUrl() OVERRIDE;
51 virtual std::string CreateApiCallBody() OVERRIDE;
52 virtual void ProcessApiCallSuccess(
53 const net::URLFetcher* source) OVERRIDE;
54 virtual void ProcessApiCallFailure(
55 const net::URLFetcher* source) OVERRIDE;
56 virtual void ProcessNewAccessToken(const std::string& access_token) OVERRIDE;
57 virtual void ProcessMintAccessTokenFailure(
58 const GoogleServiceAuthError& error) OVERRIDE;
59
60 private:
61 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp);
62 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse);
63 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess);
64 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure);
65
66 void ReportSuccess(const std::string& obfuscated_id);
67 void ReportFailure(const GoogleServiceAuthError& error);
68
69 // Get the obfuscated Gaia ID out of the response body.
70 static bool ParseResponse(
71 const std::string& data, std::string* obfuscated_id);
72
73 // Unowned pointer to the delegate. Normally the delegate owns
74 // this fetcher class.
75 Delegate* delegate_;
76
77 DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher);
78 };
79
80 } // namespace extensions
81
82 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCH ER_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698