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

Unified Diff: chrome/browser/services/gcm/push_messaging_application_id.cc

Issue 953423003: Push API: Workaround for GCM lowercasing subtypes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Don't uppercase the leading "wp:" Created 5 years, 10 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/services/gcm/push_messaging_application_id.cc
diff --git a/chrome/browser/services/gcm/push_messaging_application_id.cc b/chrome/browser/services/gcm/push_messaging_application_id.cc
index c35e396821c219d76c4d2a3f01dd7781028aba3c..eb2b436e0379fe3f254438b36761e3e9bbcaeb79 100644
--- a/chrome/browser/services/gcm/push_messaging_application_id.cc
+++ b/chrome/browser/services/gcm/push_messaging_application_id.cc
@@ -10,6 +10,7 @@
#include "base/prefs/scoped_user_pref_update.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_split.h"
+#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
@@ -50,11 +51,20 @@ PushMessagingApplicationId PushMessagingApplicationId::Generate(
// static
PushMessagingApplicationId PushMessagingApplicationId::Get(
Profile* profile, const std::string& app_id_guid) {
+ // Workaround crbug.com/461867 in GCM where it converts subtypes to lowercase.
+ // TODO(johnme): Remove this when obsolete
+ const size_t prefix_len = strlen(kPushMessagingApplicationIdPrefix);
+ if (app_id_guid.size() < prefix_len)
+ return PushMessagingApplicationId();
+ std::string uppercase_app_id =
+ app_id_guid.substr(0, prefix_len) +
+ StringToUpperASCII(app_id_guid.substr(prefix_len, std::string::npos));
+
const base::DictionaryValue* map =
profile->GetPrefs()->GetDictionary(prefs::kPushMessagingApplicationIdMap);
std::string origin_and_sw_id;
- if (!map->GetStringWithoutPathExpansion(app_id_guid, &origin_and_sw_id))
+ if (!map->GetStringWithoutPathExpansion(uppercase_app_id, &origin_and_sw_id))
return PushMessagingApplicationId();
std::vector<std::string> parts;
@@ -68,7 +78,7 @@ PushMessagingApplicationId PushMessagingApplicationId::Get(
if (!base::StringToInt64(parts[1], &service_worker_registration_id))
return PushMessagingApplicationId();
- PushMessagingApplicationId application_id(app_id_guid, origin,
+ PushMessagingApplicationId application_id(uppercase_app_id, origin,
service_worker_registration_id);
DCHECK(application_id.IsValid());
return application_id;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698