diff options
author | harkness <harkness@chromium.org> | 2016-03-21 04:58:17 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-21 11:59:32 +0000 |
commit | 35c378e23dccd1bf2ad7da30bc93ffbb152859ea (patch) | |
tree | 08acce4f3b9f8529e1d6ed263ed7f6aa97011698 /content/public | |
parent | 3bdd60d1af1e6f30b1323e6e3ab3946b170f7444 (diff) | |
download | chromium_src-35c378e23dccd1bf2ad7da30bc93ffbb152859ea.zip chromium_src-35c378e23dccd1bf2ad7da30bc93ffbb152859ea.tar.gz chromium_src-35c378e23dccd1bf2ad7da30bc93ffbb152859ea.tar.bz2 |
Implementation of subscription restrictions.
Currently, chrome requires that app developers provide a "sender_id" tag in the
manifest. This id is generated by the developer console and is not standard
for all browsers.
In the future, the app developer will be able to specify a public key for their
service, which will be registered with the push service and which the push
service can use to validate app services requesting to send messages.
This is a reland of CL https://codereview.chromium.org/1701313002. The only diff is content/renderer/push_messaging/push_messaging_dispatcher.cc where the request_id is set inside the return.
BUG=583753
TBR=avi,mkwst
Cr-Commit-Position: refs/heads/master@{#379045}
Review URL: https://codereview.chromium.org/1801113003
Cr-Commit-Position: refs/heads/master@{#382268}
Diffstat (limited to 'content/public')
-rw-r--r-- | content/public/browser/push_messaging_service.h | 19 | ||||
-rw-r--r-- | content/public/common/push_subscription_options.h | 32 |
2 files changed, 41 insertions, 10 deletions
diff --git a/content/public/browser/push_messaging_service.h b/content/public/browser/push_messaging_service.h index 86aa34e..993e281 100644 --- a/content/public/browser/push_messaging_service.h +++ b/content/public/browser/push_messaging_service.h @@ -19,6 +19,7 @@ namespace content { class BrowserContext; class ServiceWorkerContext; +struct PushSubscriptionOptions; // A push service-agnostic interface that the Push API uses for talking to // push messaging services like GCM. Must only be used on the UI thread. @@ -49,24 +50,22 @@ class CONTENT_EXPORT PushMessagingService { // origins and push registrations. virtual GURL GetPushEndpoint() = 0; - // Subscribe the given |sender_id| with the push messaging service in a - // document context. The frame is known and a permission UI may be displayed - // to the user. + // Subscribe the given |options.sender_info| with the push messaging service + // in a document context. The frame is known and a permission UI may be + // displayed to the user. virtual void SubscribeFromDocument(const GURL& requesting_origin, int64_t service_worker_registration_id, - const std::string& sender_id, int renderer_id, int render_frame_id, - bool user_visible, + const PushSubscriptionOptions& options, const RegisterCallback& callback) = 0; - // Subscribe the given |sender_id| with the push messaging service. The frame - // is not known so if permission was not previously granted by the user this - // request should fail. + // Subscribe the given |options.sender_info| with the push messaging service. + // The frame is not known so if permission was not previously granted by the + // user this request should fail. virtual void SubscribeFromWorker(const GURL& requesting_origin, int64_t service_worker_registration_id, - const std::string& sender_id, - bool user_visible, + const PushSubscriptionOptions& options, const RegisterCallback& callback) = 0; // Retrieves the encryption information associated with the subscription diff --git a/content/public/common/push_subscription_options.h b/content/public/common/push_subscription_options.h new file mode 100644 index 0000000..1a2da0a --- /dev/null +++ b/content/public/common/push_subscription_options.h @@ -0,0 +1,32 @@ +// Copyright 2016 The Chromium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +#ifndef CONTENT_PUBLIC_COMMON_PUSH_SUBSCRIPTION_OPTIONS_H_ +#define CONTENT_PUBLIC_COMMON_PUSH_SUBSCRIPTION_OPTIONS_H_ + +#include <string> + +#include "content/common/content_export.h" + +namespace content { + +// Structure to hold the options provided from the web app developer as +// part of asking for a new push subscription. +struct CONTENT_EXPORT PushSubscriptionOptions { + PushSubscriptionOptions() {} + ~PushSubscriptionOptions() {} + + // Whether or not the app developer agrees to provide user visible + // notifications whenever they receive a push message. + bool user_visible_only = false; + + // The unique identifier of the application service which is used to + // verify the push message before delivery. This could either be an ID + // assigned by the developer console or the app server's public key. + std::string sender_info; +}; + +} // namespace content + +#endif // CONTENT_PUBLIC_COMMON_CONTENT_PUSH_SUBSCRIPTION_OPTIONS_H_ |