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

Unified Diff: content/browser/push_messaging/push_messaging_message_filter.cc

Issue 1770763003: Revert of Partial implementation of subscription restrictions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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_message_filter.cc
diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc
index ef75724c1aecc32ee0f7dbcbc9f6f42a13e50fb9..a2eb8959eeef2e006ce40bbf68fc73b0a89f7182 100644
--- a/content/browser/push_messaging/push_messaging_message_filter.cc
+++ b/content/browser/push_messaging/push_messaging_message_filter.cc
@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/bind_helpers.h"
-#include "base/command_line.h"
#include "base/logging.h"
#include "base/macros.h"
#include "base/metrics/histogram.h"
@@ -28,7 +27,6 @@
#include "content/public/browser/web_contents.h"
#include "content/public/common/child_process_host.h"
#include "content/public/common/console_message_level.h"
-#include "content/public/common/content_switches.h"
#include "content/public/common/push_messaging_status.h"
#include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermissionStatus.h"
@@ -252,7 +250,8 @@
void PushMessagingMessageFilter::OnSubscribeFromDocument(
int render_frame_id,
int request_id,
- const PushSubscriptionOptions& options,
+ const std::string& sender_id,
+ bool user_visible,
int64_t service_worker_registration_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
// TODO(mvanouwerkerk): Validate arguments?
@@ -260,7 +259,7 @@
data.request_id = request_id;
data.service_worker_registration_id = service_worker_registration_id;
data.render_frame_id = render_frame_id;
- data.user_visible = options.user_visible_only;
+ data.user_visible = user_visible;
ServiceWorkerRegistration* service_worker_registration =
service_worker_context_->GetLiveRegistration(
@@ -274,20 +273,20 @@
service_worker_context_->StoreRegistrationUserData(
service_worker_registration_id, data.requesting_origin,
- kPushSenderIdServiceWorkerKey, options.sender_info,
- base::Bind(&PushMessagingMessageFilter::DidPersistSenderInfo,
- weak_factory_io_to_io_.GetWeakPtr(), data, options));
+ kPushSenderIdServiceWorkerKey, sender_id,
+ base::Bind(&PushMessagingMessageFilter::DidPersistSenderId,
+ weak_factory_io_to_io_.GetWeakPtr(), data, sender_id));
}
void PushMessagingMessageFilter::OnSubscribeFromWorker(
int request_id,
int64_t service_worker_registration_id,
- const PushSubscriptionOptions& options) {
+ bool user_visible) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
RegisterData data;
data.request_id = request_id;
data.service_worker_registration_id = service_worker_registration_id;
- data.user_visible = options.user_visible_only;
+ data.user_visible = user_visible;
ServiceWorkerRegistration* service_worker_registration =
service_worker_context_->GetLiveRegistration(
@@ -298,35 +297,34 @@
}
data.requesting_origin = service_worker_registration->pattern().GetOrigin();
- // If there is a sender_info in the subscription options, it will be used,
- // otherwise the registration sender_info will be used.
- CheckForExistingRegistration(data, options);
-}
-
-void PushMessagingMessageFilter::DidPersistSenderInfo(
+ // This sender_id will be ignored; instead it will be fetched from storage.
+ CheckForExistingRegistration(data, std::string() /* sender_id */);
+}
+
+void PushMessagingMessageFilter::DidPersistSenderId(
const RegisterData& data,
- const PushSubscriptionOptions& options,
+ const std::string& sender_id,
ServiceWorkerStatusCode service_worker_status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
if (service_worker_status != SERVICE_WORKER_OK)
SendSubscriptionError(data, PUSH_REGISTRATION_STATUS_STORAGE_ERROR);
else
- CheckForExistingRegistration(data, options);
+ CheckForExistingRegistration(data, sender_id);
}
void PushMessagingMessageFilter::CheckForExistingRegistration(
const RegisterData& data,
- const PushSubscriptionOptions& options) {
+ const std::string& sender_id) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
service_worker_context_->GetRegistrationUserData(
data.service_worker_registration_id, kPushRegistrationIdServiceWorkerKey,
base::Bind(&PushMessagingMessageFilter::DidCheckForExistingRegistration,
- weak_factory_io_to_io_.GetWeakPtr(), data, options));
+ weak_factory_io_to_io_.GetWeakPtr(), data, sender_id));
}
void PushMessagingMessageFilter::DidCheckForExistingRegistration(
const RegisterData& data,
- const PushSubscriptionOptions& options,
+ const std::string& sender_id,
const std::string& push_registration_id,
ServiceWorkerStatusCode service_worker_status) {
DCHECK_CURRENTLY_ON(BrowserThread::IO);
@@ -347,11 +345,11 @@
// service_worker_status != SERVICE_WORKER_ERROR_NOT_FOUND instead of
// attempting to do a fresh registration?
// https://w3c.github.io/push-api/#widl-PushRegistrationManager-register-Promise-PushRegistration
- if (!options.sender_info.empty()) {
+ if (data.FromDocument()) {
BrowserThread::PostTask(
BrowserThread::UI, FROM_HERE,
base::Bind(&Core::RegisterOnUI, base::Unretained(ui_core_.get()), data,
- options.sender_info));
+ sender_id));
} else {
service_worker_context_->GetRegistrationUserData(
data.service_worker_registration_id, kPushSenderIdServiceWorkerKey,
@@ -394,7 +392,7 @@
void PushMessagingMessageFilter::Core::RegisterOnUI(
const PushMessagingMessageFilter::RegisterData& data,
- const std::string& sender_info) {
+ const std::string& sender_id) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
PushMessagingService* push_service = service();
if (!push_service) {
@@ -440,18 +438,16 @@
return;
}
- PushSubscriptionOptions options;
- options.user_visible_only = data.user_visible;
- options.sender_info = sender_info;
if (data.FromDocument()) {
push_service->SubscribeFromDocument(
- data.requesting_origin, data.service_worker_registration_id,
- render_process_id_, data.render_frame_id, options,
+ data.requesting_origin, data.service_worker_registration_id, sender_id,
+ render_process_id_, data.render_frame_id, data.user_visible,
base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
data));
} else {
push_service->SubscribeFromWorker(
- data.requesting_origin, data.service_worker_registration_id, options,
+ data.requesting_origin, data.service_worker_registration_id, sender_id,
+ data.user_visible,
base::Bind(&Core::DidRegister, weak_factory_ui_to_ui_.GetWeakPtr(),
data));
}
« no previous file with comments | « content/browser/push_messaging/push_messaging_message_filter.h ('k') | content/child/push_messaging/push_provider.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698