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

Side by Side Diff: Source/bindings/core/v8/ScriptController.cpp

Issue 1100223003: bindings: Add empty checks for toV8() (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 5 years, 7 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
« no previous file with comments | « Source/bindings/core/v8/Iterable.h ('k') | Source/bindings/core/v8/ScriptPromiseProperty.h » ('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) 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2008, 2009 Google Inc. All rights reserved.
3 * Copyright (C) 2009 Apple Inc. All rights reserved. 3 * Copyright (C) 2009 Apple Inc. All rights reserved.
4 * Copyright (C) 2014 Opera Software ASA. All rights reserved. 4 * Copyright (C) 2014 Opera Software ASA. All rights reserved.
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are 7 * modification, are permitted provided that the following conditions are
8 * met: 8 * met:
9 * 9 *
10 * * Redistributions of source code must retain the above copyright 10 * * Redistributions of source code must retain the above copyright
(...skipping 335 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate) 347 static NPObject* createScriptObject(LocalFrame* frame, v8::Isolate* isolate)
348 { 348 {
349 ScriptState* scriptState = ScriptState::forMainWorld(frame); 349 ScriptState* scriptState = ScriptState::forMainWorld(frame);
350 if (!scriptState->contextIsValid()) 350 if (!scriptState->contextIsValid())
351 return createNoScriptObject(); 351 return createNoScriptObject();
352 352
353 ScriptState::Scope scope(scriptState); 353 ScriptState::Scope scope(scriptState);
354 LocalDOMWindow* window = frame->localDOMWindow(); 354 LocalDOMWindow* window = frame->localDOMWindow();
355 v8::Local<v8::Value> global = toV8(window, scriptState->context()->Global(), scriptState->isolate()); 355 v8::Local<v8::Value> global = toV8(window, scriptState->context()->Global(), scriptState->isolate());
356 if (global.IsEmpty())
357 return createNoScriptObject();
356 ASSERT(global->IsObject()); 358 ASSERT(global->IsObject());
357 return npCreateV8ScriptObject(isolate, 0, v8::Local<v8::Object>::Cast(global ), window); 359 return npCreateV8ScriptObject(isolate, 0, v8::Local<v8::Object>::Cast(global ), window);
358 } 360 }
359 361
360 NPObject* ScriptController::windowScriptNPObject() 362 NPObject* ScriptController::windowScriptNPObject()
361 { 363 {
362 if (m_windowScriptNPObject) 364 if (m_windowScriptNPObject)
363 return m_windowScriptNPObject; 365 return m_windowScriptNPObject;
364 366
365 if (canExecuteScripts(NotAboutToExecuteScript)) { 367 if (canExecuteScripts(NotAboutToExecuteScript)) {
(...skipping 16 matching lines...) Expand all
382 if (!canExecuteScripts(NotAboutToExecuteScript)) 384 if (!canExecuteScripts(NotAboutToExecuteScript))
383 return createNoScriptObject(); 385 return createNoScriptObject();
384 386
385 ScriptState* scriptState = ScriptState::forMainWorld(frame()); 387 ScriptState* scriptState = ScriptState::forMainWorld(frame());
386 if (!scriptState->contextIsValid()) 388 if (!scriptState->contextIsValid())
387 return createNoScriptObject(); 389 return createNoScriptObject();
388 390
389 ScriptState::Scope scope(scriptState); 391 ScriptState::Scope scope(scriptState);
390 LocalDOMWindow* window = frame()->localDOMWindow(); 392 LocalDOMWindow* window = frame()->localDOMWindow();
391 v8::Local<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global( ), scriptState->isolate()); 393 v8::Local<v8::Value> v8plugin = toV8(plugin, scriptState->context()->Global( ), scriptState->isolate());
392 if (!v8plugin->IsObject()) 394 if (v8plugin.IsEmpty() || !v8plugin->IsObject())
393 return createNoScriptObject(); 395 return createNoScriptObject();
394 396
395 return npCreateV8ScriptObject(scriptState->isolate(), 0, v8::Local<v8::Objec t>::Cast(v8plugin), window); 397 return npCreateV8ScriptObject(scriptState->isolate(), 0, v8::Local<v8::Objec t>::Cast(v8plugin), window);
396 } 398 }
397 399
398 void ScriptController::clearWindowProxy() 400 void ScriptController::clearWindowProxy()
399 { 401 {
400 // V8 binding expects ScriptController::clearWindowProxy only be called 402 // V8 binding expects ScriptController::clearWindowProxy only be called
401 // when a frame is loading a new page. This creates a new context for the ne w page. 403 // when a frame is loading a new page. This creates a new context for the ne w page.
402 404
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 for (size_t i = 0; i < resultArray->Length(); ++i) { 592 for (size_t i = 0; i < resultArray->Length(); ++i) {
591 v8::Local<v8::Value> value; 593 v8::Local<v8::Value> value;
592 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value)) 594 if (!resultArray->Get(scriptState->context(), i).ToLocal(&value))
593 return; 595 return;
594 results->append(value); 596 results->append(value);
595 } 597 }
596 } 598 }
597 } 599 }
598 600
599 } // namespace blink 601 } // namespace blink
OLDNEW
« no previous file with comments | « Source/bindings/core/v8/Iterable.h ('k') | Source/bindings/core/v8/ScriptPromiseProperty.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698