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

Unified Diff: chrome/browser/push_messaging/push_messaging_app_identifier.cc

Issue 2697793004: Push API: Validate storage before returning cached subscriptions (Closed)
Patch Set: Comment out PUSH_GETREGISTRATION_STATUS_PUBLIC_KEY_UNAVAILABLE Created 3 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
Index: chrome/browser/push_messaging/push_messaging_app_identifier.cc
diff --git a/chrome/browser/push_messaging/push_messaging_app_identifier.cc b/chrome/browser/push_messaging/push_messaging_app_identifier.cc
index fc2f52a0b67c7e18970365411e5bfa1d14be4990..1e23692414ae7516551d593da0d7a5715a0d388f 100644
--- a/chrome/browser/push_messaging/push_messaging_app_identifier.cc
+++ b/chrome/browser/push_messaging/push_messaging_app_identifier.cc
@@ -74,12 +74,31 @@ bool PushMessagingAppIdentifier::UseInstanceID(const std::string& app_id) {
PushMessagingAppIdentifier PushMessagingAppIdentifier::Generate(
const GURL& origin,
int64_t service_worker_registration_id) {
+ // All new push subscriptions use Instance ID tokens.
+ return GenerateInternal(origin, service_worker_registration_id,
+ true /* use_instance_id */);
+}
+
+// static
+PushMessagingAppIdentifier PushMessagingAppIdentifier::LegacyGenerateForTesting(
+ const GURL& origin,
+ int64_t service_worker_registration_id) {
+ return GenerateInternal(origin, service_worker_registration_id,
+ false /* use_instance_id */);
+}
+
+// static
+PushMessagingAppIdentifier PushMessagingAppIdentifier::GenerateInternal(
+ const GURL& origin,
+ int64_t service_worker_registration_id,
+ bool use_instance_id) {
// Use uppercase GUID for consistency with GUIDs Push has already sent to GCM.
// Also allows detecting case mangling; see code commented "crbug.com/461867".
std::string guid = base::ToUpperASCII(base::GenerateGUID());
- // All new push subscriptions are Instance ID tokens.
- guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength,
- kInstanceIDGuidSuffix);
+ if (use_instance_id) {
+ guid.replace(guid.size() - kGuidSuffixLength, kGuidSuffixLength,
+ kInstanceIDGuidSuffix);
+ }
CHECK(!guid.empty());
std::string app_id =
kPushMessagingAppIdentifierPrefix + origin.spec() + kSeparator + guid;

Powered by Google App Engine
This is Rietveld 408576698