| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2009, 2011 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "bindings/v8/V8GCForContextDispose.h" | 46 #include "bindings/v8/V8GCForContextDispose.h" |
| 47 #include "bindings/v8/V8HiddenValue.h" | 47 #include "bindings/v8/V8HiddenValue.h" |
| 48 #include "core/dom/ExceptionCode.h" | 48 #include "core/dom/ExceptionCode.h" |
| 49 #include "core/dom/MessagePort.h" | 49 #include "core/dom/MessagePort.h" |
| 50 #include "core/html/HTMLCollection.h" | 50 #include "core/html/HTMLCollection.h" |
| 51 #include "core/html/HTMLDocument.h" | 51 #include "core/html/HTMLDocument.h" |
| 52 #include "core/inspector/ScriptCallStack.h" | 52 #include "core/inspector/ScriptCallStack.h" |
| 53 #include "core/loader/FrameLoadRequest.h" | 53 #include "core/loader/FrameLoadRequest.h" |
| 54 #include "core/loader/FrameLoader.h" | 54 #include "core/loader/FrameLoader.h" |
| 55 #include "core/frame/DOMTimer.h" | 55 #include "core/frame/DOMTimer.h" |
| 56 #include "core/frame/DOMWindow.h" | 56 #include "core/frame/LocalDOMWindow.h" |
| 57 #include "core/frame/DOMWindowTimers.h" | 57 #include "core/frame/DOMWindowTimers.h" |
| 58 #include "core/frame/FrameView.h" | 58 #include "core/frame/FrameView.h" |
| 59 #include "core/frame/LocalFrame.h" | 59 #include "core/frame/LocalFrame.h" |
| 60 #include "core/frame/Settings.h" | 60 #include "core/frame/Settings.h" |
| 61 #include "core/frame/csp/ContentSecurityPolicy.h" | 61 #include "core/frame/csp/ContentSecurityPolicy.h" |
| 62 #include "core/storage/Storage.h" | 62 #include "core/storage/Storage.h" |
| 63 #include "platform/PlatformScreen.h" | 63 #include "platform/PlatformScreen.h" |
| 64 #include "platform/graphics/media/MediaPlayer.h" | 64 #include "platform/graphics/media/MediaPlayer.h" |
| 65 #include "wtf/ArrayBuffer.h" | 65 #include "wtf/ArrayBuffer.h" |
| 66 #include "wtf/Assertions.h" | 66 #include "wtf/Assertions.h" |
| 67 #include "wtf/OwnPtr.h" | 67 #include "wtf/OwnPtr.h" |
| 68 | 68 |
| 69 namespace WebCore { | 69 namespace WebCore { |
| 70 | 70 |
| 71 // FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerG
lobalScopeCustom.cpp. | 71 // FIXME: There is a lot of duplication with SetTimeoutOrInterval() in V8WorkerG
lobalScopeCustom.cpp. |
| 72 // We should refactor this. | 72 // We should refactor this. |
| 73 static void windowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info
, bool singleShot, ExceptionState& exceptionState) | 73 static void windowSetTimeoutImpl(const v8::FunctionCallbackInfo<v8::Value>& info
, bool singleShot, ExceptionState& exceptionState) |
| 74 { | 74 { |
| 75 int argumentCount = info.Length(); | 75 int argumentCount = info.Length(); |
| 76 | 76 |
| 77 if (argumentCount < 1) | 77 if (argumentCount < 1) |
| 78 return; | 78 return; |
| 79 | 79 |
| 80 DOMWindow* impl = V8Window::toNative(info.Holder()); | 80 LocalDOMWindow* impl = V8Window::toNative(info.Holder()); |
| 81 if (!impl->frame() || !impl->document()) { | 81 if (!impl->frame() || !impl->document()) { |
| 82 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); | 82 exceptionState.throwDOMException(InvalidAccessError, "No script context
is available in which to execute the script."); |
| 83 return; | 83 return; |
| 84 } | 84 } |
| 85 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); | 85 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); |
| 86 v8::Handle<v8::Value> function = info[0]; | 86 v8::Handle<v8::Value> function = info[0]; |
| 87 String functionString; | 87 String functionString; |
| 88 if (!function->IsFunction()) { | 88 if (!function->IsFunction()) { |
| 89 if (function->IsString()) { | 89 if (function->IsString()) { |
| 90 functionString = toCoreString(function.As<v8::String>()); | 90 functionString = toCoreString(function.As<v8::String>()); |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { | 170 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), frame, exc
eptionState)) { |
| 171 exceptionState.throwIfNeeded(); | 171 exceptionState.throwIfNeeded(); |
| 172 return; | 172 return; |
| 173 } | 173 } |
| 174 | 174 |
| 175 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder()->CreationCont
ext()->Global(), V8HiddenValue::event(info.GetIsolate()), value); | 175 V8HiddenValue::setHiddenValue(info.GetIsolate(), info.Holder()->CreationCont
ext()->Global(), V8HiddenValue::event(info.GetIsolate()), value); |
| 176 } | 176 } |
| 177 | 177 |
| 178 void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<
v8::Value>& info) | 178 void V8Window::frameElementAttributeGetterCustom(const v8::PropertyCallbackInfo<
v8::Value>& info) |
| 179 { | 179 { |
| 180 DOMWindow* impl = V8Window::toNative(info.Holder()); | 180 LocalDOMWindow* impl = V8Window::toNative(info.Holder()); |
| 181 ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Windo
w", info.Holder(), info.GetIsolate()); | 181 ExceptionState exceptionState(ExceptionState::GetterContext, "frame", "Windo
w", info.Holder(), info.GetIsolate()); |
| 182 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->frame
Element(), exceptionState)) { | 182 if (!BindingSecurity::shouldAllowAccessToNode(info.GetIsolate(), impl->frame
Element(), exceptionState)) { |
| 183 v8SetReturnValueNull(info); | 183 v8SetReturnValueNull(info); |
| 184 exceptionState.throwIfNeeded(); | 184 exceptionState.throwIfNeeded(); |
| 185 return; | 185 return; |
| 186 } | 186 } |
| 187 | 187 |
| 188 // The wrapper for an <iframe> should get its prototype from the context of
the frame it's in, rather than its own frame. | 188 // The wrapper for an <iframe> should get its prototype from the context of
the frame it's in, rather than its own frame. |
| 189 // So, use its containing document as the creation context when wrapping. | 189 // So, use its containing document as the creation context when wrapping. |
| 190 v8::Handle<v8::Value> creationContext = toV8(&impl->frameElement()->document
(), info.Holder(), info.GetIsolate()); | 190 v8::Handle<v8::Value> creationContext = toV8(&impl->frameElement()->document
(), info.Holder(), info.GetIsolate()); |
| 191 RELEASE_ASSERT(!creationContext.IsEmpty()); | 191 RELEASE_ASSERT(!creationContext.IsEmpty()); |
| 192 v8::Handle<v8::Value> wrapper = toV8(impl->frameElement(), v8::Handle<v8::Ob
ject>::Cast(creationContext), info.GetIsolate()); | 192 v8::Handle<v8::Value> wrapper = toV8(impl->frameElement(), v8::Handle<v8::Ob
ject>::Cast(creationContext), info.GetIsolate()); |
| 193 v8SetReturnValue(info, wrapper); | 193 v8SetReturnValue(info, wrapper); |
| 194 } | 194 } |
| 195 | 195 |
| 196 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) | 196 void V8Window::openerAttributeSetterCustom(v8::Local<v8::Value> value, const v8:
:PropertyCallbackInfo<void>& info) |
| 197 { | 197 { |
| 198 DOMWindow* impl = V8Window::toNative(info.Holder()); | 198 LocalDOMWindow* impl = V8Window::toNative(info.Holder()); |
| 199 ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Wind
ow", info.Holder(), info.GetIsolate()); | 199 ExceptionState exceptionState(ExceptionState::SetterContext, "opener", "Wind
ow", info.Holder(), info.GetIsolate()); |
| 200 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 200 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 201 exceptionState.throwIfNeeded(); | 201 exceptionState.throwIfNeeded(); |
| 202 return; | 202 return; |
| 203 } | 203 } |
| 204 | 204 |
| 205 // Opener can be shadowed if it is in the same domain. | 205 // Opener can be shadowed if it is in the same domain. |
| 206 // Have a special handling of null value to behave | 206 // Have a special handling of null value to behave |
| 207 // like Firefox. See bug http://b/1224887 & http://b/791706. | 207 // like Firefox. See bug http://b/1224887 & http://b/791706. |
| 208 if (value->IsNull()) { | 208 if (value->IsNull()) { |
| (...skipping 16 matching lines...) Expand all Loading... |
| 225 if (value->IsString() || value->IsStringObject()) | 225 if (value->IsString() || value->IsStringObject()) |
| 226 return true; | 226 return true; |
| 227 return false; | 227 return false; |
| 228 } | 228 } |
| 229 | 229 |
| 230 | 230 |
| 231 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) | 231 void V8Window::postMessageMethodCustom(const v8::FunctionCallbackInfo<v8::Value>
& info) |
| 232 { | 232 { |
| 233 // None of these need to be RefPtr because info and context are guaranteed | 233 // None of these need to be RefPtr because info and context are guaranteed |
| 234 // to hold on to them. | 234 // to hold on to them. |
| 235 DOMWindow* window = V8Window::toNative(info.Holder()); | 235 LocalDOMWindow* window = V8Window::toNative(info.Holder()); |
| 236 DOMWindow* source = callingDOMWindow(info.GetIsolate()); | 236 LocalDOMWindow* source = callingDOMWindow(info.GetIsolate()); |
| 237 | 237 |
| 238 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); | 238 ExceptionState exceptionState(ExceptionState::ExecutionContext, "postMessage
", "Window", info.Holder(), info.GetIsolate()); |
| 239 | 239 |
| 240 // If called directly by WebCore we don't have a calling context. | 240 // If called directly by WebCore we don't have a calling context. |
| 241 if (!source) { | 241 if (!source) { |
| 242 exceptionState.throwTypeError("No active calling context exists."); | 242 exceptionState.throwTypeError("No active calling context exists."); |
| 243 exceptionState.throwIfNeeded(); | 243 exceptionState.throwIfNeeded(); |
| 244 return; | 244 return; |
| 245 } | 245 } |
| 246 | 246 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 289 } | 289 } |
| 290 | 290 |
| 291 class DialogHandler { | 291 class DialogHandler { |
| 292 public: | 292 public: |
| 293 explicit DialogHandler(v8::Handle<v8::Value> dialogArguments, ScriptState* s
criptState) | 293 explicit DialogHandler(v8::Handle<v8::Value> dialogArguments, ScriptState* s
criptState) |
| 294 : m_scriptState(scriptState) | 294 : m_scriptState(scriptState) |
| 295 , m_dialogArguments(dialogArguments) | 295 , m_dialogArguments(dialogArguments) |
| 296 { | 296 { |
| 297 } | 297 } |
| 298 | 298 |
| 299 void dialogCreated(DOMWindow*); | 299 void dialogCreated(LocalDOMWindow*); |
| 300 v8::Handle<v8::Value> returnValue() const; | 300 v8::Handle<v8::Value> returnValue() const; |
| 301 | 301 |
| 302 private: | 302 private: |
| 303 RefPtr<ScriptState> m_scriptState; | 303 RefPtr<ScriptState> m_scriptState; |
| 304 RefPtr<ScriptState> m_scriptStateForDialogFrame; | 304 RefPtr<ScriptState> m_scriptStateForDialogFrame; |
| 305 v8::Handle<v8::Value> m_dialogArguments; | 305 v8::Handle<v8::Value> m_dialogArguments; |
| 306 }; | 306 }; |
| 307 | 307 |
| 308 void DialogHandler::dialogCreated(DOMWindow* dialogFrame) | 308 void DialogHandler::dialogCreated(LocalDOMWindow* dialogFrame) |
| 309 { | 309 { |
| 310 if (m_dialogArguments.IsEmpty()) | 310 if (m_dialogArguments.IsEmpty()) |
| 311 return; | 311 return; |
| 312 v8::Handle<v8::Context> context = toV8Context(dialogFrame->frame(), m_script
State->world()); | 312 v8::Handle<v8::Context> context = toV8Context(dialogFrame->frame(), m_script
State->world()); |
| 313 if (context.IsEmpty()) | 313 if (context.IsEmpty()) |
| 314 return; | 314 return; |
| 315 m_scriptStateForDialogFrame = ScriptState::from(context); | 315 m_scriptStateForDialogFrame = ScriptState::from(context); |
| 316 | 316 |
| 317 ScriptState::Scope scope(m_scriptStateForDialogFrame.get()); | 317 ScriptState::Scope scope(m_scriptStateForDialogFrame.get()); |
| 318 m_scriptStateForDialogFrame->context()->Global()->Set(v8AtomicString(m_scrip
tState->isolate(), "dialogArguments"), m_dialogArguments); | 318 m_scriptStateForDialogFrame->context()->Global()->Set(v8AtomicString(m_scrip
tState->isolate(), "dialogArguments"), m_dialogArguments); |
| 319 } | 319 } |
| 320 | 320 |
| 321 v8::Handle<v8::Value> DialogHandler::returnValue() const | 321 v8::Handle<v8::Value> DialogHandler::returnValue() const |
| 322 { | 322 { |
| 323 if (!m_scriptStateForDialogFrame) | 323 if (!m_scriptStateForDialogFrame) |
| 324 return v8Undefined(); | 324 return v8Undefined(); |
| 325 ASSERT(!m_scriptStateForDialogFrame->contextIsEmpty()); | 325 ASSERT(!m_scriptStateForDialogFrame->contextIsEmpty()); |
| 326 | 326 |
| 327 v8::Isolate* isolate = m_scriptStateForDialogFrame->isolate(); | 327 v8::Isolate* isolate = m_scriptStateForDialogFrame->isolate(); |
| 328 v8::EscapableHandleScope handleScope(isolate); | 328 v8::EscapableHandleScope handleScope(isolate); |
| 329 ScriptState::Scope scope(m_scriptStateForDialogFrame.get()); | 329 ScriptState::Scope scope(m_scriptStateForDialogFrame.get()); |
| 330 v8::Local<v8::Value> returnValue = m_scriptStateForDialogFrame->context()->G
lobal()->Get(v8AtomicString(isolate, "returnValue")); | 330 v8::Local<v8::Value> returnValue = m_scriptStateForDialogFrame->context()->G
lobal()->Get(v8AtomicString(isolate, "returnValue")); |
| 331 if (returnValue.IsEmpty()) | 331 if (returnValue.IsEmpty()) |
| 332 return v8Undefined(); | 332 return v8Undefined(); |
| 333 return handleScope.Escape(returnValue); | 333 return handleScope.Escape(returnValue); |
| 334 } | 334 } |
| 335 | 335 |
| 336 static void setUpDialog(DOMWindow* dialog, void* handler) | 336 static void setUpDialog(LocalDOMWindow* dialog, void* handler) |
| 337 { | 337 { |
| 338 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); | 338 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); |
| 339 } | 339 } |
| 340 | 340 |
| 341 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | 341 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) |
| 342 { | 342 { |
| 343 DOMWindow* impl = V8Window::toNative(info.Holder()); | 343 LocalDOMWindow* impl = V8Window::toNative(info.Holder()); |
| 344 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); | 344 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); |
| 345 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 345 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 346 exceptionState.throwIfNeeded(); | 346 exceptionState.throwIfNeeded(); |
| 347 return; | 347 return; |
| 348 } | 348 } |
| 349 | 349 |
| 350 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, urlString, info[0]
); | 350 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, urlString, info[0]
); |
| 351 DialogHandler handler(info[1], ScriptState::current(info.GetIsolate())); | 351 DialogHandler handler(info[1], ScriptState::current(info.GetIsolate())); |
| 352 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, dialogFeaturesStri
ng, info[2]); | 352 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, dialogFeaturesStri
ng, info[2]); |
| 353 | 353 |
| 354 impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info
.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); | 354 impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info
.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); |
| 355 | 355 |
| 356 v8SetReturnValue(info, handler.returnValue()); | 356 v8SetReturnValue(info, handler.returnValue()); |
| 357 } | 357 } |
| 358 | 358 |
| 359 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 359 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
| 360 { | 360 { |
| 361 DOMWindow* impl = V8Window::toNative(info.Holder()); | 361 LocalDOMWindow* impl = V8Window::toNative(info.Holder()); |
| 362 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); | 362 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); |
| 363 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 363 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
| 364 exceptionState.throwIfNeeded(); | 364 exceptionState.throwIfNeeded(); |
| 365 return; | 365 return; |
| 366 } | 366 } |
| 367 | 367 |
| 368 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, urlString, info[0]
); | 368 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, urlString, info[0]
); |
| 369 AtomicString frameName; | 369 AtomicString frameName; |
| 370 if (info[1]->IsUndefined() || info[1]->IsNull()) { | 370 if (info[1]->IsUndefined() || info[1]->IsNull()) { |
| 371 frameName = "_blank"; | 371 frameName = "_blank"; |
| 372 } else { | 372 } else { |
| 373 TOSTRING_VOID(V8StringResource<>, frameNameResource, info[1]); | 373 TOSTRING_VOID(V8StringResource<>, frameNameResource, info[1]); |
| 374 frameName = frameNameResource; | 374 frameName = frameNameResource; |
| 375 } | 375 } |
| 376 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, windowFeaturesStri
ng, info[2]); | 376 TOSTRING_VOID(V8StringResource<WithUndefinedOrNullCheck>, windowFeaturesStri
ng, info[2]); |
| 377 | 377 |
| 378 RefPtrWillBeRawPtr<DOMWindow> openedWindow = impl->open(urlString, frameName
, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWindow(in
fo.GetIsolate())); | 378 RefPtrWillBeRawPtr<LocalDOMWindow> openedWindow = impl->open(urlString, fram
eName, windowFeaturesString, callingDOMWindow(info.GetIsolate()), enteredDOMWind
ow(info.GetIsolate())); |
| 379 if (!openedWindow) | 379 if (!openedWindow) |
| 380 return; | 380 return; |
| 381 | 381 |
| 382 v8SetReturnValueFast(info, openedWindow.release(), impl); | 382 v8SetReturnValueFast(info, openedWindow.release(), impl); |
| 383 } | 383 } |
| 384 | 384 |
| 385 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Value>& info) | 385 void V8Window::namedPropertyGetterCustom(v8::Local<v8::String> name, const v8::P
ropertyCallbackInfo<v8::Value>& info) |
| 386 { | 386 { |
| 387 | 387 |
| 388 DOMWindow* window = V8Window::toNative(info.Holder()); | 388 LocalDOMWindow* window = V8Window::toNative(info.Holder()); |
| 389 if (!window) | 389 if (!window) |
| 390 return; | 390 return; |
| 391 | 391 |
| 392 LocalFrame* frame = window->frame(); | 392 LocalFrame* frame = window->frame(); |
| 393 // window is detached from a frame. | 393 // window is detached from a frame. |
| 394 if (!frame) | 394 if (!frame) |
| 395 return; | 395 return; |
| 396 | 396 |
| 397 // Search sub-frames. | 397 // Search sub-frames. |
| 398 AtomicString propName = toCoreAtomicString(name); | 398 AtomicString propName = toCoreAtomicString(name); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 440 exceptionState.throwIfNeeded(); | 440 exceptionState.throwIfNeeded(); |
| 441 } | 441 } |
| 442 | 442 |
| 443 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) | 443 bool V8Window::namedSecurityCheckCustom(v8::Local<v8::Object> host, v8::Local<v8
::Value> key, v8::AccessType type, v8::Local<v8::Value>) |
| 444 { | 444 { |
| 445 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 445 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 446 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); | 446 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); |
| 447 if (window.IsEmpty()) | 447 if (window.IsEmpty()) |
| 448 return false; // the frame is gone. | 448 return false; // the frame is gone. |
| 449 | 449 |
| 450 DOMWindow* targetWindow = V8Window::toNative(window); | 450 LocalDOMWindow* targetWindow = V8Window::toNative(window); |
| 451 | 451 |
| 452 ASSERT(targetWindow); | 452 ASSERT(targetWindow); |
| 453 | 453 |
| 454 LocalFrame* target = targetWindow->frame(); | 454 LocalFrame* target = targetWindow->frame(); |
| 455 if (!target) | 455 if (!target) |
| 456 return false; | 456 return false; |
| 457 | 457 |
| 458 // Notify the loader's client if the initial document has been accessed. | 458 // Notify the loader's client if the initial document has been accessed. |
| 459 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 459 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 460 target->loader().didAccessInitialDocument(); | 460 target->loader().didAccessInitialDocument(); |
| (...skipping 22 matching lines...) Expand all Loading... |
| 483 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); | 483 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); |
| 484 } | 484 } |
| 485 | 485 |
| 486 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i
ndex, v8::AccessType type, v8::Local<v8::Value>) | 486 bool V8Window::indexedSecurityCheckCustom(v8::Local<v8::Object> host, uint32_t i
ndex, v8::AccessType type, v8::Local<v8::Value>) |
| 487 { | 487 { |
| 488 v8::Isolate* isolate = v8::Isolate::GetCurrent(); | 488 v8::Isolate* isolate = v8::Isolate::GetCurrent(); |
| 489 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); | 489 v8::Handle<v8::Object> window = V8Window::findInstanceInPrototypeChain(host,
isolate); |
| 490 if (window.IsEmpty()) | 490 if (window.IsEmpty()) |
| 491 return false; | 491 return false; |
| 492 | 492 |
| 493 DOMWindow* targetWindow = V8Window::toNative(window); | 493 LocalDOMWindow* targetWindow = V8Window::toNative(window); |
| 494 | 494 |
| 495 ASSERT(targetWindow); | 495 ASSERT(targetWindow); |
| 496 | 496 |
| 497 LocalFrame* target = targetWindow->frame(); | 497 LocalFrame* target = targetWindow->frame(); |
| 498 if (!target) | 498 if (!target) |
| 499 return false; | 499 return false; |
| 500 | 500 |
| 501 // Notify the loader's client if the initial document has been accessed. | 501 // Notify the loader's client if the initial document has been accessed. |
| 502 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) | 502 if (target->loader().stateMachine()->isDisplayingInitialEmptyDocument()) |
| 503 target->loader().didAccessInitialDocument(); | 503 target->loader().didAccessInitialDocument(); |
| 504 | 504 |
| 505 Frame* childFrame = target->tree().scopedChild(index); | 505 Frame* childFrame = target->tree().scopedChild(index); |
| 506 | 506 |
| 507 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS | 507 // Notice that we can't call HasRealNamedProperty for ACCESS_HAS |
| 508 // because that would generate infinite recursion. | 508 // because that would generate infinite recursion. |
| 509 if (type == v8::ACCESS_HAS && childFrame) | 509 if (type == v8::ACCESS_HAS && childFrame) |
| 510 return true; | 510 return true; |
| 511 if (type == v8::ACCESS_GET | 511 if (type == v8::ACCESS_GET |
| 512 && childFrame | 512 && childFrame |
| 513 && !host->HasRealIndexedProperty(index) | 513 && !host->HasRealIndexedProperty(index) |
| 514 && !window->HasRealIndexedProperty(index)) | 514 && !window->HasRealIndexedProperty(index)) |
| 515 return true; | 515 return true; |
| 516 | 516 |
| 517 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); | 517 return BindingSecurity::shouldAllowAccessToFrame(isolate, target, DoNotRepor
tSecurityError); |
| 518 } | 518 } |
| 519 | 519 |
| 520 v8::Handle<v8::Value> toV8(DOMWindow* window, v8::Handle<v8::Object> creationCon
text, v8::Isolate* isolate) | 520 v8::Handle<v8::Value> toV8(LocalDOMWindow* window, v8::Handle<v8::Object> creati
onContext, v8::Isolate* isolate) |
| 521 { | 521 { |
| 522 // Notice that we explicitly ignore creationContext because the DOMWindow is
its own creationContext. | 522 // Notice that we explicitly ignore creationContext because the LocalDOMWind
ow is its own creationContext. |
| 523 | 523 |
| 524 if (!window) | 524 if (!window) |
| 525 return v8::Null(isolate); | 525 return v8::Null(isolate); |
| 526 // Initializes environment of a frame, and return the global object | 526 // Initializes environment of a frame, and return the global object |
| 527 // of the frame. | 527 // of the frame. |
| 528 LocalFrame* frame = window->frame(); | 528 LocalFrame* frame = window->frame(); |
| 529 if (!frame) | 529 if (!frame) |
| 530 return v8Undefined(); | 530 return v8Undefined(); |
| 531 | 531 |
| 532 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); | 532 v8::Handle<v8::Context> context = toV8Context(frame, DOMWrapperWorld::curren
t(isolate)); |
| 533 if (context.IsEmpty()) | 533 if (context.IsEmpty()) |
| 534 return v8Undefined(); | 534 return v8Undefined(); |
| 535 | 535 |
| 536 v8::Handle<v8::Object> global = context->Global(); | 536 v8::Handle<v8::Object> global = context->Global(); |
| 537 ASSERT(!global.IsEmpty()); | 537 ASSERT(!global.IsEmpty()); |
| 538 return global; | 538 return global; |
| 539 } | 539 } |
| 540 | 540 |
| 541 } // namespace WebCore | 541 } // namespace WebCore |
| OLD | NEW |