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

Side by Side Diff: content/child/push_messaging/push_provider.cc

Issue 1701313002: Partial implementation of subscription restrictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 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/child/push_messaging/push_provider.h" 5 #include "content/child/push_messaging/push_provider.h"
6 6
7 #include "base/lazy_instance.h" 7 #include "base/lazy_instance.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "base/threading/thread_local.h" 10 #include "base/threading/thread_local.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 void PushProvider::subscribe( 68 void PushProvider::subscribe(
69 blink::WebServiceWorkerRegistration* service_worker_registration, 69 blink::WebServiceWorkerRegistration* service_worker_registration,
70 const blink::WebPushSubscriptionOptions& options, 70 const blink::WebPushSubscriptionOptions& options,
71 blink::WebPushSubscriptionCallbacks* callbacks) { 71 blink::WebPushSubscriptionCallbacks* callbacks) {
72 DCHECK(service_worker_registration); 72 DCHECK(service_worker_registration);
73 DCHECK(callbacks); 73 DCHECK(callbacks);
74 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 74 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
75 subscription_callbacks_.AddWithID(callbacks, request_id); 75 subscription_callbacks_.AddWithID(callbacks, request_id);
76 int64_t service_worker_registration_id = 76 int64_t service_worker_registration_id =
77 GetServiceWorkerRegistrationId(service_worker_registration); 77 GetServiceWorkerRegistrationId(service_worker_registration);
78 ContentPushSubscriptionOptions content_options;
79 content_options.user_visible_only = options.userVisibleOnly;
80 // If subscription restrictions aren't enabled or a key isn't provided
81 // by the client, the sender id will be read from the database.
82 content_options.sender_info = options.applicationServerKey.utf8();
78 thread_safe_sender_->Send(new PushMessagingHostMsg_SubscribeFromWorker( 83 thread_safe_sender_->Send(new PushMessagingHostMsg_SubscribeFromWorker(
79 request_id, service_worker_registration_id, options.userVisibleOnly)); 84 request_id, service_worker_registration_id, content_options));
80 } 85 }
81 86
82 void PushProvider::unsubscribe( 87 void PushProvider::unsubscribe(
83 blink::WebServiceWorkerRegistration* service_worker_registration, 88 blink::WebServiceWorkerRegistration* service_worker_registration,
84 blink::WebPushUnsubscribeCallbacks* callbacks) { 89 blink::WebPushUnsubscribeCallbacks* callbacks) {
85 DCHECK(service_worker_registration); 90 DCHECK(service_worker_registration);
86 DCHECK(callbacks); 91 DCHECK(callbacks);
87 92
88 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId()); 93 int request_id = push_dispatcher_->GenerateRequestId(CurrentWorkerId());
89 unsubscribe_callbacks_.AddWithID(callbacks, request_id); 94 unsubscribe_callbacks_.AddWithID(callbacks, request_id);
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
262 "supported."; 267 "supported.";
263 } 268 }
264 269
265 callbacks->onError( 270 callbacks->onError(
266 blink::WebPushError(error, blink::WebString::fromUTF8(error_message))); 271 blink::WebPushError(error, blink::WebString::fromUTF8(error_message)));
267 272
268 permission_status_callbacks_.Remove(request_id); 273 permission_status_callbacks_.Remove(request_id);
269 } 274 }
270 275
271 } // namespace content 276 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698