blob: f6afc329eb8e50286fd3addb4915adc998c65ced [file] [log] [blame]
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "bindings/core/v8/V8PagePopupControllerBinding.h"
#include "bindings/core/v8/V8Binding.h"
#include "bindings/core/v8/V8Window.h"
#include "core/dom/ContextFeatures.h"
#include "core/dom/Document.h"
#include "core/dom/ExecutionContext.h"
#include "core/frame/LocalDOMWindow.h"
#include "core/page/PagePopupController.h"
#include "core/page/PagePopupSupplement.h"
#include "platform/instrumentation/tracing/TraceEvent.h"
namespace blink {
namespace {
void pagePopupControllerAttributeGetter(
const v8::PropertyCallbackInfo<v8::Value>& info) {
v8::Local<v8::Object> holder = info.Holder();
DOMWindow* impl = V8Window::toImpl(holder);
PagePopupController* cppValue =
PagePopupSupplement::from(*toLocalDOMWindow(impl)->frame())
.pagePopupController();
v8SetReturnValue(info, ToV8(cppValue, holder, info.GetIsolate()));
}
void pagePopupControllerAttributeGetterCallback(
v8::Local<v8::Name>,
const v8::PropertyCallbackInfo<v8::Value>& info) {
pagePopupControllerAttributeGetter(info);
}
} // namespace
void V8PagePopupControllerBinding::installPagePopupController(
v8::Local<v8::Context> context,
v8::Local<v8::Object> windowWrapper) {
ExecutionContext* executionContext =
toExecutionContext(windowWrapper->CreationContext());
if (!(executionContext && executionContext->isDocument() &&
ContextFeatures::pagePopupEnabled(toDocument(executionContext))))
return;
windowWrapper->SetAccessor(
context, v8AtomicString(context->GetIsolate(), "pagePopupController"),
pagePopupControllerAttributeGetterCallback);
}
} // namespace blink