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

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

Issue 2133673002: Push API: Implement and ship PushSubscription.options (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 5 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 unified diff | Download patch
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/push_messaging_dispatcher.h" 5 #include "content/renderer/push_messaging/push_messaging_dispatcher.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "content/child/service_worker/web_service_worker_registration_impl.h" 9 #include "content/child/service_worker/web_service_worker_registration_impl.h"
10 #include "content/common/push_messaging_messages.h" 10 #include "content/common/push_messaging_messages.h"
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 PUSH_REGISTRATION_STATUS_NO_SENDER_ID); 107 PUSH_REGISTRATION_STATUS_NO_SENDER_ID);
108 return; 108 return;
109 } 109 }
110 Send(new PushMessagingHostMsg_Subscribe( 110 Send(new PushMessagingHostMsg_Subscribe(
111 routing_id(), request_id, service_worker_registration_id, options)); 111 routing_id(), request_id, service_worker_registration_id, options));
112 } 112 }
113 113
114 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( 114 void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess(
115 int32_t request_id, 115 int32_t request_id,
116 const GURL& endpoint, 116 const GURL& endpoint,
117 const PushSubscriptionOptions& options,
117 const std::vector<uint8_t>& p256dh, 118 const std::vector<uint8_t>& p256dh,
118 const std::vector<uint8_t>& auth) { 119 const std::vector<uint8_t>& auth) {
119 blink::WebPushSubscriptionCallbacks* callbacks = 120 blink::WebPushSubscriptionCallbacks* callbacks =
120 subscription_callbacks_.Lookup(request_id); 121 subscription_callbacks_.Lookup(request_id);
121 DCHECK(callbacks); 122 DCHECK(callbacks);
122 123
123 callbacks->onSuccess( 124 callbacks->onSuccess(base::WrapUnique(new blink::WebPushSubscription(
124 base::WrapUnique(new blink::WebPushSubscription(endpoint, p256dh, auth))); 125 endpoint, options.user_visible_only,
126 blink::WebString::fromLatin1(options.sender_info), p256dh, auth)));
125 127
126 subscription_callbacks_.Remove(request_id); 128 subscription_callbacks_.Remove(request_id);
127 } 129 }
128 130
129 void PushMessagingDispatcher::OnSubscribeFromDocumentError( 131 void PushMessagingDispatcher::OnSubscribeFromDocumentError(
130 int32_t request_id, 132 int32_t request_id,
131 PushRegistrationStatus status) { 133 PushRegistrationStatus status) {
132 blink::WebPushSubscriptionCallbacks* callbacks = 134 blink::WebPushSubscriptionCallbacks* callbacks =
133 subscription_callbacks_.Lookup(request_id); 135 subscription_callbacks_.Lookup(request_id);
134 DCHECK(callbacks); 136 DCHECK(callbacks);
135 137
136 blink::WebPushError::ErrorType error_type = 138 blink::WebPushError::ErrorType error_type =
137 status == PUSH_REGISTRATION_STATUS_PERMISSION_DENIED 139 status == PUSH_REGISTRATION_STATUS_PERMISSION_DENIED
138 ? blink::WebPushError::ErrorTypePermissionDenied 140 ? blink::WebPushError::ErrorTypePermissionDenied
139 : blink::WebPushError::ErrorTypeAbort; 141 : blink::WebPushError::ErrorTypeAbort;
140 142
141 callbacks->onError(blink::WebPushError( 143 callbacks->onError(blink::WebPushError(
142 error_type, 144 error_type,
143 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); 145 blink::WebString::fromUTF8(PushRegistrationStatusToString(status))));
144 146
145 subscription_callbacks_.Remove(request_id); 147 subscription_callbacks_.Remove(request_id);
146 } 148 }
147 149
148 } // namespace content 150 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698