| Index: third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
|
| diff --git a/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp b/third_party/WebKit/Source/modules/push_messaging/PushManager.cpp
|
| index 7d5eacd062eb62cacac967fb741b595722d86e84..0f5a2ffd66ddd641444c5580ef3b4c3273ccc98d 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 @@
|
| 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,25 +49,10 @@
|
| 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 @@
|
| 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 @@
|
| 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 @@
|
| 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;
|
| }
|
|
|
|
|