Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(236)

Side by Side Diff: Source/bindings/v8/custom/V8WindowCustom.cpp

Issue 24118003: Pass isolate to v8::Undefined() function (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rebase on master Created 7 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp ('k') | Source/web/WebBindings.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 299 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 } 310 }
311 311
312 class DialogHandler { 312 class DialogHandler {
313 public: 313 public:
314 explicit DialogHandler(v8::Handle<v8::Value> dialogArguments) 314 explicit DialogHandler(v8::Handle<v8::Value> dialogArguments)
315 : m_dialogArguments(dialogArguments) 315 : m_dialogArguments(dialogArguments)
316 { 316 {
317 } 317 }
318 318
319 void dialogCreated(DOMWindow*); 319 void dialogCreated(DOMWindow*);
320 v8::Handle<v8::Value> returnValue() const; 320 v8::Handle<v8::Value> returnValue(v8::Isolate*) const;
321 321
322 private: 322 private:
323 v8::Handle<v8::Value> m_dialogArguments; 323 v8::Handle<v8::Value> m_dialogArguments;
324 v8::Handle<v8::Context> m_dialogContext; 324 v8::Handle<v8::Context> m_dialogContext;
325 }; 325 };
326 326
327 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame) 327 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
328 { 328 {
329 m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->cur rentWorldContext() : v8::Local<v8::Context>(); 329 m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->cur rentWorldContext() : v8::Local<v8::Context>();
330 if (m_dialogContext.IsEmpty()) 330 if (m_dialogContext.IsEmpty())
331 return; 331 return;
332 if (m_dialogArguments.IsEmpty()) 332 if (m_dialogArguments.IsEmpty())
333 return; 333 return;
334 v8::Context::Scope scope(m_dialogContext); 334 v8::Context::Scope scope(m_dialogContext);
335 m_dialogContext->Global()->Set(v8::String::NewSymbol("dialogArguments"), m_d ialogArguments); 335 m_dialogContext->Global()->Set(v8::String::NewSymbol("dialogArguments"), m_d ialogArguments);
336 } 336 }
337 337
338 inline v8::Handle<v8::Value> DialogHandler::returnValue() const 338 inline v8::Handle<v8::Value> DialogHandler::returnValue(v8::Isolate* isolate) co nst
339 { 339 {
340 if (m_dialogContext.IsEmpty()) 340 if (m_dialogContext.IsEmpty())
341 return v8::Undefined(); 341 return v8::Undefined(isolate);
342 v8::Context::Scope scope(m_dialogContext); 342 v8::Context::Scope scope(m_dialogContext);
343 v8::Handle<v8::Value> returnValue = m_dialogContext->Global()->Get(v8::Strin g::NewSymbol("returnValue")); 343 v8::Handle<v8::Value> returnValue = m_dialogContext->Global()->Get(v8::Strin g::NewSymbol("returnValue"));
344 if (returnValue.IsEmpty()) 344 if (returnValue.IsEmpty())
345 return v8::Undefined(); 345 return v8::Undefined(isolate);
346 return returnValue; 346 return returnValue;
347 } 347 }
348 348
349 static void setUpDialog(DOMWindow* dialog, void* handler) 349 static void setUpDialog(DOMWindow* dialog, void* handler)
350 { 350 {
351 static_cast<DialogHandler*>(handler)->dialogCreated(dialog); 351 static_cast<DialogHandler*>(handler)->dialogCreated(dialog);
352 } 352 }
353 353
354 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va lue>& args) 354 void V8Window::showModalDialogMethodCustom(const v8::FunctionCallbackInfo<v8::Va lue>& args)
355 { 355 {
356 DOMWindow* impl = V8Window::toNative(args.Holder()); 356 DOMWindow* impl = V8Window::toNative(args.Holder());
357 ExceptionState es(args.GetIsolate()); 357 ExceptionState es(args.GetIsolate());
358 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { 358 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) {
359 es.throwIfNeeded(); 359 es.throwIfNeeded();
360 return; 360 return;
361 } 361 }
362 362
363 // FIXME: Handle exceptions properly. 363 // FIXME: Handle exceptions properly.
364 String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]); 364 String urlString = toWebCoreStringWithUndefinedOrNullCheck(args[0]);
365 DialogHandler handler(args[1]); 365 DialogHandler handler(args[1]);
366 String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2 ]); 366 String dialogFeaturesString = toWebCoreStringWithUndefinedOrNullCheck(args[2 ]);
367 367
368 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi rstDOMWindow(), setUpDialog, &handler); 368 impl->showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(), fi rstDOMWindow(), setUpDialog, &handler);
369 369
370 v8SetReturnValue(args, handler.returnValue()); 370 v8SetReturnValue(args, handler.returnValue(args.GetIsolate()));
371 } 371 }
372 372
373 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args) 373 void V8Window::openMethodCustom(const v8::FunctionCallbackInfo<v8::Value>& args)
374 { 374 {
375 DOMWindow* impl = V8Window::toNative(args.Holder()); 375 DOMWindow* impl = V8Window::toNative(args.Holder());
376 ExceptionState es(args.GetIsolate()); 376 ExceptionState es(args.GetIsolate());
377 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) { 377 if (!BindingSecurity::shouldAllowAccessToFrame(impl->frame(), es)) {
378 es.throwIfNeeded(); 378 es.throwIfNeeded();
379 return; 379 return;
380 } 380 }
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 v8::Handle<v8::Context> context = frame->script()->currentWorldContext(); 555 v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
556 if (context.IsEmpty()) 556 if (context.IsEmpty())
557 return v8Undefined(); 557 return v8Undefined();
558 558
559 v8::Handle<v8::Object> global = context->Global(); 559 v8::Handle<v8::Object> global = context->Global();
560 ASSERT(!global.IsEmpty()); 560 ASSERT(!global.IsEmpty());
561 return global; 561 return global;
562 } 562 }
563 563
564 } // namespace WebCore 564 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/custom/V8WebGLRenderingContextCustom.cpp ('k') | Source/web/WebBindings.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698