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

Side by Side Diff: content/renderer/push_messaging_dispatcher.cc

Issue 686133003: Reject push registrations when no sender Id has been provided. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments Created 6 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « content/public/common/push_messaging_status.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/push_messaging_dispatcher.h" 5 #include "content/renderer/push_messaging_dispatcher.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/child/service_worker/web_service_worker_provider_impl.h" 8 #include "content/child/service_worker/web_service_worker_provider_impl.h"
9 #include "content/common/push_messaging_messages.h" 9 #include "content/common/push_messaging_messages.h"
10 #include "content/renderer/manifest/manifest_manager.h" 10 #include "content/renderer/manifest/manifest_manager.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 } 48 }
49 49
50 void PushMessagingDispatcher::DoRegister( 50 void PushMessagingDispatcher::DoRegister(
51 blink::WebPushRegistrationCallbacks* callbacks, 51 blink::WebPushRegistrationCallbacks* callbacks,
52 blink::WebServiceWorkerProvider* service_worker_provider, 52 blink::WebServiceWorkerProvider* service_worker_provider,
53 const Manifest& manifest) { 53 const Manifest& manifest) {
54 DCHECK(callbacks); 54 DCHECK(callbacks);
55 int callbacks_id = registration_callbacks_.Add(callbacks); 55 int callbacks_id = registration_callbacks_.Add(callbacks);
56 int service_worker_provider_id = static_cast<WebServiceWorkerProviderImpl*>( 56 int service_worker_provider_id = static_cast<WebServiceWorkerProviderImpl*>(
57 service_worker_provider)->provider_id(); 57 service_worker_provider)->provider_id();
58
59 std::string sender_id = manifest.gcm_sender_id.is_null()
60 ? std::string() : base::UTF16ToUTF8(manifest.gcm_sender_id.string());
61 if (sender_id.empty()) {
62 OnRegisterError(callbacks_id, PUSH_REGISTRATION_STATUS_NO_SENDER_ID);
63 return;
64 }
65
58 Send(new PushMessagingHostMsg_Register( 66 Send(new PushMessagingHostMsg_Register(
59 routing_id(), 67 routing_id(),
60 callbacks_id, 68 callbacks_id,
61 manifest.gcm_sender_id.is_null() 69 sender_id,
62 ? std::string()
63 : base::UTF16ToUTF8(manifest.gcm_sender_id.string()),
64 blink::WebUserGestureIndicator::isProcessingUserGesture(), 70 blink::WebUserGestureIndicator::isProcessingUserGesture(),
65 service_worker_provider_id)); 71 service_worker_provider_id));
66 } 72 }
67 73
68 void PushMessagingDispatcher::OnRegisterSuccess( 74 void PushMessagingDispatcher::OnRegisterSuccess(
69 int32 callbacks_id, 75 int32 callbacks_id,
70 const GURL& endpoint, 76 const GURL& endpoint,
71 const std::string& registration_id) { 77 const std::string& registration_id) {
72 blink::WebPushRegistrationCallbacks* callbacks = 78 blink::WebPushRegistrationCallbacks* callbacks =
73 registration_callbacks_.Lookup(callbacks_id); 79 registration_callbacks_.Lookup(callbacks_id);
(...skipping 14 matching lines...) Expand all
88 CHECK(callbacks); 94 CHECK(callbacks);
89 95
90 scoped_ptr<blink::WebPushError> error(new blink::WebPushError( 96 scoped_ptr<blink::WebPushError> error(new blink::WebPushError(
91 blink::WebPushError::ErrorTypeAbort, 97 blink::WebPushError::ErrorTypeAbort,
92 WebString::fromUTF8(PushRegistrationStatusToString(status)))); 98 WebString::fromUTF8(PushRegistrationStatusToString(status))));
93 callbacks->onError(error.release()); 99 callbacks->onError(error.release());
94 registration_callbacks_.Remove(callbacks_id); 100 registration_callbacks_.Remove(callbacks_id);
95 } 101 }
96 102
97 } // namespace content 103 } // namespace content
OLDNEW
« no previous file with comments | « content/public/common/push_messaging_status.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698