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

Unified Diff: chrome/browser/extensions/api/push_messaging/push_messaging_api.cc

Issue 10836182: Obfuscated Gaia ID fetcher (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: CR changes per 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/push_messaging_api.cc
diff --git a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
index aaa36a50af7813ba08a920ffc2c41f870c298377..c6b96f4595d60954c313e2be3903e5510b163c7e 100644
--- a/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
+++ b/chrome/browser/extensions/api/push_messaging/push_messaging_api.cc
@@ -9,9 +9,14 @@
#include "chrome/browser/extensions/event_names.h"
#include "chrome/browser/extensions/event_router.h"
#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/profiles/profile_manager.h"
+#include "chrome/browser/signin/token_service.h"
+#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/common/extensions/api/experimental_push_messaging.h"
+#include "chrome/common/net/gaia/google_service_auth_error.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
+#include "obfuscated_gaia_id_fetcher.h"
namespace extensions {
@@ -23,8 +28,56 @@ PushMessagingEventRouter::PushMessagingEventRouter(Profile* profile)
PushMessagingEventRouter::~PushMessagingEventRouter() {}
+// TODO: Move these methods to be on the class that eventually creates
+// the Obfuscated Gaia ID fetcher, and pass "this" from that class for
+// the delegate.
+class GaiaFetcherDelegate : public ObfuscatedGaiaIdFetcher::Delegate {
+ public:
+ GaiaFetcherDelegate() {}
+ virtual ~GaiaFetcherDelegate() {}
+ virtual void OnObfuscatedGaiaIdFetchSuccess(
+ const std::string& access_token) {
+ LOG(INFO) << "*** GaiaFetcherDelegate::OnObfuscatedGaiaIdFetchSuccess"
+ << "- success, " << access_token << " ***";
+ delete this; // TODO: temp only, remove when part of outer class
+ }
+ virtual void OnObfuscatedGaiaIdFetchFailure(
+ const GoogleServiceAuthError& error) {
+ LOG(INFO) << "*** GaiaFetcherDelegate::OnObfuscatedGaiaIdFetchFailure, "
+ << "error is " << (int) error.state() << " ***";
+ delete this; // TODO: temp only, remove when part of outer class
+ }
+
+};
+
+// free function to start the fetch operation
+void StartGaiaIdFetch(Profile* profile) {
+ // TODO: Not for checkin, just for testing, remove all this before checkin
+ // LOG(INFO) << "*** PushMessagingEventRouter::Init called ***";
+ TokenService* token_service = TokenServiceFactory::GetForProfile(profile);
+ net::URLRequestContextGetter* context = profile->GetRequestContext();
+ const std::string refreshToken = token_service->GetOAuth2LoginRefreshToken();
+ GaiaFetcherDelegate* delegate = new GaiaFetcherDelegate();
+ std::vector<std::string> scopes;
+ scopes.push_back(
+ "https://www.googleapis.com/auth/chromewebstore.notification");
Munjal (Google) 2012/08/15 20:15:44 Put this scope in ObfuscatedGaiaIdFetcher class in
+ // TODO: Don't forget to manage the lifetime of the fetcher object
+ ObfuscatedGaiaIdFetcher* fetcher =
+ new ObfuscatedGaiaIdFetcher(context, delegate, refreshToken, scopes);
+ fetcher->Start();
+ // LOG(INFO) << "*** PushMessagingEventRouter::Init exiting ***";
+}
+
void PushMessagingEventRouter::Init() {
// TODO(dcheng): Add hooks into InvalidationHandler when landed.
+
+ // TODO: remove this and do it the right way before checkin
+ MessageLoop::current()->PostDelayedTask(
+ FROM_HERE,
+ base::Bind(&StartGaiaIdFetch, profile_),
+ base::TimeDelta::FromMilliseconds(2000));
+
+
}
void PushMessagingEventRouter::OnMessage(const std::string& extension_id,

Powered by Google App Engine
This is Rietveld 408576698