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

Unified Diff: content/browser/push_messaging/push_messaging_manager.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 side-by-side diff with in-line comments
Download patch
Index: content/browser/push_messaging/push_messaging_manager.cc
diff --git a/content/browser/push_messaging/push_messaging_manager.cc b/content/browser/push_messaging/push_messaging_manager.cc
index 33ee69ca54ca4d6e6cec48bc1cea026197129c09..3b0ee0fb2e9eb51d8ea18c4d9b43a45fe5626c2a 100644
--- a/content/browser/push_messaging/push_messaging_manager.cc
+++ b/content/browser/push_messaging/push_messaging_manager.cc
@@ -111,6 +111,9 @@ struct PushMessagingManager::RegisterData {
SubscribeCallback callback;
// The following member should only be read if FromDocument() is true.
int render_frame_id;
+
+ // True if the call to register was made with a user gesture.
+ bool user_gesture;
};
// Inner core of the PushMessagingManager which lives on the UI thread.
@@ -281,6 +284,7 @@ void PushMessagingManager::BindRequest(
void PushMessagingManager::Subscribe(int32_t render_frame_id,
int64_t service_worker_registration_id,
const PushSubscriptionOptions& options,
+ bool user_gesture,
SubscribeCallback callback) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// TODO(mvanouwerkerk): Validate arguments?
@@ -292,6 +296,7 @@ void PushMessagingManager::Subscribe(int32_t render_frame_id,
data.service_worker_registration_id = service_worker_registration_id;
data.callback = std::move(callback);
data.options = options;
+ data.user_gesture = user_gesture;
ServiceWorkerRegistration* service_worker_registration =
service_worker_context_->GetLiveRegistration(
@@ -504,7 +509,7 @@ void PushMessagingManager::Core::RegisterOnUI(
GURL requesting_origin = data.requesting_origin;
browser_context->GetPermissionManager()->RequestPermission(
PermissionType::PUSH_MESSAGING, render_frame_host,
- requesting_origin, false /* user_gesture */,
+ requesting_origin, data.user_gesture,
base::Bind(
&PushMessagingManager::Core::DidRequestPermissionInIncognito,
weak_factory_ui_to_ui_.GetWeakPtr(), base::Passed(&data)));
@@ -521,7 +526,7 @@ void PushMessagingManager::Core::RegisterOnUI(
if (data.FromDocument()) {
push_service->SubscribeFromDocument(
requesting_origin, registration_id, render_process_id_, render_frame_id,
- options,
+ options, data.user_gesture,
base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
base::Passed(&data)));
} else {
« no previous file with comments | « content/browser/push_messaging/push_messaging_manager.h ('k') | content/child/push_messaging/push_provider.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698