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

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

Powered by Google App Engine
This is Rietveld 408576698