Index: Source/web/WebFrameImpl.cpp |
diff --git a/Source/web/WebFrameImpl.cpp b/Source/web/WebFrameImpl.cpp |
index 095498ecac6391866cc9b81aef2c9634231bd73d..02954a6ec4100cabb559a0bf123a356c7600e623 100644 |
--- a/Source/web/WebFrameImpl.cpp |
+++ b/Source/web/WebFrameImpl.cpp |
@@ -1,5 +1,6 @@ |
/* |
* Copyright (C) 2009 Google Inc. All rights reserved. |
+ * Copyright (C) 2013 Opera Software ASA. All rights reserved. |
* |
* Redistribution and use in source and binary forms, with or without |
* modification, are permitted provided that the following conditions are |
@@ -81,6 +82,7 @@ |
#include "V8DOMFileSystem.h" |
#include "V8DirectoryEntry.h" |
#include "V8FileEntry.h" |
+#include "WebBindings.h" |
#include "WebConsoleMessage.h" |
#include "WebDOMEvent.h" |
#include "WebDOMEventListener.h" |
@@ -108,6 +110,7 @@ |
#include "bindings/v8/ScriptSourceCode.h" |
#include "bindings/v8/ScriptValue.h" |
#include "bindings/v8/V8GCController.h" |
+#include "bindings/v8/V8NPUtils.h" |
#include "core/dom/Document.h" |
#include "core/dom/DocumentMarker.h" |
#include "core/dom/DocumentMarkerController.h" |
@@ -189,6 +192,7 @@ |
#include "public/platform/WebSize.h" |
#include "public/platform/WebURLError.h" |
#include "public/platform/WebVector.h" |
+#include "public/web/WebWindowPropertyCallback.h" |
#include "weborigin/KURL.h" |
#include "weborigin/SchemeRegistry.h" |
#include "weborigin/SecurityPolicy.h" |
@@ -753,6 +757,38 @@ void WebFrameImpl::bindToWindowObject(const WebString& name, NPObject* object, v |
frame()->script()->bindToWindowObject(frame(), String(name), object); |
} |
+namespace { |
+v8::Handle<v8::Value> windowPropertyGetter(v8::Local<v8::String> property, const v8::AccessorInfo& info) |
+{ |
+ v8::Local<v8::External> wrap = v8::Local<v8::External>::Cast(info.Data()); |
+ v8::Isolate* isolate = info.GetIsolate(); |
+ WebWindowPropertyCallback* callback = static_cast<WebWindowPropertyCallback*>(wrap->Value()); |
+ NPVariant variantValue; |
+ if (!callback->GetValue(&variantValue)) |
+ return v8::Undefined(); |
+ v8::Handle<v8::Value> v8Value = WebCore::convertNPVariantToV8Object(&variantValue, 0, isolate); |
+ WebBindings::releaseVariantValue(&variantValue); |
+ return v8Value; |
+} |
+ |
+void windowPropertySetter(v8::Local<v8::String> property, v8::Local<v8::Value> value, const v8::AccessorInfo& info) |
+{ |
+ v8::Local<v8::External> wrap = v8::Local<v8::External>::Cast(info.Data()); |
+ WebWindowPropertyCallback* callback = static_cast<WebWindowPropertyCallback*>(wrap->Value()); |
+ NPVariant variantValue; |
+ WebCore::convertV8ObjectToNPVariant(value, 0, &variantValue); |
+ callback->SetValue(variantValue); |
+ WebBindings::releaseVariantValue(&variantValue); |
+} |
+} // namespace |
+ |
+void WebFrameImpl::bindToWindowObject(const WebString& name, WebWindowPropertyCallback* callback) |
+{ |
+ if (!frame() || !frame()->script()->canExecuteScripts(NotAboutToExecuteScript)) |
+ return; |
+ frame()->script()->bindToWindowObject(frame(), String(name), windowPropertyGetter, windowPropertySetter, v8::External::New(callback)); |
+} |
+ |
void WebFrameImpl::executeScript(const WebScriptSource& source) |
{ |
ASSERT(frame()); |