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

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: More style fixes per Munjal and DCheng 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 cc92f87bf20c337da9829d319bb89c3c14820560..81fabf148e5a0a9a0bb5234a5c2bc48ea299ec23 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/signin/token_service.h"
+#include "chrome/browser/signin/token_service_factory.h"
#include "chrome/common/extensions/api/experimental_push_messaging.h"
#include "content/public/browser/browser_thread.h"
#include "googleurl/src/gurl.h"
+#include "chrome/browser/extensions/api/push_messaging/obfuscated_gaia_id_fetcher.h"
+
+using content::BrowserThread;
namespace extensions {
@@ -43,4 +48,64 @@ void PushMessagingEventRouter::OnMessage(const std::string& extension_id,
GURL());
}
+PushMessagingGetChannelIdFunction::PushMessagingGetChannelIdFunction() {}
+
+PushMessagingGetChannelIdFunction::~PushMessagingGetChannelIdFunction() {}
+
+bool PushMessagingGetChannelIdFunction::RunImpl() {
+ // Start the async fetch of the GAIA ID.
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ net::URLRequestContextGetter* context = profile()->GetRequestContext();
+ TokenService* token_service = TokenServiceFactory::GetForProfile(profile());
+ const std::string& refresh_token =
+ token_service->GetOAuth2LoginRefreshToken();
+ fetcher_.reset(new ObfuscatedGaiaIdFetcher(context, this, refresh_token));
+
+ // Balanced in ReportResult()
+ AddRef();
+
+ fetcher_->Start();
+
+ // Will finish asynchronously.
+ return true;
+}
+
+void PushMessagingGetChannelIdFunction::ReportResult(
+ const std::string& gaia_id, long status) {
+ DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
+ // Unpack the status and GaiaId parameters, and use it to build the
+ // channel ID here.
+ std::string channel_id(gaia_id);
+ if (!gaia_id.empty()) {
+ channel_id += ".";
+ channel_id += extension_id();
+ } else if (status != 0) {
dcheng 2012/08/20 22:52:22 That means if gaia_id is empty and status is zero
Pete Williamson 2012/08/20 23:19:28 != was supposed to be ==, changed.
+ status = GoogleServiceAuthError::INVALID_GAIA_CREDENTIALS;
+ }
+
+ // TODO(petewil): It may be a good idea to further
+ // obfuscate the channel ID to prevent the user's obfuscated GAIA ID
+ // from being readily obtained. Security review will tell us if we need to.
+
+ // Create a ChannelId results object and set the fields.
+ glue::ChannelIdResult result;
+ result.channel_id = channel_id;
+ result.status = status;
+ results_ = glue::GetChannelId::Results::Create(result);
+ SendResponse(true);
+
+ // Balanced in RunImpl
+ Release();
+}
+
+void PushMessagingGetChannelIdFunction::OnObfuscatedGaiaIdFetchSuccess(
+ const std::string& gaia_id) {
+ ReportResult(gaia_id, 0);
+}
+
+void PushMessagingGetChannelIdFunction::OnObfuscatedGaiaIdFetchFailure(
+ const GoogleServiceAuthError& error) {
+ ReportResult(std::string(), error.state());
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698