| 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 "bindings/core/v8/V8PagePopupControllerBinding.h" | 5 #include "bindings/core/v8/V8PagePopupControllerBinding.h" |
| 6 | 6 |
| 7 #include "bindings/core/v8/V8Binding.h" | 7 #include "bindings/core/v8/V8Binding.h" |
| 8 #include "bindings/core/v8/V8Window.h" | 8 #include "bindings/core/v8/V8Window.h" |
| 9 #include "core/dom/ContextFeatures.h" | 9 #include "core/dom/ContextFeatures.h" |
| 10 #include "core/dom/Document.h" | 10 #include "core/dom/Document.h" |
| 11 #include "core/dom/ExecutionContext.h" | 11 #include "core/dom/ExecutionContext.h" |
| 12 #include "core/frame/LocalDOMWindow.h" | 12 #include "core/frame/LocalDOMWindow.h" |
| 13 #include "core/page/PagePopupController.h" | 13 #include "core/page/PagePopupController.h" |
| 14 #include "core/page/PagePopupSupplement.h" | 14 #include "core/page/PagePopupSupplement.h" |
| 15 #include "platform/instrumentation/tracing/TraceEvent.h" | 15 #include "platform/instrumentation/tracing/TraceEvent.h" |
| 16 | 16 |
| 17 namespace blink { | 17 namespace blink { |
| 18 | 18 |
| 19 namespace { | 19 namespace { |
| 20 | 20 |
| 21 void pagePopupControllerAttributeGetter( | 21 void pagePopupControllerAttributeGetter( |
| 22 const v8::PropertyCallbackInfo<v8::Value>& info) { | 22 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 23 v8::Local<v8::Object> holder = info.Holder(); | 23 v8::Local<v8::Object> holder = info.Holder(); |
| 24 DOMWindow* impl = V8Window::toImpl(holder); | 24 DOMWindow* impl = V8Window::toImpl(holder); |
| 25 PagePopupController* cppValue = PagePopupSupplement::pagePopupController( | 25 PagePopupController* cppValue = PagePopupSupplement::pagePopupController( |
| 26 *toLocalDOMWindow(impl)->frame()); | 26 *toLocalDOMWindow(impl)->frame()); |
| 27 v8SetReturnValue(info, toV8(cppValue, holder, info.GetIsolate())); | 27 v8SetReturnValue(info, ToV8(cppValue, holder, info.GetIsolate())); |
| 28 } | 28 } |
| 29 | 29 |
| 30 void pagePopupControllerAttributeGetterCallback( | 30 void pagePopupControllerAttributeGetterCallback( |
| 31 v8::Local<v8::Name>, | 31 v8::Local<v8::Name>, |
| 32 const v8::PropertyCallbackInfo<v8::Value>& info) { | 32 const v8::PropertyCallbackInfo<v8::Value>& info) { |
| 33 pagePopupControllerAttributeGetter(info); | 33 pagePopupControllerAttributeGetter(info); |
| 34 } | 34 } |
| 35 | 35 |
| 36 } // namespace | 36 } // namespace |
| 37 | 37 |
| 38 void V8PagePopupControllerBinding::installPagePopupController( | 38 void V8PagePopupControllerBinding::installPagePopupController( |
| 39 v8::Local<v8::Context> context, | 39 v8::Local<v8::Context> context, |
| 40 v8::Local<v8::Object> windowWrapper) { | 40 v8::Local<v8::Object> windowWrapper) { |
| 41 ExecutionContext* executionContext = | 41 ExecutionContext* executionContext = |
| 42 toExecutionContext(windowWrapper->CreationContext()); | 42 toExecutionContext(windowWrapper->CreationContext()); |
| 43 if (!(executionContext && executionContext->isDocument() && | 43 if (!(executionContext && executionContext->isDocument() && |
| 44 ContextFeatures::pagePopupEnabled(toDocument(executionContext)))) | 44 ContextFeatures::pagePopupEnabled(toDocument(executionContext)))) |
| 45 return; | 45 return; |
| 46 | 46 |
| 47 windowWrapper->SetAccessor( | 47 windowWrapper->SetAccessor( |
| 48 context, v8AtomicString(context->GetIsolate(), "pagePopupController"), | 48 context, v8AtomicString(context->GetIsolate(), "pagePopupController"), |
| 49 pagePopupControllerAttributeGetterCallback); | 49 pagePopupControllerAttributeGetterCallback); |
| 50 } | 50 } |
| 51 | 51 |
| 52 } // namespace blink | 52 } // namespace blink |
| OLD | NEW |