OLD | NEW |
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "modules/push_messaging/PushSubscriptionOptions.h" | 5 #include "modules/push_messaging/PushSubscriptionOptions.h" |
6 | 6 |
7 #include "bindings/core/v8/ExceptionState.h" | 7 #include "bindings/core/v8/ExceptionState.h" |
8 #include "core/dom/DOMArrayBuffer.h" | 8 #include "core/dom/DOMArrayBuffer.h" |
9 #include "core/dom/ExceptionCode.h" | 9 #include "core/dom/ExceptionCode.h" |
10 #include "modules/push_messaging/PushSubscriptionOptionsInit.h" | 10 #include "modules/push_messaging/PushSubscriptionOptionsInit.h" |
11 #include "public/platform/WebString.h" | 11 #include "public/platform/WebString.h" |
12 #include "public/platform/modules/push_messaging/WebPushSubscriptionOptions.h" | 12 #include "public/platform/modules/push_messaging/WebPushSubscriptionOptions.h" |
13 #include "wtf/Assertions.h" | 13 #include "wtf/Assertions.h" |
14 #include "wtf/text/WTFString.h" | 14 #include "wtf/text/WTFString.h" |
15 | 15 |
16 namespace blink { | 16 namespace blink { |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kMaxApplicationServerKeyLength = 255; | 19 const int kMaxApplicationServerKeyLength = 255; |
20 | 20 |
21 String bufferSourceToString( | 21 String bufferSourceToString( |
22 const ArrayBufferOrArrayBufferView& applicationServerKey, | 22 const ArrayBufferOrArrayBufferView& applicationServerKey, |
23 ExceptionState& exceptionState) { | 23 ExceptionState& exceptionState) { |
24 // Check the validity of the sender info. It must be a 65 byte unencrypted key
, | 24 // Check the validity of the sender info. It must be a 65-byte uncompressed |
25 // which has the byte 0x04 as the first byte as a marker. | 25 // key, which has the byte 0x04 as the first byte as a marker. |
26 unsigned char* input; | 26 unsigned char* input; |
27 int length; | 27 int length; |
28 if (applicationServerKey.isArrayBuffer()) { | 28 if (applicationServerKey.isArrayBuffer()) { |
29 input = static_cast<unsigned char*>( | 29 input = static_cast<unsigned char*>( |
30 applicationServerKey.getAsArrayBuffer()->data()); | 30 applicationServerKey.getAsArrayBuffer()->data()); |
31 length = applicationServerKey.getAsArrayBuffer()->byteLength(); | 31 length = applicationServerKey.getAsArrayBuffer()->byteLength(); |
32 } else if (applicationServerKey.isArrayBufferView()) { | 32 } else if (applicationServerKey.isArrayBufferView()) { |
33 input = static_cast<unsigned char*>( | 33 input = static_cast<unsigned char*>( |
34 applicationServerKey.getAsArrayBufferView()->buffer()->data()); | 34 applicationServerKey.getAsArrayBufferView()->buffer()->data()); |
35 length = | 35 length = |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 : m_userVisibleOnly(options.userVisibleOnly), | 68 : m_userVisibleOnly(options.userVisibleOnly), |
69 m_applicationServerKey( | 69 m_applicationServerKey( |
70 DOMArrayBuffer::create(options.applicationServerKey.latin1().data(), | 70 DOMArrayBuffer::create(options.applicationServerKey.latin1().data(), |
71 options.applicationServerKey.length())) {} | 71 options.applicationServerKey.length())) {} |
72 | 72 |
73 DEFINE_TRACE(PushSubscriptionOptions) { | 73 DEFINE_TRACE(PushSubscriptionOptions) { |
74 visitor->trace(m_applicationServerKey); | 74 visitor->trace(m_applicationServerKey); |
75 } | 75 } |
76 | 76 |
77 } // namespace blink | 77 } // namespace blink |
OLD | NEW |