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

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: rebase to master 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>
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 #include "chrome/browser/extensions/api/push_messaging/push_messaging_api.h"
Munjal (Google) 2012/08/15 23:04:19 Include ordering is wrong.
Pete Williamson 2012/08/19 22:05:14 Done.
17
18 class GoogleServiceAuthError;
19 class ObfuscatedGaiaIdFetchTest;
dcheng 2012/08/16 19:12:43 This forward declare is unnecessary.
Pete Williamson 2012/08/19 22:05:14 Done.
20
21 namespace base {
22 class DictionaryValue;
23 }
24
25 namespace content {
26 class URLFetcher;
27 }
28
29 namespace net {
30 class URLRequestContextGetter;
31 }
32
33 namespace extensions {
34
35 // Ideally we would use an interface instead of hardcoding to the function,
36 // but we need to use a scoped_refptr to manager refcounts, and we
37 // get an error if we try to put AddRef and Release into an interface,
38 // since they are not virtual.
39 class PushMessagingGetChannelIdFunction;
Munjal (Google) 2012/08/15 23:04:19 I am not sure I understand the situation here. If
Pete Williamson 2012/08/20 18:38:42 Done.
40
41 // Fetches obfuscated gaia id of the Google Account that is logged in to Chrome.
42 // This starts an asynchronous operation which reports success to the delegate.
43 // Call "Start()" to start the async fetch.
44 class ObfuscatedGaiaIdFetcher : public OAuth2ApiCallFlow {
45
Munjal (Google) 2012/08/15 23:04:19 Nit: remove this empty line.
Pete Williamson 2012/08/19 22:05:14 Done.
46 public:
47
Munjal (Google) 2012/08/15 23:04:19 Nit: remove this empty line.
Pete Williamson 2012/08/19 22:05:14 Done.
48 ObfuscatedGaiaIdFetcher(net::URLRequestContextGetter* context,
49 extensions::PushMessagingGetChannelIdFunction*
50 delegate,
Munjal (Google) 2012/08/15 23:04:19 We should try our best to remove this dependency.
Pete Williamson 2012/08/20 18:38:42 Done.
51 const std::string& refresh_token);
52 virtual ~ObfuscatedGaiaIdFetcher();
53
Munjal (Google) 2012/08/15 23:04:19 We need a Start() method. It is not a good idea to
Pete Williamson 2012/08/19 22:05:14 We do have a start method, it is inherited from OA
54 protected:
55 // Implementation of template methods in OAuth2ApiCallFlow.
dcheng 2012/08/16 19:12:43 Nit: These aren't templated, so "template methods"
Pete Williamson 2012/08/19 22:05:14 Done.
56 virtual GURL CreateApiCallUrl() OVERRIDE;
57 virtual std::string CreateApiCallBody() OVERRIDE;
58
Munjal (Google) 2012/08/15 23:04:19 Nit: remove this blank line since the next few met
Pete Williamson 2012/08/19 22:05:14 Done.
59 virtual void ProcessApiCallSuccess(
60 const net::URLFetcher* source) OVERRIDE;
61 virtual void ProcessApiCallFailure(
62 const net::URLFetcher* source) OVERRIDE;
63 virtual void ProcessNewAccessToken(const std::string& access_token) OVERRIDE;
64 virtual void ProcessMintAccessTokenFailure(
65 const GoogleServiceAuthError& error) OVERRIDE;
66
67 private:
68 friend class ObfuscatedGaiaIdFetcherTest;
dcheng 2012/08/16 19:12:43 This line is unnecessary.
Pete Williamson 2012/08/19 22:05:14 Done.
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 static std::vector<std::string> Scopes();
dcheng 2012/08/16 19:12:43 This method name should probably have a verb in it
Pete Williamson 2012/08/20 18:38:42 Done.
78
79 // Get the obfuscated GAIA ID out of the response body.
80 static bool ParseResponse(
81 const std::string& data, std::string* obfuscated_id);
82
83 scoped_refptr<extensions::PushMessagingGetChannelIdFunction> delegate_;
84 std::string obfuscated_gaia_id_;
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_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698