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

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: More CR changes per DCheng 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
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 // This file has code to fetch the Obfuscated GAIA ID from the server
Mihai Parparita -not on Chrome 2012/08/22 21:40:45 Redundant comment.
Pete Williamson 2012/08/23 17:20:50 Done.
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
12 #include "chrome/common/net/gaia/oauth2_api_call_flow.h"
13
14 class GoogleServiceAuthError;
15
16 namespace content {
17 class URLFetcher;
18 }
19
20 namespace net {
21 class URLRequestContextGetter;
22 }
23
24 namespace extensions {
25
26 // Fetches obfuscated gaia id of the Google Account that is logged in to Chrome.
Mihai Parparita -not on Chrome 2012/08/22 21:40:45 Capitalize Gaia and ID (in other comments too). A
Pete Williamson 2012/08/23 17:20:50 Done.
27 // This starts an asynchronous operation which reports success to the delegate.
28 // Call "Start()" to start the async fetch.
29 class ObfuscatedGaiaIdFetcher : public OAuth2ApiCallFlow {
30 public:
31 // Delegate interface that is called when obfuscated gaia id fetch
32 // succeeds or fails.
33 class Delegate {
34 public:
35 virtual void OnObfuscatedGaiaIdFetchSuccess(
36 const std::string& obfuscated_id) {}
37 virtual void OnObfuscatedGaiaIdFetchFailure(
38 const GoogleServiceAuthError& error) {}
39 virtual ~Delegate() {}
40 };
41
42 // TODO(petewil): Someday let's make a profile keyed service to cache
43 // the GAIA ID.
44
45 ObfuscatedGaiaIdFetcher(net::URLRequestContextGetter* context,
46 Delegate* delegate,
47 const std::string& refresh_token);
48 virtual ~ObfuscatedGaiaIdFetcher();
49
50 protected:
51 // OAuth2ApiCallFlow implementation
52 virtual GURL CreateApiCallUrl() OVERRIDE;
53 virtual std::string CreateApiCallBody() OVERRIDE;
54 virtual void ProcessApiCallSuccess(
55 const net::URLFetcher* source) OVERRIDE;
56 virtual void ProcessApiCallFailure(
57 const net::URLFetcher* source) OVERRIDE;
58 virtual void ProcessNewAccessToken(const std::string& access_token) OVERRIDE;
59 virtual void ProcessMintAccessTokenFailure(
60 const GoogleServiceAuthError& error) OVERRIDE;
61
62 private:
63 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp);
64 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse);
65 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess);
66 FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure);
67
68 void ReportSuccess(const std::string& obfuscated_id);
69 void ReportFailure(const GoogleServiceAuthError& error);
70
71 // Get the obfuscated GAIA ID out of the response body.
72 static bool ParseResponse(
73 const std::string& data, std::string* obfuscated_id);
74
75 // Unowned pointer to the delegate. Normally the delegate owns
76 // this fetcher class.
77 Delegate* delegate_;
78
79 DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher);
80 };
81
82 } // namespace extensions
83
84 #endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCH ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698