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

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: 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..697ccd1e198aed7e674bc3a0dd8cbf6e8d01010c 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,59 @@ 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) << "*** Obfuscated Gaia Id fetch returned success, "
+ << access_token << " ***";
+ delete this; // TODO: temp only, remove when part of outer class
+ }
+ virtual void OnObfuscatedGaiaIdFetchFailure(
+ const GoogleServiceAuthError& error) {
+ LOG(INFO) << "*** Obfuscated Gaia Id fetch failed, error is "
+ << (int) error.state();
+ delete this; // TODO: temp only, remove when part of outer class
+ }
+
+};
Munjal (Google) 2012/08/09 21:44:29 This seems like temporary code?
+
+// free function to start the fetch operation
+void StartGaiaIdFetch() {
+ // TODO: I really want to use the profile passed in, not get the last one
+ Profile* profile = ProfileManager::GetLastUsedProfile();
+ // 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();
+ const std::string extensionId = "joginpnpfmplidoohnmocbdijkchphdm";
+ // TODO: we really want extensionId = ExtensionFunction::GetExtension()->id();
+ // but that in only available once we have a class inheriting
+ // from ExtensionFuction, which we will likely have later on
+ ObfuscatedGaiaIdFetcher::Parameters parameters(refreshToken, extensionId);
+ GaiaFetcherDelegate* delegate = new GaiaFetcherDelegate();
+ // TODO: Don't forget to manage the lifetime of the fetcher object
+ ObfuscatedGaiaIdFetcher* fetcher =
+ new ObfuscatedGaiaIdFetcher(context, delegate, parameters);
+ fetcher->Start();
+ LOG(INFO) << "*** PushMessagingEventRouter::Init exiting ***";
+}
+
void PushMessagingEventRouter::Init() {
// TODO(dcheng): Add hooks into InvalidationHandler when landed.
+
+ // MessageLoop::current()->PostDelayedTask(
+ // FROM_HERE,
+ // base::Bind(&StartGaiaIdFetch),
+ // base::TimeDelta::FromMilliseconds(2000));
+
+
}
Munjal (Google) 2012/08/09 21:44:29 Seems like all changes ot this file are done for t
void PushMessagingEventRouter::OnMessage(const std::string& extension_id,

Powered by Google App Engine
This is Rietveld 408576698