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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h
diff --git a/chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h b/chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h
new file mode 100644
index 0000000000000000000000000000000000000000..c1025a19a93f9f319d9cf6920831e3570d43bf9c
--- /dev/null
+++ b/chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h
@@ -0,0 +1,87 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// This file has code to fetch the Obfuscated GAIA ID from the server
+
+#ifndef CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_H_
+#define CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_H_
+
+#include <string>
+#include <vector>
dcheng 2012/08/20 21:04:13 This #include is unused.
Pete Williamson 2012/08/20 22:26:45 Done.
+
+#include "base/memory/ref_counted.h"
dcheng 2012/08/20 21:04:13 Ditto.
Pete Williamson 2012/08/20 22:26:45 Done.
+#include "base/string16.h"
dcheng 2012/08/20 21:04:13 Ditto.
Pete Williamson 2012/08/20 22:26:45 Done.
+#include "chrome/common/net/gaia/oauth2_api_call_flow.h"
+
+class GoogleServiceAuthError;
+
+namespace content {
+class URLFetcher;
+}
+
+namespace net {
+class URLRequestContextGetter;
+}
+
+namespace extensions {
+
+// Fetches obfuscated gaia id of the Google Account that is logged in to Chrome.
+// This starts an asynchronous operation which reports success to the delegate.
+// Call "Start()" to start the async fetch.
+class ObfuscatedGaiaIdFetcher : public OAuth2ApiCallFlow {
+ public:
+ // Delegate interface that is called when obfuscated gaia id fetch
+ // succeeds or fails.
+ class Delegate {
+ public:
+ virtual void OnObfuscatedGaiaIdFetchSuccess(
+ const std::string& obfuscated_id) {}
+ virtual void OnObfuscatedGaiaIdFetchFailure(
+ const GoogleServiceAuthError& error) {}
+ virtual ~Delegate() {}
+ };
+
+ // TODO(petewil): Someday let's make a profile keyed service to cache
+ // the GAIA ID.
+
+ ObfuscatedGaiaIdFetcher(net::URLRequestContextGetter* context,
+ Delegate* delegate,
+ const std::string& refresh_token);
+ virtual ~ObfuscatedGaiaIdFetcher();
+
+ protected:
+ // OAuth2ApiCallFlow implementation
+ virtual GURL CreateApiCallUrl() OVERRIDE;
+ virtual std::string CreateApiCallBody() OVERRIDE;
+ virtual void ProcessApiCallSuccess(
+ const net::URLFetcher* source) OVERRIDE;
+ virtual void ProcessApiCallFailure(
+ const net::URLFetcher* source) OVERRIDE;
+ virtual void ProcessNewAccessToken(const std::string& access_token) OVERRIDE;
+ virtual void ProcessMintAccessTokenFailure(
+ const GoogleServiceAuthError& error) OVERRIDE;
+
+ private:
+ FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, SetUp);
+ FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ParseResponse);
+ FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallSuccess);
+ FRIEND_TEST_ALL_PREFIXES(ObfuscatedGaiaIdFetcherTest, ProcessApiCallFailure);
+
+ void ReportSuccess(const std::string& obfuscated_id);
+ void ReportFailure(const GoogleServiceAuthError& error);
+
+ // Get the obfuscated GAIA ID out of the response body.
+ static bool ParseResponse(
+ const std::string& data, std::string* obfuscated_id);
+
+ // Unowned pointer to the delegate. Normally the delegate owns
+ // this fetcher class.
+ Delegate* delegate_;
+
+ DISALLOW_COPY_AND_ASSIGN(ObfuscatedGaiaIdFetcher);
+};
+
+} // namespace extensions
+
+#endif // CHROME_BROWSER_EXTENSIONS_API_PUSH_MESSAGING_OBFUSCATED_GAIA_ID_FETCHER_H_

Powered by Google App Engine
This is Rietveld 408576698