Index: Source/bindings/core/v8/BindingSecurity.cpp |
diff --git a/Source/bindings/core/v8/BindingSecurity.cpp b/Source/bindings/core/v8/BindingSecurity.cpp |
index 3f9c7eeae381754d04ed17c45ca0fd4befb6945d..6cf718f525d152abe43584f5d8645001c4fc288e 100644 |
--- a/Source/bindings/core/v8/BindingSecurity.cpp |
+++ b/Source/bindings/core/v8/BindingSecurity.cpp |
@@ -41,60 +41,50 @@ |
namespace blink { |
-static bool isDocumentAccessibleFromDOMWindow(Document* targetDocument, LocalDOMWindow* callingWindow) |
+static bool isOriginAccessibleFromDOMWindow(SecurityOrigin* targetOrigin, LocalDOMWindow* callingWindow) |
{ |
- if (!targetDocument) |
- return false; |
- |
- if (!callingWindow) |
- return false; |
- |
- if (callingWindow->document()->securityOrigin()->canAccess(targetDocument->securityOrigin())) |
- return true; |
- |
- return false; |
+ return callingWindow && callingWindow->document()->securityOrigin()->canAccess(targetOrigin); |
} |
-static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, ExceptionState& exceptionState) |
+static bool canAccessFrame(v8::Isolate* isolate, SecurityOrigin* targetFrameOrigin, DOMWindow* targetWindow, ExceptionState& exceptionState) |
{ |
LocalDOMWindow* callingWindow = callingDOMWindow(isolate); |
- if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow)) |
+ if (isOriginAccessibleFromDOMWindow(targetFrameOrigin, callingWindow)) |
return true; |
- if (targetDocument->domWindow()) |
- exceptionState.throwSecurityError(targetDocument->domWindow()->sanitizedCrossDomainAccessErrorMessage(callingWindow), targetDocument->domWindow()->crossDomainAccessErrorMessage(callingWindow)); |
+ if (targetWindow) |
+ exceptionState.throwSecurityError(targetWindow->sanitizedCrossDomainAccessErrorMessage(callingWindow), targetWindow->crossDomainAccessErrorMessage(callingWindow)); |
return false; |
} |
-static bool canAccessDocument(v8::Isolate* isolate, Document* targetDocument, SecurityReportingOption reportingOption = ReportSecurityError) |
+static bool canAccessFrame(v8::Isolate* isolate, SecurityOrigin* targetFrameOrigin, DOMWindow* targetWindow, SecurityReportingOption reportingOption = ReportSecurityError) |
{ |
LocalDOMWindow* callingWindow = callingDOMWindow(isolate); |
- if (isDocumentAccessibleFromDOMWindow(targetDocument, callingWindow)) |
+ if (isOriginAccessibleFromDOMWindow(targetFrameOrigin, callingWindow)) |
return true; |
- if (reportingOption == ReportSecurityError && targetDocument->domWindow()) |
- callingWindow->printErrorMessage(targetDocument->domWindow()->crossDomainAccessErrorMessage(callingWindow)); |
- |
+ if (reportingOption == ReportSecurityError && targetWindow) |
+ callingWindow->printErrorMessage(targetWindow->crossDomainAccessErrorMessage(callingWindow)); |
return false; |
} |
bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, SecurityReportingOption reportingOption) |
{ |
- if (!target || !target->isLocalFrame()) |
+ if (!target || !target->securityContext()) |
return false; |
- return canAccessDocument(isolate, toLocalFrame(target)->document(), reportingOption); |
+ return canAccessFrame(isolate, target->securityContext()->securityOrigin(), target->domWindow(), reportingOption); |
} |
bool BindingSecurity::shouldAllowAccessToFrame(v8::Isolate* isolate, Frame* target, ExceptionState& exceptionState) |
{ |
- if (!target || !target->isLocalFrame()) |
+ if (!target || !target->securityContext()) |
return false; |
- return canAccessDocument(isolate, toLocalFrame(target)->document(), exceptionState); |
+ return canAccessFrame(isolate, target->securityContext()->securityOrigin(), target->domWindow(), exceptionState); |
} |
bool BindingSecurity::shouldAllowAccessToNode(v8::Isolate* isolate, Node* target, ExceptionState& exceptionState) |
{ |
- return target && canAccessDocument(isolate, &target->document(), exceptionState); |
+ return target && canAccessFrame(isolate, target->document().securityOrigin(), target->document().domWindow(), exceptionState); |
dcheng
2015/04/23 17:39:57
Would it make sense to have canAccessFrame() take
alexmos
2015/04/23 17:45:28
That was the first thing I tried, and unfortunatel
dcheng
2015/04/23 18:01:24
Do we actually return a true value in that case? O
alexmos
2015/04/23 21:25:23
That particular test returns false - I think it ha
|
} |
} |