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

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

Issue 1816123002: Add testing for subscription from service workers (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix asan errors Created 4 years, 8 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/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "content/child/service_worker/web_service_worker_registration_impl.h" 8 #include "content/child/service_worker/web_service_worker_registration_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 // fetching the manifest. 48 // fetching the manifest.
49 if (options.applicationServerKey.isEmpty()) { 49 if (options.applicationServerKey.isEmpty()) {
50 RenderFrameImpl::FromRoutingID(routing_id()) 50 RenderFrameImpl::FromRoutingID(routing_id())
51 ->manifest_manager() 51 ->manifest_manager()
52 ->GetManifest(base::Bind( 52 ->GetManifest(base::Bind(
53 &PushMessagingDispatcher::DidGetManifest, base::Unretained(this), 53 &PushMessagingDispatcher::DidGetManifest, base::Unretained(this),
54 service_worker_registration, options, callbacks)); 54 service_worker_registration, options, callbacks));
55 } else { 55 } else {
56 PushSubscriptionOptions content_options; 56 PushSubscriptionOptions content_options;
57 content_options.user_visible_only = options.userVisibleOnly; 57 content_options.user_visible_only = options.userVisibleOnly;
58 content_options.sender_info = options.applicationServerKey.utf8(); 58 // Just treat the server key as a string of bytes and pass it to the push
59 // service.
60 content_options.sender_info = options.applicationServerKey.latin1();
59 DoSubscribe(service_worker_registration, content_options, callbacks); 61 DoSubscribe(service_worker_registration, content_options, callbacks);
60 } 62 }
61 } 63 }
62 64
63 void PushMessagingDispatcher::DidGetManifest( 65 void PushMessagingDispatcher::DidGetManifest(
64 blink::WebServiceWorkerRegistration* service_worker_registration, 66 blink::WebServiceWorkerRegistration* service_worker_registration,
65 const blink::WebPushSubscriptionOptions& options, 67 const blink::WebPushSubscriptionOptions& options,
66 blink::WebPushSubscriptionCallbacks* callbacks, 68 blink::WebPushSubscriptionCallbacks* callbacks,
67 const Manifest& manifest) { 69 const Manifest& manifest) {
68 // Get the sender_info from the manifest since it wasn't provided by 70 // Get the sender_info from the manifest since it wasn't provided by
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 : blink::WebPushError::ErrorTypeAbort; 133 : blink::WebPushError::ErrorTypeAbort;
132 134
133 callbacks->onError(blink::WebPushError( 135 callbacks->onError(blink::WebPushError(
134 error_type, 136 error_type,
135 blink::WebString::fromUTF8(PushRegistrationStatusToString(status)))); 137 blink::WebString::fromUTF8(PushRegistrationStatusToString(status))));
136 138
137 subscription_callbacks_.Remove(request_id); 139 subscription_callbacks_.Remove(request_id);
138 } 140 }
139 141
140 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « content/child/push_messaging/push_provider.cc ('k') | third_party/WebKit/Source/modules/push_messaging/PushManager.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698