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

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

Issue 2935333003: Propagate the user gesture bit when requesting push messaging permission. (Closed)
Patch Set: ThreadSafe user gesture check Created 3 years, 6 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
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/push_messaging.mojom » ('j') | 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/child/push_messaging/push_provider.h" 5 #include "content/child/push_messaging/push_provider.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 } 115 }
116 116
117 void PushProvider::WillStopCurrentWorkerThread() { 117 void PushProvider::WillStopCurrentWorkerThread() {
118 delete this; 118 delete this;
119 } 119 }
120 120
121 void PushProvider::Subscribe( 121 void PushProvider::Subscribe(
122 blink::WebServiceWorkerRegistration* service_worker_registration, 122 blink::WebServiceWorkerRegistration* service_worker_registration,
123 const blink::WebPushSubscriptionOptions& options, 123 const blink::WebPushSubscriptionOptions& options,
124 bool user_gesture,
124 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks) { 125 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks) {
125 DCHECK(service_worker_registration); 126 DCHECK(service_worker_registration);
126 DCHECK(callbacks); 127 DCHECK(callbacks);
127 128
128 int64_t service_worker_registration_id = 129 int64_t service_worker_registration_id =
129 GetServiceWorkerRegistrationId(service_worker_registration); 130 GetServiceWorkerRegistrationId(service_worker_registration);
130 PushSubscriptionOptions content_options; 131 PushSubscriptionOptions content_options;
131 content_options.user_visible_only = options.user_visible_only; 132 content_options.user_visible_only = options.user_visible_only;
132 133
133 // Just treat the server key as a string of bytes and pass it to the push 134 // Just treat the server key as a string of bytes and pass it to the push
134 // service. 135 // service.
135 content_options.sender_info = options.application_server_key.Latin1(); 136 content_options.sender_info = options.application_server_key.Latin1();
136 137
137 push_messaging_manager_->Subscribe( 138 push_messaging_manager_->Subscribe(
138 ChildProcessHost::kInvalidUniqueID, service_worker_registration_id, 139 ChildProcessHost::kInvalidUniqueID, service_worker_registration_id,
139 content_options, 140 content_options, user_gesture,
140 // Safe to use base::Unretained because |push_messaging_manager_ |is owned 141 // Safe to use base::Unretained because |push_messaging_manager_ |is owned
141 // by |this|. 142 // by |this|.
142 base::Bind(&PushProvider::DidSubscribe, base::Unretained(this), 143 base::Bind(&PushProvider::DidSubscribe, base::Unretained(this),
143 base::Passed(&callbacks))); 144 base::Passed(&callbacks)));
144 } 145 }
145 146
146 void PushProvider::DidSubscribe( 147 void PushProvider::DidSubscribe(
147 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks, 148 std::unique_ptr<blink::WebPushSubscriptionCallbacks> callbacks,
148 content::PushRegistrationStatus status, 149 content::PushRegistrationStatus status,
149 const base::Optional<GURL>& endpoint, 150 const base::Optional<GURL>& endpoint,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 error_message = 276 error_message =
276 "Push subscriptions that don't enable userVisibleOnly are not " 277 "Push subscriptions that don't enable userVisibleOnly are not "
277 "supported."; 278 "supported.";
278 } 279 }
279 callbacks->OnError(blink::WebPushError( 280 callbacks->OnError(blink::WebPushError(
280 error_type, blink::WebString::FromUTF8(error_message))); 281 error_type, blink::WebString::FromUTF8(error_message)));
281 } 282 }
282 } 283 }
283 284
284 } // namespace content 285 } // namespace content
OLDNEW
« no previous file with comments | « content/child/push_messaging/push_provider.h ('k') | content/common/push_messaging.mojom » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698