Upstream version 9.37.197.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / bindings / v8 / BindingSecurity.cpp
index 59cc6b1..126b2ba 100644 (file)
 #include "bindings/v8/V8Binding.h"
 #include "core/dom/Document.h"
 #include "core/html/HTMLFrameElementBase.h"
-#include "core/frame/DOMWindow.h"
+#include "core/frame/LocalDOMWindow.h"
 #include "core/frame/LocalFrame.h"
 #include "core/frame/Settings.h"
 #include "platform/weborigin/SecurityOrigin.h"
 
 namespace WebCore {
 
-static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, DOMWindow* callingWindow)
+static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, LocalDOMWindow* callingWindow)
 {
     if (!targetDocument)
         return false;
@@ -57,7 +57,7 @@ static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, DOMWindo
 
 static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, ExceptionState& exceptionState)
 {
-    DOMWindow* callingWindow = callingDOMWindow(isolate);
+    LocalDOMWindow* callingWindow = callingDOMWindow(isolate);
     if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow))
         return true;
 
@@ -68,7 +68,7 @@ static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, Ex
 
 static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError)
 {
-    DOMWindow* callingWindow = callingDOMWindow(isolate);
+    LocalDOMWindow* callingWindow = callingDOMWindow(isolate);
     if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow))
         return true;
 
@@ -80,14 +80,18 @@ static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, Se
     return false;
 }
 
-bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, LocalFrame* target, SecurityReportingOption reportingOption)
+bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, SecurityReportingOption reportingOption)
 {
-    return target && canAccessDocument(isolate, target->document(), reportingOption);
+    if (!target || !target->isLocalFrame())
+        return false;
+    return canAccessDocument(isolate, toLocalFrame(target)->document(), reportingOption);
 }
 
-bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, LocalFrame* target, ExceptionState& exceptionState)
+bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, ExceptionState& exceptionState)
 {
-    return target && canAccessDocument(isolate, target->document(), exceptionState);
+    if (!target || !target->isLocalFrame())
+        return false;
+    return canAccessDocument(isolate, toLocalFrame(target)->document(), exceptionState);
 }
 
 bool BindingSecurity::shouldAllowAccessToNode(v8::Isolate* isolate, Node* target, ExceptionState& exceptionState)