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

Unified Diff: content/browser/push_messaging/push_messaging_message_filter.cc

Issue 2436393002: Disallow repeated PushManager.subscribes with different sender ids (Closed)
Patch Set: Rename registration_id -> push_registration_id Created 4 years, 2 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: content/browser/push_messaging/push_messaging_message_filter.cc
diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc
index fd768eb7ff6aca39eade34157eab148b28d50fd8..008d9aa724fb1c759dac3feb12d5feabfc6b9b78 100644
--- a/content/browser/push_messaging/push_messaging_message_filter.cc
+++ b/content/browser/push_messaging/push_messaging_message_filter.cc
@@ -284,23 +284,27 @@ void PushMessagingMessageFilter::OnSubscribe(
service_worker_context_->GetRegistrationUserData(
data.service_worker_registration_id,
- {kPushRegistrationIdServiceWorkerKey},
+ {kPushRegistrationIdServiceWorkerKey, kPushSenderIdServiceWorkerKey},
base::Bind(&PushMessagingMessageFilter::DidCheckForExistingRegistration,
weak_factory_io_to_io_.GetWeakPtr(), data));
}
void PushMessagingMessageFilter::DidCheckForExistingRegistration(
const RegisterData& data,
- const std::vector<std::string>& push_registration_id,
+ const std::vector<std::string>& push_registration_id_and_sender_id,
ServiceWorkerStatusCode service_worker_status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (service_worker_status == SERVICE_WORKER_OK) {
- // TODO(johnme): Check that stored sender ID equals data.options.sender_info
- // and throw an exception if they don't match.
- DCHECK_EQ(1u, push_registration_id.size());
+ DCHECK_EQ(2u, push_registration_id_and_sender_id.size());
+ auto& push_registration_id = push_registration_id_and_sender_id[0];
+ auto& sender_id = push_registration_id_and_sender_id[1];
harkness 2016/10/25 10:11:22 These can be const.
awdf 2016/10/25 13:18:18 Done.
+ if (data.options.sender_info != sender_id) {
johnme 2016/10/25 12:33:31 data.options.sender_info might be empty here, and
awdf 2016/10/25 13:18:18 If data.options.sender_info is empty here though,
johnme 2016/10/25 13:28:25 PushMessagingBrowserTest.SubscribeWorker and PushM
awdf 2016/10/25 13:50:36 Oh, sorry, got confused, I now understand you're s
harkness 2016/10/25 14:25:20 There is already a browser test for that, but it's
+ SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_SENDER_ID_MISMATCH);
+ return;
+ }
auto callback = base::Bind(
&PushMessagingMessageFilter::DidGetEncryptionKeys,
- weak_factory_io_to_io_.GetWeakPtr(), data, push_registration_id[0]);
+ weak_factory_io_to_io_.GetWeakPtr(), data, push_registration_id);
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,

Powered by Google App Engine
This is Rietveld 408576698