diff options
author | benwells <benwells@chromium.org> | 2016-03-07 21:06:39 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-03-08 05:08:05 +0000 |
commit | cd6d01e60cd874019473ae1c37eb5227b5ed6daf (patch) | |
tree | 86363f1704a5db9ec8695d51a3a9893b68539215 | |
parent | 04b30b54513ba4be7ab776b9b8ea008fe4c61cf7 (diff) | |
download | chromium_src-cd6d01e60cd874019473ae1c37eb5227b5ed6daf.zip chromium_src-cd6d01e60cd874019473ae1c37eb5227b5ed6daf.tar.gz chromium_src-cd6d01e60cd874019473ae1c37eb5227b5ed6daf.tar.bz2 |
Revert of Partial implementation of subscription restrictions. (patchset #8 id:140001 of https://codereview.chromium.org/1701313002/ )
Reason for revert:
Sorry about the delay in reverting ...
This is causing many memory errors on DrMemory.
I think there is an error in the patch, in push_messaging_dispatcher.cc. The same WebPush...Callbacks* can be added twice to |subscription_callbacks_|, in the new DidGetManifest and in the already existing DoSubscribe.
As |subscription_callbacks_| is declared with IDMapOwnPointer, this will cause callbacks to be freed twice.
First build where it failed with example errors:
https://build.chromium.org/p/chromium.memory.fyi/builders/Windows%20Browser%20%28DrMemory%20full%29%20%281%29/builds/2799
Sample output:
UNADDRESSABLE ACCESS beyond heap bounds: writing 0x09880330-0x09880334 4 byte(s)
# 0 modules.dll!blink::WebCallbacks<>::`scalar deleting destructor'
# 1 content.dll!IDMap<>::Releaser<>::release_all [base\id_map.h:250]
# 2 content.dll!content::PushMessagingDispatcher::~PushMessagingDispatcher [content\renderer\push_messaging\push_messaging_dispatcher.cc:27]
# 3 content.dll!content::PushMessagingDispatcher::`scalar deleting destructor'
# 4 content.dll!content::RenderFrameObserver::OnDestruct [content\public\renderer\render_frame_observer.cc:33]
# 5 content.dll!content::RenderFrameImpl::`vector deleting destructor'
# 6 content.dll!content::RenderFrameImpl::frameDetached [content\renderer\render_frame_impl.cc:2740]
# 7 blink_web.dll!blink::FrameLoaderClientImpl::detached [third_party\webkit\source\web\frameloaderclientimpl.cpp:383]
# 8 webcore_shared.dll!blink::Frame::detach [third_party\webkit\source\core\frame\frame.cpp:98]
# 9 webcore_shared.dll!blink::LocalFrame::detach [third_party\webkit\source\core\frame\localframe.cpp:357]
#10 webcore_shared.dll!blink::Page::willBeDestroyed [third_party\webkit\source\core\page\page.cpp:573]
#11 base.dll!base::debug::TaskAnnotator::RunTask [base\debug\task_annotator.cc:51]
#12 scheduler.dll!scheduler::TaskQueueManager::ProcessTaskFromWorkQueue [components\scheduler\base\task_queue_manager.cc:288]
#13 scheduler.dll!scheduler::TaskQueueManager::DoWork [components\scheduler\base\task_queue_manager.cc:200]
#14 scheduler.dll!base::internal::Invoker<>::Run [base\bind_internal.h:354]
#15 base.dll!base::debug::TaskAnnotator::RunTask [base\debug\task_annotator.cc:51]
#16 base.dll!base::MessageLoop::RunTask [base\message_loop\message_loop.cc:476]
#17 base.dll!base::MessageLoop::DeferOrRunPendingTask [base\message_loop\message_loop.cc:485]
#18 base.dll!base::MessageLoop::DoWork [base\message_loop\message_loop.cc:597]
#19 base.dll!base::MessagePumpDefault::Run [base\message_loop\message_pump_default.cc:33]
#20 base.dll!base::MessageLoop::RunHandler [base\message_loop\message_loop.cc:440]
#21 base.dll!base::RunLoop::Run [base\run_loop.cc:35]
#22 base.dll!base::MessageLoop::Run [base\message_loop\message_loop.cc:293]
#23 content.dll!content::RendererMain [content\renderer\renderer_main.cc:219]
#24 content.dll!content::RunNamedProcessTypeMain [content\app\content_main_runner.cc:395]
#25 content.dll!content::ContentMainRunnerImpl::Run [content\app\content_main_runner.cc:766]
#26 content.dll!content::ContentMain [content\app\content_main.cc:19]
#27 content::LaunchTests [content\public\test\test_launcher.cc:505]
#28 LaunchChromeTests [chrome\test\base\chrome_test_launcher.cc:128]
#29 main [chrome\test\base\browser_tests_main.cc:21]
Note: @0:03:41.960 in thread 1944
Note: next higher malloc: 0x098804a0-0x098804c0
Note: prev lower malloc: 0x09880248-0x09880310
Note: instruction: mov $0x679f7ef4 -> (%esi)
The report came from the `PushMessagingBrowserTest.GrantAlreadyGrantedPermissionDoesNotUnsubscribe` test.
Original issue's description:
> Partial 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.
>
> BUG=583753
>
> Committed: https://crrev.com/71f5a08bb30153b56e8a3f9b447264a54b6d9c12
> Cr-Commit-Position: refs/heads/master@{#379045}
TBR=mkwst@chromium.org,avi@chromium.org,mvanouwerkerk@chromium.org,peter@chromium.org,harkness@chromium.org
# Not skipping CQ checks because original CL landed more than 1 days ago.
BUG=583753
Review URL: https://codereview.chromium.org/1770763003
Cr-Commit-Position: refs/heads/master@{#379750}
23 files changed, 113 insertions, 378 deletions
diff --git a/chrome/browser/push_messaging/push_messaging_browsertest.cc b/chrome/browser/push_messaging/push_messaging_browsertest.cc index bcad2bc..03fb929 100644 --- a/chrome/browser/push_messaging/push_messaging_browsertest.cc +++ b/chrome/browser/push_messaging/push_messaging_browsertest.cc @@ -44,7 +44,6 @@ #include "components/gcm_driver/common/gcm_messages.h" #include "components/gcm_driver/gcm_client.h" #include "content/public/browser/web_contents.h" -#include "content/public/common/content_switches.h" #include "content/public/test/browser_test_utils.h" #include "content/public/test/test_utils.h" #include "net/test/embedded_test_server/embedded_test_server.h" @@ -100,13 +99,6 @@ class PushMessagingBrowserTest : public InProcessBrowserTest { InProcessBrowserTest::SetUp(); } - void SetUpCommandLine(base::CommandLine* command_line) override { - // Enable experiemntal features for subscription restrictions. - command_line->AppendSwitch( - switches::kEnableExperimentalWebPlatformFeatures); - InProcessBrowserTest::SetUpCommandLine(command_line); - } - // InProcessBrowserTest: void SetUpOnMainThread() override { gcm_service_ = static_cast<gcm::FakeGCMProfileService*>( @@ -172,8 +164,7 @@ class PushMessagingBrowserTest : public InProcessBrowserTest { void RequestAndDenyPermission(); void TryToSubscribeSuccessfully( - const std::string& expected_push_subscription_info, - bool use_key = true); + const std::string& expected_push_subscription_id); std::string GetEndpointForSubscriptionId(const std::string& subscription_id) { return std::string(kPushMessagingEndpoint) + "/" + subscription_id; @@ -255,8 +246,7 @@ void PushMessagingBrowserTest::RequestAndDenyPermission() { } void PushMessagingBrowserTest::TryToSubscribeSuccessfully( - const std::string& expected_push_subscription_info, - bool use_key) { + const std::string& expected_push_subscription_id) { std::string script_result; EXPECT_TRUE(RunScript("registerServiceWorker()", &script_result)); @@ -264,14 +254,8 @@ void PushMessagingBrowserTest::TryToSubscribeSuccessfully( RequestAndAcceptPermission(); - if (use_key) { - EXPECT_TRUE(RunScript("subscribePush()", &script_result)); - } else { - // Test backwards compatibility with old ID based subscriptions. - EXPECT_TRUE(RunScript("subscribePushWithoutKey()", &script_result)); - } - - EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_info), + EXPECT_TRUE(RunScript("subscribePush()", &script_result)); + EXPECT_EQ(GetEndpointForSubscriptionId(expected_push_subscription_id), script_result); } @@ -296,16 +280,6 @@ void PushMessagingBrowserTest::SendMessageAndWaitUntilHandled( } IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, - SubscribeWithoutKeySuccessNotificationsGranted) { - TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */, false); - - PushMessagingAppIdentifier app_identifier = - GetAppIdentifierForServiceWorkerRegistration(0LL); - EXPECT_EQ(app_identifier.app_id(), gcm_service()->last_registered_app_id()); - EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); -} - -IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeSuccessNotificationsGranted) { TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); @@ -333,21 +307,6 @@ IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, EXPECT_EQ("1234567890", gcm_service()->last_registered_sender_ids()[0]); } -IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureBadKey) { - std::string script_result; - - ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); - ASSERT_EQ("ok - service worker registered", script_result); - - RequestAndAcceptPermission(); - - ASSERT_TRUE(RunScript("subscribePushBadKey()", &script_result)); - EXPECT_EQ( - "InvalidAccessError - Failed to execute 'subscribe' on 'PushManager': " - "The provided applicationServerKey is not valid.", - script_result); -} - IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, SubscribeFailureNotificationsBlocked) { std::string script_result; diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.cc b/chrome/browser/push_messaging/push_messaging_service_impl.cc index 4895907..b5f409e 100644 --- a/chrome/browser/push_messaging/push_messaging_service_impl.cc +++ b/chrome/browser/push_messaging/push_messaging_service_impl.cc @@ -44,7 +44,6 @@ #include "content/public/common/child_process_host.h" #include "content/public/common/content_switches.h" #include "content/public/common/push_messaging_status.h" -#include "content/public/common/push_subscription_options.h" #include "ui/base/l10n/l10n_util.h" #if BUILDFLAG(ENABLE_BACKGROUND) @@ -345,9 +344,10 @@ GURL PushMessagingServiceImpl::GetPushEndpoint() { void PushMessagingServiceImpl::SubscribeFromDocument( const GURL& requesting_origin, int64_t service_worker_registration_id, + const std::string& sender_id, int renderer_id, int render_frame_id, - const content::PushSubscriptionOptions& options, + bool user_visible, const content::PushMessagingService::RegisterCallback& callback) { PushMessagingAppIdentifier app_identifier = PushMessagingAppIdentifier::Generate(requesting_origin, @@ -367,7 +367,7 @@ void PushMessagingServiceImpl::SubscribeFromDocument( if (!web_contents) return; - if (!options.user_visible_only) { + if (!user_visible) { web_contents->GetMainFrame()->AddMessageToConsole( content::CONSOLE_MESSAGE_LEVEL_ERROR, kSilentPushUnsupportedMessage); @@ -381,14 +381,15 @@ void PushMessagingServiceImpl::SubscribeFromDocument( content::PermissionType::PUSH_MESSAGING, web_contents->GetMainFrame(), requesting_origin, base::Bind(&PushMessagingServiceImpl::DidRequestPermission, - weak_factory_.GetWeakPtr(), app_identifier, options, + weak_factory_.GetWeakPtr(), app_identifier, sender_id, callback)); } void PushMessagingServiceImpl::SubscribeFromWorker( const GURL& requesting_origin, int64_t service_worker_registration_id, - const content::PushSubscriptionOptions& options, + const std::string& sender_id, + bool user_visible, const content::PushMessagingService::RegisterCallback& register_callback) { PushMessagingAppIdentifier app_identifier = PushMessagingAppIdentifier::Generate(requesting_origin, @@ -403,7 +404,7 @@ void PushMessagingServiceImpl::SubscribeFromWorker( blink::WebPushPermissionStatus permission_status = PushMessagingServiceImpl::GetPermissionStatus(requesting_origin, - options.user_visible_only); + user_visible); if (permission_status != blink::WebPushPermissionStatusGranted) { SubscribeEndWithError(register_callback, @@ -412,7 +413,7 @@ void PushMessagingServiceImpl::SubscribeFromWorker( } IncreasePushSubscriptionCount(1, true /* is_pending */); - std::vector<std::string> sender_ids(1, options.sender_info); + std::vector<std::string> sender_ids(1, sender_id); GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, base::Bind(&PushMessagingServiceImpl::DidSubscribe, weak_factory_.GetWeakPtr(), @@ -515,7 +516,7 @@ void PushMessagingServiceImpl::DidSubscribeWithEncryptionInfo( void PushMessagingServiceImpl::DidRequestPermission( const PushMessagingAppIdentifier& app_identifier, - const content::PushSubscriptionOptions& options, + const std::string& sender_id, const content::PushMessagingService::RegisterCallback& register_callback, content::PermissionStatus permission_status) { if (permission_status != content::PermissionStatus::GRANTED) { @@ -525,7 +526,7 @@ void PushMessagingServiceImpl::DidRequestPermission( } IncreasePushSubscriptionCount(1, true /* is_pending */); - std::vector<std::string> sender_ids(1, options.sender_info); + std::vector<std::string> sender_ids(1, sender_id); GetGCMDriver()->Register(app_identifier.app_id(), sender_ids, base::Bind(&PushMessagingServiceImpl::DidSubscribe, weak_factory_.GetWeakPtr(), diff --git a/chrome/browser/push_messaging/push_messaging_service_impl.h b/chrome/browser/push_messaging/push_messaging_service_impl.h index a0b145a..3b95d2d 100644 --- a/chrome/browser/push_messaging/push_messaging_service_impl.h +++ b/chrome/browser/push_messaging/push_messaging_service_impl.h @@ -35,7 +35,6 @@ class Profile; class PushMessagingAppIdentifier; class PushMessagingServiceObserver; -struct PushSubscriptionOptions; namespace gcm { class GCMDriver; @@ -75,14 +74,16 @@ class PushMessagingServiceImpl : public content::PushMessagingService, void SubscribeFromDocument( const GURL& requesting_origin, int64_t service_worker_registration_id, + const std::string& sender_id, int renderer_id, int render_frame_id, - const content::PushSubscriptionOptions& options, + bool user_visible, const content::PushMessagingService::RegisterCallback& callback) override; void SubscribeFromWorker( const GURL& requesting_origin, int64_t service_worker_registration_id, - const content::PushSubscriptionOptions& options, + const std::string& sender_id, + bool user_visible, const content::PushMessagingService::RegisterCallback& callback) override; void GetEncryptionInfo( const GURL& origin, @@ -164,7 +165,7 @@ class PushMessagingServiceImpl : public content::PushMessagingService, void DidRequestPermission( const PushMessagingAppIdentifier& app_identifier, - const content::PushSubscriptionOptions& options, + const std::string& sender_id, const content::PushMessagingService::RegisterCallback& callback, content::PermissionStatus permission_status); diff --git a/chrome/browser/push_messaging/push_messaging_service_unittest.cc b/chrome/browser/push_messaging/push_messaging_service_unittest.cc index 19167e4..a68e0d1 100644 --- a/chrome/browser/push_messaging/push_messaging_service_unittest.cc +++ b/chrome/browser/push_messaging/push_messaging_service_unittest.cc @@ -27,7 +27,6 @@ #include "components/gcm_driver/fake_gcm_client_factory.h" #include "components/gcm_driver/gcm_profile_service.h" #include "content/public/common/push_event_payload.h" -#include "content/public/common/push_subscription_options.h" #include "content/public/test/test_browser_thread_bundle.h" #include "testing/gtest/include/gtest/gtest.h" @@ -154,11 +153,8 @@ TEST_F(PushMessagingServiceTest, PayloadEncryptionTest) { // (2) Subscribe for Push Messaging, and verify that we've got the required // information in order to be able to create encrypted messages. - content::PushSubscriptionOptions options; - options.user_visible_only = true; - options.sender_info = kTestSenderId; push_service->SubscribeFromWorker( - origin, kTestServiceWorkerId, options, + origin, kTestServiceWorkerId, kTestSenderId, true /* user_visible */, base::Bind(&PushMessagingServiceTest::DidRegister, base::Unretained(this), &subscription_id, &p256dh, &auth)); diff --git a/chrome/test/data/push_messaging/push_test.js b/chrome/test/data/push_messaging/push_test.js index 73a307e..c1fe6aa 100644 --- a/chrome/test/data/push_messaging/push_test.js +++ b/chrome/test/data/push_messaging/push_test.js @@ -7,16 +7,6 @@ var resultQueue = new ResultQueue(); var pushSubscription = null; -// NIST P-256 public key made available to tests. Must be an uncompressed -// point in accordance with SEC1 2.3.3. -var applicationServerKey = new Uint8Array([ - 0x04, 0x55, 0x52, 0x6A, 0xA5, 0x6E, 0x8E, 0xAA, 0x47, 0x97, 0x36, 0x10, 0xC1, - 0x66, 0x3C, 0x1E, 0x65, 0xBF, 0xA1, 0x7B, 0xEE, 0x48, 0xC9, 0xC6, 0xBB, 0xBF, - 0x02, 0x18, 0x53, 0x72, 0x1D, 0x0C, 0x7B, 0xA9, 0xE3, 0x11, 0xB7, 0x03, 0x52, - 0x21, 0xD3, 0x71, 0x90, 0x13, 0xA8, 0xC1, 0xCF, 0xED, 0x20, 0xF7, 0x1F, 0xD1, - 0x7F, 0xF2, 0x76, 0xB6, 0x01, 0x20, 0xD8, 0x35, 0xA5, 0xD9, 0x3C, 0x43, 0xFD -]); - var pushSubscriptionOptions = { userVisibleOnly: true }; @@ -116,36 +106,8 @@ function swapManifestNoSenderId() { } } -// This is the old style of push subscriptions which we are phasing away -// from, where the subscription used a sender ID instead of public key. -function subscribePushWithoutKey() { - navigator.serviceWorker.ready.then(function(swRegistration) { - return swRegistration.pushManager.subscribe( - pushSubscriptionOptions) - .then(function(subscription) { - pushSubscription = subscription; - sendResultToTest(subscription.endpoint); - }); - }).catch(sendErrorToTest); -} - function subscribePush() { navigator.serviceWorker.ready.then(function(swRegistration) { - pushSubscriptionOptions.applicationServerKey = applicationServerKey.buffer; - return swRegistration.pushManager.subscribe(pushSubscriptionOptions) - .then(function(subscription) { - pushSubscription = subscription; - sendResultToTest(subscription.endpoint); - }); - }).catch(sendErrorToTest); -} - -function subscribePushBadKey() { - navigator.serviceWorker.ready.then(function(swRegistration) { - var invalidApplicationServerKey = Uint8Array.from(applicationServerKey); - invalidApplicationServerKey[0] = 0x05; - pushSubscriptionOptions.applicationServerKey = - invalidApplicationServerKey.buffer; return swRegistration.pushManager.subscribe(pushSubscriptionOptions) .then(function(subscription) { pushSubscription = subscription; diff --git a/content/browser/push_messaging/push_messaging_message_filter.cc b/content/browser/push_messaging/push_messaging_message_filter.cc index ef75724..a2eb895 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 @@ bool PushMessagingMessageFilter::OnMessageReceived( 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 @@ void PushMessagingMessageFilter::OnSubscribeFromDocument( 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 @@ void PushMessagingMessageFilter::OnSubscribeFromDocument( 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 @@ void PushMessagingMessageFilter::OnSubscribeFromWorker( } 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); + // This sender_id will be ignored; instead it will be fetched from storage. + CheckForExistingRegistration(data, std::string() /* sender_id */); } -void PushMessagingMessageFilter::DidPersistSenderInfo( +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 @@ void PushMessagingMessageFilter::DidCheckForExistingRegistration( // 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::DidGetSenderIdFromStorage( 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 @@ void PushMessagingMessageFilter::Core::RegisterOnUI( 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)); } diff --git a/content/browser/push_messaging/push_messaging_message_filter.h b/content/browser/push_messaging/push_messaging_message_filter.h index d2db18a..aba0b34 100644 --- a/content/browser/push_messaging/push_messaging_message_filter.h +++ b/content/browser/push_messaging/push_messaging_message_filter.h @@ -23,7 +23,6 @@ namespace content { class PushMessagingService; class ServiceWorkerContextWrapper; -struct PushSubscriptionOptions; extern const char kPushSenderIdServiceWorkerKey[]; extern const char kPushRegistrationIdServiceWorkerKey[]; @@ -51,25 +50,26 @@ class PushMessagingMessageFilter : public BrowserMessageFilter { void 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); void OnSubscribeFromWorker(int request_id, int64_t service_worker_registration_id, - const PushSubscriptionOptions& options); + bool user_visible); - void DidPersistSenderInfo(const RegisterData& data, - const PushSubscriptionOptions& options, - ServiceWorkerStatusCode service_worker_status); + void DidPersistSenderId(const RegisterData& data, + const std::string& sender_id, + ServiceWorkerStatusCode service_worker_status); // sender_id is ignored if data.FromDocument() is false. void CheckForExistingRegistration(const RegisterData& data, - const PushSubscriptionOptions& options); + const std::string& sender_id); // sender_id is ignored if data.FromDocument() is false. void DidCheckForExistingRegistration( const RegisterData& data, - const PushSubscriptionOptions& options, + const std::string& sender_id, const std::string& push_registration_id, ServiceWorkerStatusCode service_worker_status); diff --git a/content/child/push_messaging/push_provider.cc b/content/child/push_messaging/push_provider.cc index 254d855..f8e807d 100644 --- a/content/child/push_messaging/push_provider.cc +++ b/content/child/push_messaging/push_provider.cc @@ -75,11 +75,8 @@ void PushProvider::subscribe( subscription_callbacks_.AddWithID(callbacks, request_id); int64_t service_worker_registration_id = GetServiceWorkerRegistrationId(service_worker_registration); - PushSubscriptionOptions content_options; - content_options.user_visible_only = options.userVisibleOnly; - content_options.sender_info = options.applicationServerKey.utf8(); thread_safe_sender_->Send(new PushMessagingHostMsg_SubscribeFromWorker( - request_id, service_worker_registration_id, content_options)); + request_id, service_worker_registration_id, options.userVisibleOnly)); } void PushProvider::unsubscribe( diff --git a/content/common/push_messaging_messages.h b/content/common/push_messaging_messages.h index df88b2f..38a39e8 100644 --- a/content/common/push_messaging_messages.h +++ b/content/common/push_messaging_messages.h @@ -8,7 +8,6 @@ #include <stdint.h> #include "content/public/common/push_messaging_status.h" -#include "content/public/common/push_subscription_options.h" #include "ipc/ipc_message_macros.h" #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushError.h" #include "third_party/WebKit/public/platform/modules/push_messaging/WebPushPermissionStatus.h" @@ -30,11 +29,6 @@ IPC_ENUM_TRAITS_MAX_VALUE( blink::WebPushError::ErrorType, blink::WebPushError::ErrorType::ErrorTypeLast) -IPC_STRUCT_TRAITS_BEGIN(content::PushSubscriptionOptions) - IPC_STRUCT_TRAITS_MEMBER(user_visible_only) - IPC_STRUCT_TRAITS_MEMBER(sender_info) -IPC_STRUCT_TRAITS_END() - // Messages sent from the browser to the child process. IPC_MESSAGE_ROUTED4(PushMessagingMsg_SubscribeFromDocumentSuccess, @@ -86,16 +80,17 @@ IPC_MESSAGE_CONTROL2(PushMessagingMsg_GetPermissionStatusError, // Messages sent from the child process to the browser. -IPC_MESSAGE_CONTROL4(PushMessagingHostMsg_SubscribeFromDocument, +IPC_MESSAGE_CONTROL5(PushMessagingHostMsg_SubscribeFromDocument, int32_t /* render_frame_id */, int32_t /* request_id */, - content::PushSubscriptionOptions /* options */, + std::string /* sender_id */, + bool /* user_visible */, int64_t /* service_worker_registration_id */) IPC_MESSAGE_CONTROL3(PushMessagingHostMsg_SubscribeFromWorker, int32_t /* request_id */, int64_t /* service_worker_registration_id */, - content::PushSubscriptionOptions /* options */) + bool /* user_visible */) IPC_MESSAGE_CONTROL2(PushMessagingHostMsg_Unsubscribe, int32_t /* request_id */, diff --git a/content/public/browser/push_messaging_service.h b/content/public/browser/push_messaging_service.h index 993e281..86aa34e 100644 --- a/content/public/browser/push_messaging_service.h +++ b/content/public/browser/push_messaging_service.h @@ -19,7 +19,6 @@ 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. @@ -50,22 +49,24 @@ class CONTENT_EXPORT PushMessagingService { // origins and push registrations. virtual GURL GetPushEndpoint() = 0; - // 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. + // 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. 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, - const PushSubscriptionOptions& options, + bool user_visible, const RegisterCallback& callback) = 0; - // 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. + // 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. virtual void SubscribeFromWorker(const GURL& requesting_origin, int64_t service_worker_registration_id, - const PushSubscriptionOptions& options, + const std::string& sender_id, + bool user_visible, 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 deleted file mode 100644 index 1a2da0a..0000000 --- a/content/public/common/push_subscription_options.h +++ /dev/null @@ -1,32 +0,0 @@ -// 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_ diff --git a/content/renderer/push_messaging/push_messaging_dispatcher.cc b/content/renderer/push_messaging/push_messaging_dispatcher.cc index ef35db5..d107043 100644 --- a/content/renderer/push_messaging/push_messaging_dispatcher.cc +++ b/content/renderer/push_messaging/push_messaging_dispatcher.cc @@ -44,63 +44,46 @@ void PushMessagingDispatcher::subscribe( blink::WebPushSubscriptionCallbacks* callbacks) { DCHECK(service_worker_registration); DCHECK(callbacks); - // If a developer provided an application server key in |options|, skip - // fetching the manifest. - if (options.applicationServerKey.isEmpty()) { - RenderFrameImpl::FromRoutingID(routing_id()) - ->manifest_manager() - ->GetManifest(base::Bind( - &PushMessagingDispatcher::DidGetManifest, base::Unretained(this), - service_worker_registration, options, callbacks)); - } else { - PushSubscriptionOptions content_options; - content_options.user_visible_only = options.userVisibleOnly; - content_options.sender_info = options.applicationServerKey.utf8(); - DoSubscribe(service_worker_registration, content_options, callbacks); - } + RenderFrameImpl::FromRoutingID(routing_id()) + ->manifest_manager() + ->GetManifest(base::Bind( + &PushMessagingDispatcher::DoSubscribe, base::Unretained(this), + service_worker_registration, options, callbacks)); } -void PushMessagingDispatcher::DidGetManifest( +void PushMessagingDispatcher::DoSubscribe( blink::WebServiceWorkerRegistration* service_worker_registration, const blink::WebPushSubscriptionOptions& options, blink::WebPushSubscriptionCallbacks* callbacks, const Manifest& manifest) { int request_id = subscription_callbacks_.Add(callbacks); - // Get the sender_info from the manifest since it wasn't provided by - // the caller. + int64_t service_worker_registration_id = + static_cast<WebServiceWorkerRegistrationImpl*>( + service_worker_registration) + ->registration_id(); + if (manifest.IsEmpty()) { OnSubscribeFromDocumentError( request_id, PUSH_REGISTRATION_STATUS_MANIFEST_EMPTY_OR_MISSING); return; } - PushSubscriptionOptions content_options; - content_options.user_visible_only = options.userVisibleOnly; - if (!manifest.gcm_sender_id.is_null()) { - content_options.sender_info = - base::UTF16ToUTF8(manifest.gcm_sender_id.string()); - } - - DoSubscribe(service_worker_registration, content_options, callbacks); -} - -void PushMessagingDispatcher::DoSubscribe( - blink::WebServiceWorkerRegistration* service_worker_registration, - const PushSubscriptionOptions& options, - blink::WebPushSubscriptionCallbacks* callbacks) { - int request_id = subscription_callbacks_.Add(callbacks); - int64_t service_worker_registration_id = - static_cast<WebServiceWorkerRegistrationImpl*>( - service_worker_registration) - ->registration_id(); - - if (options.sender_info.empty()) { + std::string sender_id = + manifest.gcm_sender_id.is_null() + ? std::string() + : base::UTF16ToUTF8(manifest.gcm_sender_id.string()); + if (sender_id.empty()) { OnSubscribeFromDocumentError(request_id, PUSH_REGISTRATION_STATUS_NO_SENDER_ID); return; } + Send(new PushMessagingHostMsg_SubscribeFromDocument( - routing_id(), request_id, options, service_worker_registration_id)); + routing_id(), request_id, + manifest.gcm_sender_id.is_null() + ? std::string() + : base::UTF16ToUTF8(manifest.gcm_sender_id.string()), + options.userVisibleOnly, service_worker_registration_id)); } void PushMessagingDispatcher::OnSubscribeFromDocumentSuccess( diff --git a/content/renderer/push_messaging/push_messaging_dispatcher.h b/content/renderer/push_messaging/push_messaging_dispatcher.h index 71294e2..ca6610b 100644 --- a/content/renderer/push_messaging/push_messaging_dispatcher.h +++ b/content/renderer/push_messaging/push_messaging_dispatcher.h @@ -29,7 +29,6 @@ class Message; namespace content { struct Manifest; -struct PushSubscriptionOptions; class PushMessagingDispatcher : public RenderFrameObserver, public blink::WebPushClient { @@ -47,17 +46,12 @@ class PushMessagingDispatcher : public RenderFrameObserver, const blink::WebPushSubscriptionOptions& options, blink::WebPushSubscriptionCallbacks* callbacks) override; - void DidGetManifest( + void DoSubscribe( blink::WebServiceWorkerRegistration* service_worker_registration, const blink::WebPushSubscriptionOptions& options, blink::WebPushSubscriptionCallbacks* callbacks, const Manifest& manifest); - void DoSubscribe( - blink::WebServiceWorkerRegistration* service_worker_registration, - const PushSubscriptionOptions& options, - blink::WebPushSubscriptionCallbacks* callbacks); - void OnSubscribeFromDocumentSuccess(int32_t request_id, const GURL& endpoint, const std::vector<uint8_t>& p256dh, diff --git a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc index c346a08..11554e9 100644 --- a/content/shell/browser/layout_test/layout_test_push_messaging_service.cc +++ b/content/shell/browser/layout_test/layout_test_push_messaging_service.cc @@ -8,7 +8,6 @@ #include "base/logging.h" #include "base/macros.h" #include "content/public/browser/permission_type.h" -#include "content/public/common/push_subscription_options.h" #include "content/shell/browser/layout_test/layout_test_browser_context.h" #include "content/shell/browser/layout_test/layout_test_content_browser_client.h" #include "content/shell/browser/layout_test/layout_test_permission_manager.h" @@ -68,20 +67,22 @@ GURL LayoutTestPushMessagingService::GetPushEndpoint() { void LayoutTestPushMessagingService::SubscribeFromDocument( const GURL& requesting_origin, int64_t service_worker_registration_id, + const std::string& sender_id, int renderer_id, int render_frame_id, - const PushSubscriptionOptions& options, + bool user_visible, const PushMessagingService::RegisterCallback& callback) { SubscribeFromWorker(requesting_origin, service_worker_registration_id, - options, callback); + sender_id, user_visible, callback); } void LayoutTestPushMessagingService::SubscribeFromWorker( const GURL& requesting_origin, int64_t service_worker_registration_id, - const PushSubscriptionOptions& options, + const std::string& sender_id, + bool user_visible, const PushMessagingService::RegisterCallback& callback) { - if (GetPermissionStatus(requesting_origin, options.user_visible_only) == + if (GetPermissionStatus(requesting_origin, user_visible) == blink::WebPushPermissionStatusGranted) { std::vector<uint8_t> p256dh( kTestP256Key, kTestP256Key + arraysize(kTestP256Key)); diff --git a/content/shell/browser/layout_test/layout_test_push_messaging_service.h b/content/shell/browser/layout_test/layout_test_push_messaging_service.h index 5e5a7a48..eb5e7e4 100644 --- a/content/shell/browser/layout_test/layout_test_push_messaging_service.h +++ b/content/shell/browser/layout_test/layout_test_push_messaging_service.h @@ -17,8 +17,6 @@ namespace content { -struct PushSubscriptionOptions; - class LayoutTestPushMessagingService : public PushMessagingService { public: LayoutTestPushMessagingService(); @@ -29,14 +27,16 @@ class LayoutTestPushMessagingService : public PushMessagingService { void SubscribeFromDocument( const GURL& requesting_origin, int64_t service_worker_registration_id, + const std::string& sender_id, int renderer_id, int render_frame_id, - const PushSubscriptionOptions& options, + bool user_visible, const PushMessagingService::RegisterCallback& callback) override; void SubscribeFromWorker( const GURL& requesting_origin, int64_t service_worker_registration_id, - const PushSubscriptionOptions& options, + const std::string& sender_id, + bool user_visible, const PushMessagingService::RegisterCallback& callback) override; void GetEncryptionInfo( const GURL& origin, diff --git a/third_party/WebKit/Source/modules/modules.gypi b/third_party/WebKit/Source/modules/modules.gypi index 69196df..b06446c 100644 --- a/third_party/WebKit/Source/modules/modules.gypi +++ b/third_party/WebKit/Source/modules/modules.gypi @@ -1967,7 +1967,6 @@ 'mediastream/RTCDataChannelTest.cpp', 'notifications/NotificationDataTest.cpp', 'presentation/PresentationAvailabilityTest.cpp', - 'push_messaging/PushManagerTest.cpp', 'push_messaging/PushMessageDataTest.cpp', 'serviceworkers/ServiceWorkerContainerTest.cpp', 'webaudio/AudioBasicProcessorHandlerTest.cpp', diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp index 7d5eacd..0f5a2ff 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp @@ -34,29 +34,11 @@ WebPushProvider* pushProvider() return webPushProvider; } -String bufferSourceToString(const ArrayBufferOrArrayBufferView& applicationServerKey, ExceptionState& exceptionState) +WebPushSubscriptionOptions toWebPushSubscriptionOptions(const PushSubscriptionOptions& options) { - // Check the validity of the sender info. It must be a 65 byte unencrypted key, - // which has the byte 0x04 as the first byte as a marker. - char* input; - int length; - if (applicationServerKey.isArrayBuffer()) { - input = static_cast<char*>( - applicationServerKey.getAsArrayBuffer()->data()); - length = applicationServerKey.getAsArrayBuffer()->byteLength(); - } else if (applicationServerKey.isArrayBufferView()) { - input = static_cast<char*>( - applicationServerKey.getAsArrayBufferView()->buffer()->data()); - length = applicationServerKey.getAsArrayBufferView()->buffer()->byteLength(); - } else { - ASSERT_NOT_REACHED(); - return String(); - } - - if (length == 65 && input[0] == 0x04) - return WebString::fromUTF8(input, length); - exceptionState.throwDOMException(InvalidAccessError, "The provided applicationServerKey is not valid."); - return String(); + WebPushSubscriptionOptions webOptions; + webOptions.userVisibleOnly = options.userVisibleOnly(); + return webOptions; } } // namespace @@ -67,26 +49,11 @@ PushManager::PushManager(ServiceWorkerRegistration* registration) ASSERT(registration); } -WebPushSubscriptionOptions PushManager::toWebPushSubscriptionOptions(const PushSubscriptionOptions& options, ExceptionState& exceptionState) -{ - WebPushSubscriptionOptions webOptions; - webOptions.userVisibleOnly = options.userVisibleOnly(); - if (options.hasApplicationServerKey()) { - webOptions.applicationServerKey = bufferSourceToString(options.applicationServerKey(), - exceptionState); - } - return webOptions; -} - -ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscriptionOptions& options, ExceptionState& exceptionState) +ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscriptionOptions& options) { if (!m_registration->active()) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(AbortError, "Subscription failed - no active Service Worker")); - const WebPushSubscriptionOptions& webOptions = toWebPushSubscriptionOptions(options, exceptionState); - if (exceptionState.hadException()) - return ScriptPromise(); - ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); @@ -97,9 +64,9 @@ ScriptPromise PushManager::subscribe(ScriptState* scriptState, const PushSubscri Document* document = toDocument(scriptState->executionContext()); if (!document->domWindow() || !document->frame()) return ScriptPromise::rejectWithDOMException(scriptState, DOMException::create(InvalidStateError, "Document is detached from window.")); - PushController::clientFrom(document->frame()).subscribe(m_registration->webRegistration(), webOptions, new PushSubscriptionCallbacks(resolver, m_registration)); + PushController::clientFrom(document->frame()).subscribe(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushSubscriptionCallbacks(resolver, m_registration)); } else { - pushProvider()->subscribe(m_registration->webRegistration(), webOptions, new PushSubscriptionCallbacks(resolver, m_registration)); + pushProvider()->subscribe(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushSubscriptionCallbacks(resolver, m_registration)); } return promise; @@ -114,7 +81,7 @@ ScriptPromise PushManager::getSubscription(ScriptState* scriptState) return promise; } -ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushSubscriptionOptions& options, ExceptionState& exceptionState) +ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushSubscriptionOptions& options) { if (scriptState->executionContext()->isDocument()) { Document* document = toDocument(scriptState->executionContext()); @@ -125,7 +92,7 @@ ScriptPromise PushManager::permissionState(ScriptState* scriptState, const PushS ScriptPromiseResolver* resolver = ScriptPromiseResolver::create(scriptState); ScriptPromise promise = resolver->promise(); - pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWebPushSubscriptionOptions(options, exceptionState), new PushPermissionStatusCallbacks(resolver)); + pushProvider()->getPermissionStatus(m_registration->webRegistration(), toWebPushSubscriptionOptions(options), new PushPermissionStatusCallbacks(resolver)); return promise; } diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.h b/third_party/WebKit/Source/modules/push_messaging/PushManager.h index a4c0729..d6d9cfd 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.h +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.h @@ -6,20 +6,16 @@ #define PushManager_h #include "bindings/core/v8/ScriptWrappable.h" -#include "bindings/modules/v8/UnionTypesModules.h" -#include "modules/ModulesExport.h" #include "platform/heap/Handle.h" namespace blink { -class ExceptionState; class PushSubscriptionOptions; class ScriptPromise; class ScriptState; class ServiceWorkerRegistration; -struct WebPushSubscriptionOptions; -class MODULES_EXPORT PushManager final : public GarbageCollected<PushManager>, public ScriptWrappable { +class PushManager final : public GarbageCollected<PushManager>, public ScriptWrappable { DEFINE_WRAPPERTYPEINFO(); public: static PushManager* create(ServiceWorkerRegistration* registration) @@ -27,17 +23,12 @@ public: return new PushManager(registration); } - ScriptPromise subscribe(ScriptState*, const PushSubscriptionOptions&, - ExceptionState&); + ScriptPromise subscribe(ScriptState*, const PushSubscriptionOptions&); ScriptPromise getSubscription(ScriptState*); - ScriptPromise permissionState(ScriptState*, const PushSubscriptionOptions&, - ExceptionState&); + ScriptPromise permissionState(ScriptState*, const PushSubscriptionOptions&); DECLARE_TRACE(); - static WebPushSubscriptionOptions toWebPushSubscriptionOptions( - const PushSubscriptionOptions&, ExceptionState&); - private: explicit PushManager(ServiceWorkerRegistration*); diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.idl b/third_party/WebKit/Source/modules/push_messaging/PushManager.idl index 0c4ff864..ddb6139 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushManager.idl +++ b/third_party/WebKit/Source/modules/push_messaging/PushManager.idl @@ -9,7 +9,7 @@ GarbageCollected, RuntimeEnabled=PushMessaging, ] interface PushManager { - [CallWith=ScriptState, RaisesException] Promise<PushSubscription> subscribe(optional PushSubscriptionOptions options); + [CallWith=ScriptState] Promise<PushSubscription> subscribe(optional PushSubscriptionOptions options); [CallWith=ScriptState] Promise<PushSubscription?> getSubscription(); - [CallWith=ScriptState, RaisesException] Promise permissionState(optional PushSubscriptionOptions options); + [CallWith=ScriptState] Promise permissionState(optional PushSubscriptionOptions options); }; diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp deleted file mode 100644 index e5e7f8f..0000000 --- a/third_party/WebKit/Source/modules/push_messaging/PushManagerTest.cpp +++ /dev/null @@ -1,68 +0,0 @@ -// 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. - -#include "modules/push_messaging/PushManager.h" - -#include "bindings/modules/v8/UnionTypesModules.h" -#include "core/dom/DOMArrayBuffer.h" -#include "modules/push_messaging/PushSubscriptionOptions.h" -#include "public/platform/WebString.h" -#include "public/platform/modules/push_messaging/WebPushSubscriptionOptions.h" -#include "testing/gtest/include/gtest/gtest.h" - -namespace blink { -namespace { - -const char kValidKeyMarker = 0x04; -const unsigned kValidKeyLength = 65; - -TEST(PushManagerTest, ValidSenderKey) -{ - uint8_t senderKey[kValidKeyLength]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = kValidKeyMarker; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_FALSE(exceptionState.hadException()); - EXPECT_EQ(output.applicationServerKey.length(), kValidKeyLength); - EXPECT_EQ(output.applicationServerKey, WebString::fromUTF8(reinterpret_cast<const char*>(senderKey), kValidKeyLength)); -} - -TEST(PushManagerTest, InvalidSenderKeyMarker) -{ - uint8_t senderKey[kValidKeyLength]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = 0x05; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_TRUE(exceptionState.hadException()); -} - -TEST(PushManagerTest, InvalidSenderKeyLength) -{ - uint8_t senderKey[kValidKeyLength - 1]; - memset(senderKey, 0, sizeof(senderKey)); - senderKey[0] = kValidKeyMarker; - PushSubscriptionOptions options; - options.setApplicationServerKey( - ArrayBufferOrArrayBufferView::fromArrayBuffer( - DOMArrayBuffer::create(senderKey, kValidKeyLength - 1))); - - TrackExceptionState exceptionState; - WebPushSubscriptionOptions output = PushManager::toWebPushSubscriptionOptions(options, exceptionState); - EXPECT_TRUE(exceptionState.hadException()); -} - -} // namespace -} // namespace blink diff --git a/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl b/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl index 48af6cc..f034242 100644 --- a/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl +++ b/third_party/WebKit/Source/modules/push_messaging/PushSubscriptionOptions.idl @@ -6,5 +6,4 @@ dictionary PushSubscriptionOptions { boolean userVisibleOnly = false; - [RuntimeEnabled=PushSubscriptionRestrictions] BufferSource applicationServerKey; }; diff --git a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in index bd06d46..8a0bcf0 100644 --- a/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in +++ b/third_party/WebKit/Source/platform/RuntimeEnabledFeatures.in @@ -151,7 +151,6 @@ PresentationReceiver status=test PromiseRejectionEvent status=stable PushMessaging status=stable PushMessagingData status=stable -PushSubscriptionRestrictions status=experimental QuotaPromise status=experimental ReducedReferrerGranularity RenderingPipelineThrottling status=experimental diff --git a/third_party/WebKit/public/platform/modules/push_messaging/WebPushSubscriptionOptions.h b/third_party/WebKit/public/platform/modules/push_messaging/WebPushSubscriptionOptions.h index ad3db17..bfac23a 100644 --- a/third_party/WebKit/public/platform/modules/push_messaging/WebPushSubscriptionOptions.h +++ b/third_party/WebKit/public/platform/modules/push_messaging/WebPushSubscriptionOptions.h @@ -5,8 +5,6 @@ #ifndef WebPushSubscriptionOptions_h #define WebPushSubscriptionOptions_h -#include "public/platform/WebString.h" - namespace blink { struct WebPushSubscriptionOptions { @@ -18,10 +16,6 @@ struct WebPushSubscriptionOptions { // Indicates that the subscription will only be used for push messages // that result in UI visible to the user. bool userVisibleOnly; - - // P-256 public key, in uncompressed form, of the app server that can send - // push messages to this subscription. - WebString applicationServerKey; }; } // namespace blink |