| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 return; | 110 return; |
| 111 // If the context is different, we need to make sure that the current | 111 // If the context is different, we need to make sure that the current |
| 112 // context has access to the creation context. | 112 // context has access to the creation context. |
| 113 Frame* frame = toFrameIfNotDetached(contextForWrapper); | 113 Frame* frame = toFrameIfNotDetached(contextForWrapper); |
| 114 if (!frame) { | 114 if (!frame) { |
| 115 // Sandbox detached frames - they can't create cross origin objects. | 115 // Sandbox detached frames - they can't create cross origin objects. |
| 116 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); | 116 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); |
| 117 DOMWindow* targetWindow = toDOMWindow(contextForWrapper); | 117 DOMWindow* targetWindow = toDOMWindow(contextForWrapper); |
| 118 // TODO(jochen): Currently, Location is the only object for which we can | 118 // TODO(jochen): Currently, Location is the only object for which we can |
| 119 // reach this code path. Should be generalized. | 119 // reach this code path. Should be generalized. |
| 120 ExceptionState exceptionState(ExceptionState::ConstructionContext, | 120 ExceptionState exceptionState(isolate, ExceptionState::ConstructionContext, |
| 121 "Location", contextForWrapper->Global(), | 121 "Location"); |
| 122 isolate); | |
| 123 if (BindingSecurity::shouldAllowAccessToDetachedWindow( | 122 if (BindingSecurity::shouldAllowAccessToDetachedWindow( |
| 124 callingWindow, targetWindow, exceptionState)) | 123 callingWindow, targetWindow, exceptionState)) |
| 125 return; | 124 return; |
| 126 | 125 |
| 127 CHECK_EQ(SecurityError, exceptionState.code()); | 126 CHECK_EQ(SecurityError, exceptionState.code()); |
| 128 return; | 127 return; |
| 129 } | 128 } |
| 130 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context); | 129 const DOMWrapperWorld& currentWorld = DOMWrapperWorld::world(m_context); |
| 131 RELEASE_ASSERT(currentWorld.worldId() == | 130 RELEASE_ASSERT(currentWorld.worldId() == |
| 132 DOMWrapperWorld::world(contextForWrapper).worldId()); | 131 DOMWrapperWorld::world(contextForWrapper).worldId()); |
| 133 // TODO(jochen): Add the interface name here once this is generalized. | 132 // TODO(jochen): Add the interface name here once this is generalized. |
| 134 ExceptionState exceptionState(ExceptionState::ConstructionContext, nullptr, | 133 ExceptionState exceptionState(isolate, ExceptionState::ConstructionContext, |
| 135 contextForWrapper->Global(), isolate); | 134 nullptr); |
| 136 if (currentWorld.isMainWorld() && | 135 if (currentWorld.isMainWorld() && |
| 137 !BindingSecurity::shouldAllowAccessToFrame(currentDOMWindow(isolate), | 136 !BindingSecurity::shouldAllowAccessToFrame(currentDOMWindow(isolate), |
| 138 frame, exceptionState)) { | 137 frame, exceptionState)) { |
| 139 CHECK_EQ(SecurityError, exceptionState.code()); | 138 CHECK_EQ(SecurityError, exceptionState.code()); |
| 140 return; | 139 return; |
| 141 } | 140 } |
| 142 } | 141 } |
| 143 | 142 |
| 144 void V8WrapperInstantiationScope::convertException() { | 143 void V8WrapperInstantiationScope::convertException() { |
| 145 v8::Isolate* isolate = m_context->GetIsolate(); | 144 v8::Isolate* isolate = m_context->GetIsolate(); |
| 146 // TODO(jochen): Currently, Location is the only object for which we can reach | 145 // TODO(jochen): Currently, Location is the only object for which we can reach |
| 147 // this code path. Should be generalized. | 146 // this code path. Should be generalized. |
| 148 ExceptionState exceptionState(ExceptionState::ConstructionContext, "Location", | 147 ExceptionState exceptionState(isolate, ExceptionState::ConstructionContext, |
| 149 isolate->GetCurrentContext()->Global(), | 148 "Location"); |
| 150 isolate); | |
| 151 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); | 149 LocalDOMWindow* callingWindow = currentDOMWindow(isolate); |
| 152 DOMWindow* targetWindow = toDOMWindow(m_context); | 150 DOMWindow* targetWindow = toDOMWindow(m_context); |
| 153 exceptionState.throwSecurityError( | 151 exceptionState.throwSecurityError( |
| 154 targetWindow->sanitizedCrossDomainAccessErrorMessage(callingWindow), | 152 targetWindow->sanitizedCrossDomainAccessErrorMessage(callingWindow), |
| 155 targetWindow->crossDomainAccessErrorMessage(callingWindow)); | 153 targetWindow->crossDomainAccessErrorMessage(callingWindow)); |
| 156 } | 154 } |
| 157 | 155 |
| 158 } // namespace blink | 156 } // namespace blink |
| OLD | NEW |