OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "config.h" | 5 #include "config.h" |
6 #include "bindings/core/v8/ToV8.h" | 6 #include "bindings/core/v8/ToV8.h" |
7 | 7 |
8 #include "core/events/EventTarget.h" | 8 #include "core/events/EventTarget.h" |
9 #include "core/frame/DOMWindow.h" | 9 #include "core/frame/DOMWindow.h" |
10 #include "core/workers/WorkerGlobalScope.h" | 10 #include "core/workers/WorkerGlobalScope.h" |
11 | 11 |
12 namespace blink { | 12 namespace blink { |
13 | 13 |
14 v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationCon
text, v8::Isolate* isolate) | 14 v8::Local<v8::Value> toV8(DOMWindow* window, v8::Local<v8::Object> creationConte
xt, v8::Isolate* isolate) |
15 { | 15 { |
16 // Notice that we explicitly ignore creationContext because the DOMWindow | 16 // Notice that we explicitly ignore creationContext because the DOMWindow |
17 // has its own creationContext. | 17 // has its own creationContext. |
18 | 18 |
19 if (UNLIKELY(!window)) | 19 if (UNLIKELY(!window)) |
20 return v8::Null(isolate); | 20 return v8::Null(isolate); |
21 // Initializes environment of a frame, and return the global object | 21 // Initializes environment of a frame, and return the global object |
22 // of the frame. | 22 // of the frame. |
23 Frame * frame = window->frame(); | 23 Frame * frame = window->frame(); |
24 if (!frame) | 24 if (!frame) |
25 return v8Undefined(); | 25 return v8Undefined(); |
26 | 26 |
27 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(isolate)); | 27 v8::Local<v8::Context> context = toV8Context(frame, DOMWrapperWorld::current
(isolate)); |
28 if (context.IsEmpty()) | 28 if (context.IsEmpty()) |
29 return v8Undefined(); | 29 return v8Undefined(); |
30 | 30 |
31 v8::Local<v8::Object> global = context->Global(); | 31 v8::Local<v8::Object> global = context->Global(); |
32 ASSERT(!global.IsEmpty()); | 32 ASSERT(!global.IsEmpty()); |
33 return global; | 33 return global; |
34 } | 34 } |
35 | 35 |
36 v8::Handle<v8::Value> toV8(EventTarget* impl, v8::Handle<v8::Object> creationCon
text, v8::Isolate* isolate) | 36 v8::Local<v8::Value> toV8(EventTarget* impl, v8::Local<v8::Object> creationConte
xt, v8::Isolate* isolate) |
37 { | 37 { |
38 if (UNLIKELY(!impl)) | 38 if (UNLIKELY(!impl)) |
39 return v8::Null(isolate); | 39 return v8::Null(isolate); |
40 | 40 |
41 if (impl->interfaceName() == EventTargetNames::DOMWindow) | 41 if (impl->interfaceName() == EventTargetNames::DOMWindow) |
42 return toV8(static_cast<DOMWindow*>(impl), creationContext, isolate); | 42 return toV8(static_cast<DOMWindow*>(impl), creationContext, isolate); |
43 return toV8(static_cast<ScriptWrappable*>(impl), creationContext, isolate); | 43 return toV8(static_cast<ScriptWrappable*>(impl), creationContext, isolate); |
44 } | 44 } |
45 | 45 |
46 v8::Handle<v8::Value> toV8(WorkerGlobalScope* impl, v8::Handle<v8::Object> creat
ionContext, v8::Isolate* isolate) | 46 v8::Local<v8::Value> toV8(WorkerGlobalScope* impl, v8::Local<v8::Object> creatio
nContext, v8::Isolate* isolate) |
47 { | 47 { |
48 // Notice that we explicitly ignore creationContext because the | 48 // Notice that we explicitly ignore creationContext because the |
49 // WorkerGlobalScope has its own creationContext. | 49 // WorkerGlobalScope has its own creationContext. |
50 | 50 |
51 if (UNLIKELY(!impl)) | 51 if (UNLIKELY(!impl)) |
52 return v8::Null(isolate); | 52 return v8::Null(isolate); |
53 | 53 |
54 WorkerScriptController* script = impl->script(); | 54 WorkerScriptController* script = impl->script(); |
55 if (!script) | 55 if (!script) |
56 return v8::Null(isolate); | 56 return v8::Null(isolate); |
57 | 57 |
58 v8::Local<v8::Object> global = script->context()->Global(); | 58 v8::Local<v8::Object> global = script->context()->Global(); |
59 ASSERT(!global.IsEmpty()); | 59 ASSERT(!global.IsEmpty()); |
60 return global; | 60 return global; |
61 } | 61 } |
62 | 62 |
63 } // namespace blink | 63 } // namespace blink |
OLD | NEW |