OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2012 Google Inc. All rights reserved. | 2 * Copyright (C) 2012 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
(...skipping 15 matching lines...) Expand all Loading... |
26 #include "bindings/modules/v8/V8Crypto.h" | 26 #include "bindings/modules/v8/V8Crypto.h" |
27 | 27 |
28 #include "bindings/core/v8/ExceptionMessages.h" | 28 #include "bindings/core/v8/ExceptionMessages.h" |
29 #include "bindings/core/v8/ExceptionState.h" | 29 #include "bindings/core/v8/ExceptionState.h" |
30 #include "bindings/core/v8/V8Binding.h" | 30 #include "bindings/core/v8/V8Binding.h" |
31 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" | 31 #include "bindings/core/v8/custom/V8ArrayBufferViewCustom.h" |
32 #include "core/dom/ExceptionCode.h" | 32 #include "core/dom/ExceptionCode.h" |
33 #include "modules/crypto/Crypto.h" | 33 #include "modules/crypto/Crypto.h" |
34 #include "wtf/ArrayBufferView.h" | 34 #include "wtf/ArrayBufferView.h" |
35 | 35 |
36 namespace WebCore { | 36 namespace blink { |
37 | 37 |
38 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 38 void V8Crypto::getRandomValuesMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
39 { | 39 { |
40 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa
lues", "Crypto", info.Holder(), info.GetIsolate()); | 40 ExceptionState exceptionState(ExceptionState::ExecutionContext, "getRandomVa
lues", "Crypto", info.Holder(), info.GetIsolate()); |
41 if (info.Length() < 1) { | 41 if (info.Length() < 1) { |
42 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); | 42 exceptionState.throwTypeError(ExceptionMessages::notEnoughArguments(1, i
nfo.Length())); |
43 exceptionState.throwIfNeeded(); | 43 exceptionState.throwIfNeeded(); |
44 return; | 44 return; |
45 } | 45 } |
46 | 46 |
47 v8::Handle<v8::Value> buffer = info[0]; | 47 v8::Handle<v8::Value> buffer = info[0]; |
48 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { | 48 if (!V8ArrayBufferView::hasInstance(buffer, info.GetIsolate())) { |
49 exceptionState.throwTypeError("First argument is not an ArrayBufferView"
); | 49 exceptionState.throwTypeError("First argument is not an ArrayBufferView"
); |
50 } else { | 50 } else { |
51 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handl
e<v8::Object>::Cast(buffer)); | 51 ArrayBufferView* arrayBufferView = V8ArrayBufferView::toNative(v8::Handl
e<v8::Object>::Cast(buffer)); |
52 ASSERT(arrayBufferView); | 52 ASSERT(arrayBufferView); |
53 | 53 |
54 Crypto* crypto = V8Crypto::toNative(info.Holder()); | 54 Crypto* crypto = V8Crypto::toNative(info.Holder()); |
55 crypto->getRandomValues(arrayBufferView, exceptionState); | 55 crypto->getRandomValues(arrayBufferView, exceptionState); |
56 } | 56 } |
57 | 57 |
58 if (exceptionState.throwIfNeeded()) | 58 if (exceptionState.throwIfNeeded()) |
59 return; | 59 return; |
60 | 60 |
61 v8SetReturnValue(info, buffer); | 61 v8SetReturnValue(info, buffer); |
62 } | 62 } |
63 | 63 |
64 } // namespace WebCore | 64 } // namespace blink |
OLD | NEW |