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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
295 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) | 295 void V8Window::toStringMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& i
nfo) |
296 { | 296 { |
297 v8::Handle<v8::Object> domWrapper = info.This()->FindInstanceInPrototypeChai
n(V8Window::domTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate
()))); | 297 v8::Handle<v8::Object> domWrapper = info.This()->FindInstanceInPrototypeChai
n(V8Window::domTemplate(info.GetIsolate(), worldTypeInMainThread(info.GetIsolate
()))); |
298 if (domWrapper.IsEmpty()) { | 298 if (domWrapper.IsEmpty()) { |
299 v8SetReturnValue(info, info.This()->ObjectProtoToString()); | 299 v8SetReturnValue(info, info.This()->ObjectProtoToString()); |
300 return; | 300 return; |
301 } | 301 } |
302 v8SetReturnValue(info, domWrapper->ObjectProtoToString()); | 302 v8SetReturnValue(info, domWrapper->ObjectProtoToString()); |
303 } | 303 } |
304 | 304 |
305 class DialogHandler { | |
306 public: | |
307 explicit DialogHandler(v8::Handle<v8::Value> dialogArguments) | |
308 : m_dialogArguments(dialogArguments) | |
309 { | |
310 } | |
311 | |
312 void dialogCreated(DOMWindow*, v8::Isolate*); | |
313 v8::Handle<v8::Value> returnValue(v8::Isolate*) const; | |
314 | |
315 private: | |
316 v8::Handle<v8::Value> m_dialogArguments; | |
317 v8::Handle<v8::Context> m_dialogContext; | |
318 }; | |
319 | |
320 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame, v8::Isolate* is
olate) | |
321 { | |
322 // FIXME: It's wrong to use the current world. Instead we should use the wor
ld | |
323 // from which the modal dialog was requested. | |
324 m_dialogContext = dialogFrame->frame() ? toV8Context(isolate, dialogFrame->f
rame(), DOMWrapperWorld::current(isolate)) : v8::Local<v8::Context>(); | |
325 if (m_dialogContext.IsEmpty()) | |
326 return; | |
327 if (m_dialogArguments.IsEmpty()) | |
328 return; | |
329 v8::Context::Scope scope(m_dialogContext); | |
330 m_dialogContext->Global()->Set(v8AtomicString(isolate, "dialogArguments"), m
_dialogArguments); | |
331 } | |
332 | |
333 inline v8::Handle<v8::Value> DialogHandler::returnValue(v8::Isolate* isolate) co
nst | |
334 { | |
335 if (m_dialogContext.IsEmpty()) | |
336 return v8::Undefined(isolate); | |
337 v8::Context::Scope scope(m_dialogContext); | |
338 v8::Handle<v8::Value> returnValue = m_dialogContext->Global()->Get(v8AtomicS
tring(isolate, "returnValue")); | |
339 if (returnValue.IsEmpty()) | |
340 return v8::Undefined(isolate); | |
341 return returnValue; | |
342 } | |
343 | |
344 static void setUpDialog(DOMWindow* dialog, void* handler) | |
345 { | |
346 static_cast<DialogHandler*>(handler)->dialogCreated(dialog, v8::Isolate::Get
Current()); | |
347 } | |
348 | |
349 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va
lue>& info) | |
350 { | |
351 DOMWindow* impl = V8Window::toNative(info.Holder()); | |
352 ExceptionState exceptionState(ExceptionState::ExecutionContext, "showModalDi
alog", "Window", info.Holder(), info.GetIsolate()); | |
353 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | |
354 exceptionState.throwIfNeeded(); | |
355 return; | |
356 } | |
357 | |
358 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, urlString, info[0]); | |
359 DialogHandler handler(info[1]); | |
360 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, dialogFeaturesString, info[2]); | |
361 | |
362 impl->showModalDialog(urlString, dialogFeaturesString, callingDOMWindow(info
.GetIsolate()), enteredDOMWindow(info.GetIsolate()), setUpDialog, &handler); | |
363 | |
364 v8SetReturnValue(info, handler.returnValue(info.GetIsolate())); | |
365 } | |
366 | |
367 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) | 305 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& info) |
368 { | 306 { |
369 DOMWindow* impl = V8Window::toNative(info.Holder()); | 307 DOMWindow* impl = V8Window::toNative(info.Holder()); |
370 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); | 308 ExceptionState exceptionState(ExceptionState::ExecutionContext, "open", "Win
dow", info.Holder(), info.GetIsolate()); |
371 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { | 309 if (!BindingSecurity::shouldAllowAccessToFrame(info.GetIsolate(), impl->fram
e(), exceptionState)) { |
372 exceptionState.throwIfNeeded(); | 310 exceptionState.throwIfNeeded(); |
373 return; | 311 return; |
374 } | 312 } |
375 | 313 |
376 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, urlString, info[0]); | 314 V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithUndefinedOrNullChe
ck>, urlString, info[0]); |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 v8::Handle<v8::Context> context = toV8Context(isolate, frame, DOMWrapperWorl
d::current(isolate)); | 492 v8::Handle<v8::Context> context = toV8Context(isolate, frame, DOMWrapperWorl
d::current(isolate)); |
555 if (context.IsEmpty()) | 493 if (context.IsEmpty()) |
556 return v8Undefined(); | 494 return v8Undefined(); |
557 | 495 |
558 v8::Handle<v8::Object> global = context->Global(); | 496 v8::Handle<v8::Object> global = context->Global(); |
559 ASSERT(!global.IsEmpty()); | 497 ASSERT(!global.IsEmpty()); |
560 return global; | 498 return global; |
561 } | 499 } |
562 | 500 |
563 } // namespace WebCore | 501 } // namespace WebCore |
OLD | NEW |