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

Side by Side Diff: Source/bindings/core/v8/custom/V8InjectedScriptHostCustom.cpp

Issue 1027593003: bindings: Use Maybe version of v8::String::NewFromUtf8() (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 9 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. 2 * Copyright (C) 2007-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 348 matching lines...) Expand 10 before | Expand all | Expand 10 after
359 ScriptState* scriptState = ScriptState::current(info.GetIsolate()); 359 ScriptState* scriptState = ScriptState::current(info.GetIsolate());
360 ScriptValue object(scriptState, info[0]); 360 ScriptValue object(scriptState, info[0]);
361 ScriptValue hints(scriptState, info[1]); 361 ScriptValue hints(scriptState, info[1]);
362 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS tate)); 362 host->inspectImpl(object.toJSONValue(scriptState), hints.toJSONValue(scriptS tate));
363 } 363 }
364 364
365 void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::V alue>& info) 365 void V8InjectedScriptHost::evalMethodCustom(const v8::FunctionCallbackInfo<v8::V alue>& info)
366 { 366 {
367 v8::Isolate* isolate = info.GetIsolate(); 367 v8::Isolate* isolate = info.GetIsolate();
368 if (info.Length() < 1) { 368 if (info.Length() < 1) {
369 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected."))); 369 isolate->ThrowException(v8::Exception::Error(v8NormalString(isolate, "On e argument expected.")));
370 return; 370 return;
371 } 371 }
372 372
373 v8::Handle<v8::String> expression = info[0]->ToString(isolate); 373 v8::Handle<v8::String> expression = info[0]->ToString(isolate);
374 if (expression.IsEmpty()) { 374 if (expression.IsEmpty()) {
375 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string."))); 375 isolate->ThrowException(v8::Exception::Error(v8NormalString(isolate, "Th e argument must be a string.")));
376 return; 376 return;
377 } 377 }
378 378
379 ASSERT(isolate->InContext()); 379 ASSERT(isolate->InContext());
380 v8::TryCatch tryCatch; 380 v8::TryCatch tryCatch;
381 v8::Local<v8::Value> result; 381 v8::Local<v8::Value> result;
382 if (!v8Call(V8ScriptRunner::compileAndRunInternalScript(expression, info.Get Isolate()), result, tryCatch)) { 382 if (!v8Call(V8ScriptRunner::compileAndRunInternalScript(expression, info.Get Isolate()), result, tryCatch)) {
383 v8SetReturnValue(info, tryCatch.ReThrow()); 383 v8SetReturnValue(info, tryCatch.ReThrow());
384 return; 384 return;
385 } 385 }
386 v8SetReturnValue(info, result); 386 v8SetReturnValue(info, result);
387 } 387 }
388 388
389 static void setExceptionAsReturnValue(const v8::FunctionCallbackInfo<v8::Value>& info, v8::Local<v8::Object> returnValue, v8::TryCatch& tryCatch) 389 static void setExceptionAsReturnValue(const v8::FunctionCallbackInfo<v8::Value>& info, v8::Local<v8::Object> returnValue, v8::TryCatch& tryCatch)
390 { 390 {
391 v8::Isolate* isolate = info.GetIsolate(); 391 v8::Isolate* isolate = info.GetIsolate();
392 returnValue->Set(v8::String::NewFromUtf8(isolate, "result"), tryCatch.Except ion()); 392 returnValue->Set(v8NormalString(isolate, "result"), tryCatch.Exception());
393 returnValue->Set(v8::String::NewFromUtf8(isolate, "exceptionDetails"), JavaS criptCallFrame::createExceptionDetails(isolate, tryCatch.Message())); 393 returnValue->Set(v8NormalString(isolate, "exceptionDetails"), JavaScriptCall Frame::createExceptionDetails(isolate, tryCatch.Message()));
394 v8SetReturnValue(info, returnValue); 394 v8SetReturnValue(info, returnValue);
395 } 395 }
396 396
397 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu nctionCallbackInfo<v8::Value>& info) 397 void V8InjectedScriptHost::evaluateWithExceptionDetailsMethodCustom(const v8::Fu nctionCallbackInfo<v8::Value>& info)
398 { 398 {
399 v8::Isolate* isolate = info.GetIsolate(); 399 v8::Isolate* isolate = info.GetIsolate();
400 if (info.Length() < 1) { 400 if (info.Length() < 1) {
401 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "One argument expected."))); 401 isolate->ThrowException(v8::Exception::Error(v8NormalString(isolate, "On e argument expected.")));
402 return; 402 return;
403 } 403 }
404 404
405 v8::Handle<v8::String> expression = info[0]->ToString(isolate); 405 v8::Handle<v8::String> expression = info[0]->ToString(isolate);
406 if (expression.IsEmpty()) { 406 if (expression.IsEmpty()) {
407 isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(iso late, "The argument must be a string."))); 407 isolate->ThrowException(v8::Exception::Error(v8NormalString(isolate, "Th e argument must be a string.")));
408 return; 408 return;
409 } 409 }
410 410
411 ASSERT(isolate->InContext()); 411 ASSERT(isolate->InContext());
412 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate); 412 v8::Local<v8::Object> wrappedResult = v8::Object::New(isolate);
413 if (wrappedResult.IsEmpty()) 413 if (wrappedResult.IsEmpty())
414 return; 414 return;
415 v8::TryCatch tryCatch; 415 v8::TryCatch tryCatch;
416 v8::Local<v8::Script> script; 416 v8::Local<v8::Script> script;
417 v8::Local<v8::Value> result; 417 v8::Local<v8::Value> result;
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after
598 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder()); 598 InjectedScriptNative* injectedScriptNative = InjectedScriptNative::fromInjec tedScriptHost(info.Holder());
599 if (!injectedScriptNative) 599 if (!injectedScriptNative)
600 return; 600 return;
601 int id = info[0]->ToInt32(info.GetIsolate())->Value(); 601 int id = info[0]->ToInt32(info.GetIsolate())->Value();
602 String groupName = injectedScriptNative->groupName(id); 602 String groupName = injectedScriptNative->groupName(id);
603 if (!groupName.isEmpty()) 603 if (!groupName.isEmpty())
604 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName)); 604 info.GetReturnValue().Set(v8String(info.GetIsolate(), groupName));
605 } 605 }
606 606
607 } // namespace blink 607 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698