| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 if (!activeWindow) | 49 if (!activeWindow) |
| 50 return false; | 50 return false; |
| 51 | 51 |
| 52 if (activeWindow->document()->securityOrigin()->canAccess(targetDocument->se
curityOrigin())) | 52 if (activeWindow->document()->securityOrigin()->canAccess(targetDocument->se
curityOrigin())) |
| 53 return true; | 53 return true; |
| 54 | 54 |
| 55 return false; | 55 return false; |
| 56 } | 56 } |
| 57 | 57 |
| 58 static bool canAccessDocument(Document* targetDocument, ExceptionState& es) | 58 static bool canAccessDocument(Document* targetDocument, ExceptionState& exceptio
nState) |
| 59 { | 59 { |
| 60 DOMWindow* activeWindow = activeDOMWindow(); | 60 DOMWindow* activeWindow = activeDOMWindow(); |
| 61 if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow)) | 61 if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow)) |
| 62 return true; | 62 return true; |
| 63 | 63 |
| 64 es.throwSecurityError(targetDocument->domWindow()->sanitizedCrossDomainAcces
sErrorMessage(activeWindow), targetDocument->domWindow()->crossDomainAccessError
Message(activeWindow)); | 64 exceptionState.throwSecurityError(targetDocument->domWindow()->sanitizedCros
sDomainAccessErrorMessage(activeWindow), targetDocument->domWindow()->crossDomai
nAccessErrorMessage(activeWindow)); |
| 65 return false; | 65 return false; |
| 66 } | 66 } |
| 67 | 67 |
| 68 static bool canAccessDocument(Document* targetDocument, SecurityReportingOption
reportingOption = ReportSecurityError) | 68 static bool canAccessDocument(Document* targetDocument, SecurityReportingOption
reportingOption = ReportSecurityError) |
| 69 { | 69 { |
| 70 DOMWindow* activeWindow = activeDOMWindow(); | 70 DOMWindow* activeWindow = activeDOMWindow(); |
| 71 if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow)) | 71 if (isDocumentAccessibleFromDOMWindow(targetDocument, activeWindow)) |
| 72 return true; | 72 return true; |
| 73 | 73 |
| 74 if (reportingOption == ReportSecurityError) { | 74 if (reportingOption == ReportSecurityError) { |
| 75 if (Frame* frame = targetDocument->frame()) | 75 if (Frame* frame = targetDocument->frame()) |
| 76 frame->domWindow()->printErrorMessage(targetDocument->domWindow()->c
rossDomainAccessErrorMessage(activeWindow)); | 76 frame->domWindow()->printErrorMessage(targetDocument->domWindow()->c
rossDomainAccessErrorMessage(activeWindow)); |
| 77 } | 77 } |
| 78 | 78 |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| 82 bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, SecurityReportingO
ption reportingOption) | 82 bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, SecurityReportingO
ption reportingOption) |
| 83 { | 83 { |
| 84 return target && canAccessDocument(target->document(), reportingOption); | 84 return target && canAccessDocument(target->document(), reportingOption); |
| 85 } | 85 } |
| 86 | 86 |
| 87 bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, ExceptionState& es
) | 87 bool BindingSecurity::shouldAllowAccessToFrame(Frame* target, ExceptionState& ex
ceptionState) |
| 88 { | 88 { |
| 89 return target && canAccessDocument(target->document(), es); | 89 return target && canAccessDocument(target->document(), exceptionState); |
| 90 } | 90 } |
| 91 | 91 |
| 92 bool BindingSecurity::shouldAllowAccessToNode(Node* target, ExceptionState& es) | 92 bool BindingSecurity::shouldAllowAccessToNode(Node* target, ExceptionState& exce
ptionState) |
| 93 { | 93 { |
| 94 return target && canAccessDocument(&target->document(), es); | 94 return target && canAccessDocument(&target->document(), exceptionState); |
| 95 } | 95 } |
| 96 | 96 |
| 97 } | 97 } |
| OLD | NEW |