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" |
(...skipping 13 matching lines...) Expand all Loading... |
24 ExceptionState& exception_state) { | 24 ExceptionState& exception_state) { |
25 unsigned char* input; | 25 unsigned char* input; |
26 int length; | 26 int length; |
27 // Convert the input array into a string of bytes. | 27 // Convert the input array into a string of bytes. |
28 if (application_server_key.isArrayBuffer()) { | 28 if (application_server_key.isArrayBuffer()) { |
29 input = static_cast<unsigned char*>( | 29 input = static_cast<unsigned char*>( |
30 application_server_key.getAsArrayBuffer()->Data()); | 30 application_server_key.getAsArrayBuffer()->Data()); |
31 length = application_server_key.getAsArrayBuffer()->ByteLength(); | 31 length = application_server_key.getAsArrayBuffer()->ByteLength(); |
32 } else if (application_server_key.isArrayBufferView()) { | 32 } else if (application_server_key.isArrayBufferView()) { |
33 input = static_cast<unsigned char*>( | 33 input = static_cast<unsigned char*>( |
34 application_server_key.getAsArrayBufferView()->buffer()->Data()); | 34 application_server_key.getAsArrayBufferView().View()->buffer()->Data()); |
35 length = | 35 length = application_server_key.getAsArrayBufferView() |
36 application_server_key.getAsArrayBufferView()->buffer()->ByteLength(); | 36 .View() |
| 37 ->buffer() |
| 38 ->ByteLength(); |
37 } else { | 39 } else { |
38 NOTREACHED(); | 40 NOTREACHED(); |
39 return String(); | 41 return String(); |
40 } | 42 } |
41 | 43 |
42 // Check the validity of the sender info. It must either be a 65-byte | 44 // Check the validity of the sender info. It must either be a 65-byte |
43 // uncompressed VAPID key, which has the byte 0x04 as the first byte or a | 45 // uncompressed VAPID key, which has the byte 0x04 as the first byte or a |
44 // numeric sender ID. | 46 // numeric sender ID. |
45 const bool is_vapid = length == 65 && *input == 0x04; | 47 const bool is_vapid = length == 65 && *input == 0x04; |
46 const bool is_sender_id = | 48 const bool is_sender_id = |
(...skipping 28 matching lines...) Expand all Loading... |
75 : user_visible_only_(options.user_visible_only), | 77 : user_visible_only_(options.user_visible_only), |
76 application_server_key_( | 78 application_server_key_( |
77 DOMArrayBuffer::Create(options.application_server_key.Latin1().data(), | 79 DOMArrayBuffer::Create(options.application_server_key.Latin1().data(), |
78 options.application_server_key.length())) {} | 80 options.application_server_key.length())) {} |
79 | 81 |
80 DEFINE_TRACE(PushSubscriptionOptions) { | 82 DEFINE_TRACE(PushSubscriptionOptions) { |
81 visitor->Trace(application_server_key_); | 83 visitor->Trace(application_server_key_); |
82 } | 84 } |
83 | 85 |
84 } // namespace blink | 86 } // namespace blink |
OLD | NEW |