Replace deprecated uses of v8::String::NewFromUtf8
[email protected]
Bug: v8:7281
Change-Id: Icacc1c60f4b0c9c3646f1ea310435ee2f90f0a05
Reviewed-on: https://chromium-review.googlesource.com/1238534
Commit-Queue: Yang Guo <[email protected]>
Reviewed-by: Jochen Eisinger <[email protected]>
Cr-Commit-Position: refs/heads/master@{#594048}
diff --git a/chrome/renderer/benchmarking_extension.cc b/chrome/renderer/benchmarking_extension.cc
index b0fe829..2d957fd 100644
--- a/chrome/renderer/benchmarking_extension.cc
+++ b/chrome/renderer/benchmarking_extension.cc
@@ -54,10 +54,14 @@
v8::Isolate* isolate,
v8::Local<v8::String> name) override {
if (name->StringEquals(
- v8::String::NewFromUtf8(isolate, "IsSingleProcess"))) {
+ v8::String::NewFromUtf8(isolate, "IsSingleProcess",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, IsSingleProcess);
} else if (name->StringEquals(
- v8::String::NewFromUtf8(isolate, "HiResTime"))) {
+ v8::String::NewFromUtf8(isolate, "HiResTime",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, HiResTime);
}
diff --git a/chrome/renderer/extensions/app_bindings.cc b/chrome/renderer/extensions/app_bindings.cc
index 434c2ac..e44d35e8 100644
--- a/chrome/renderer/extensions/app_bindings.cc
+++ b/chrome/renderer/extensions/app_bindings.cc
@@ -55,8 +55,11 @@
void AppBindings::GetRunningState(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- args.GetReturnValue().Set(v8::String::NewFromUtf8(
- context()->isolate(), app_core_.GetRunningState(context())));
+ args.GetReturnValue().Set(
+ v8::String::NewFromUtf8(context()->isolate(),
+ app_core_.GetRunningState(context()),
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
}
void AppBindings::OnAppInstallStateResponse(int callback_id,
@@ -68,9 +71,10 @@
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context()->v8_context());
v8::Local<v8::Value> argv[] = {
- v8::String::NewFromUtf8(isolate, state.c_str()),
- v8::Integer::New(isolate, callback_id)
- };
+ v8::String::NewFromUtf8(isolate, state.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ v8::Integer::New(isolate, callback_id)};
context()->module_system()->CallModuleMethodSafe(
"app", "onInstallStateResponse", arraysize(argv), argv);
}
diff --git a/chrome/renderer/extensions/automation_internal_custom_bindings.cc b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
index c11ee14..c145cee5 100644
--- a/chrome/renderer/extensions/automation_internal_custom_bindings.cc
+++ b/chrome/renderer/extensions/automation_internal_custom_bindings.cc
@@ -481,17 +481,21 @@
AutomationAXTreeWrapper* tree_wrapper) {
result.Set(v8::Integer::New(isolate, tree_wrapper->tree()->root()->id()));
});
- RouteTreeIDFunction(
- "GetDocURL", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
- AutomationAXTreeWrapper* tree_wrapper) {
- result.Set(v8::String::NewFromUtf8(
- isolate, tree_wrapper->tree()->data().url.c_str()));
- });
+ RouteTreeIDFunction("GetDocURL", [](v8::Isolate* isolate,
+ v8::ReturnValue<v8::Value> result,
+ AutomationAXTreeWrapper* tree_wrapper) {
+ result.Set(v8::String::NewFromUtf8(isolate,
+ tree_wrapper->tree()->data().url.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
+ });
RouteTreeIDFunction(
"GetDocTitle", [](v8::Isolate* isolate, v8::ReturnValue<v8::Value> result,
AutomationAXTreeWrapper* tree_wrapper) {
result.Set(v8::String::NewFromUtf8(
- isolate, tree_wrapper->tree()->data().title.c_str()));
+ isolate, tree_wrapper->tree()->data().title.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteTreeIDFunction(
"GetDocLoaded",
@@ -609,7 +613,9 @@
}
std::string role_name = ui::ToString(mapped_role);
- result.Set(v8::String::NewFromUtf8(isolate, role_name.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, role_name.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteNodeIDFunction(
"GetLocation",
@@ -737,7 +743,9 @@
return;
}
- result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteNodeIDPlusAttributeFunction(
"GetBoolAttribute",
@@ -845,7 +853,9 @@
if (!node->data().GetHtmlAttribute(attribute_name.c_str(), &attr_value))
return;
- result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, attr_value.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteNodeIDFunction(
"GetNameFrom",
@@ -854,7 +864,9 @@
ax::mojom::NameFrom name_from = static_cast<ax::mojom::NameFrom>(
node->data().GetIntAttribute(ax::mojom::IntAttribute::kNameFrom));
std::string name_from_str = ui::ToString(name_from);
- result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, name_from_str.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteNodeIDFunction("GetSubscript", [](v8::Isolate* isolate,
v8::ReturnValue<v8::Value> result,
@@ -970,7 +982,9 @@
for (size_t i = 0; i < standard_actions.size(); i++) {
const v8::Maybe<bool>& did_set_value = actions_result->Set(
isolate->GetCurrentContext(), i,
- v8::String::NewFromUtf8(isolate, standard_actions[i].c_str()));
+ v8::String::NewFromUtf8(isolate, standard_actions[i].c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
bool did_set_value_result = false;
if (!did_set_value.To(&did_set_value_result) || !did_set_value_result)
@@ -987,7 +1001,9 @@
ax::mojom::IntAttribute::kCheckedState));
if (checked_state != ax::mojom::CheckedState::kNone) {
const std::string checked_str = ui::ToString(checked_state);
- result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, checked_str.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
});
RouteNodeIDFunction(
@@ -998,7 +1014,9 @@
node->data().GetRestriction();
if (restriction != ax::mojom::Restriction::kNone) {
const std::string restriction_str = ui::ToString(restriction);
- result.Set(v8::String::NewFromUtf8(isolate, restriction_str.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate, restriction_str.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
});
RouteNodeIDFunction(
@@ -1010,8 +1028,10 @@
node->data().GetIntAttribute(
ax::mojom::IntAttribute::kDefaultActionVerb));
std::string default_action_verb_str = ui::ToString(default_action_verb);
- result.Set(
- v8::String::NewFromUtf8(isolate, default_action_verb_str.c_str()));
+ result.Set(v8::String::NewFromUtf8(isolate,
+ default_action_verb_str.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
});
RouteNodeIDPlusStringBoolFunction(
"GetNextTextMatch",
diff --git a/chrome/renderer/extensions/cast_streaming_native_handler.cc b/chrome/renderer/extensions/cast_streaming_native_handler.cc
index eea058b..eb57fda 100644
--- a/chrome/renderer/extensions/cast_streaming_native_handler.cc
+++ b/chrome/renderer/extensions/cast_streaming_native_handler.cc
@@ -105,8 +105,10 @@
if (config->sender_ssrc == config->receiver_ssrc) {
DVLOG(1) << "sender_ssrc " << config->sender_ssrc
<< " cannot be equal to receiver_ssrc";
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
config->min_playout_delay = base::TimeDelta::FromMilliseconds(
@@ -120,23 +122,29 @@
if (config->min_playout_delay <= base::TimeDelta()) {
DVLOG(1) << "min_playout_delay " << config->min_playout_delay
<< " must be greater than zero";
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (config->min_playout_delay > config->max_playout_delay) {
DVLOG(1) << "min_playout_delay " << config->min_playout_delay
<< " must be less than or equal to max_palyout_delay";
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (config->animated_playout_delay < config->min_playout_delay ||
config->animated_playout_delay > config->max_playout_delay) {
DVLOG(1) << "animated_playout_delay " << config->animated_playout_delay
<< " must be between (inclusive) the min and max playout delay";
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (ext_params.codec_name == kCodecNameOpus) {
@@ -156,13 +164,17 @@
default:
DVLOG(1) << "rtp_timebase " << config->rtp_timebase << " is invalid";
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
config->channels = ext_params.channels ? *ext_params.channels : 2;
if (config->channels != 1 && config->channels != 2) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
DVLOG(1) << "channels " << config->channels << " is invalid";
return false;
}
@@ -177,7 +189,9 @@
config->channels = ext_params.channels ? *ext_params.channels : 1;
if (config->channels != 1) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
DVLOG(1) << "channels " << config->channels << " is invalid";
return false;
}
@@ -191,7 +205,9 @@
DVLOG(1) << "min_bitrate " << config->min_bitrate << " is larger than "
<< "max_bitrate " << config->max_bitrate;
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
config->start_bitrate = config->min_bitrate;
@@ -200,7 +216,9 @@
if (config->max_frame_rate > media::limits::kMaxFramesPerSecond) {
DVLOG(1) << "max_frame_rate " << config->max_frame_rate << " is invalid";
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (ext_params.codec_name == kCodecNameVp8) {
@@ -225,19 +243,25 @@
config->codec = media::cast::CODEC_VIDEO_REMOTE;
} else {
DVLOG(1) << "codec_name " << ext_params.codec_name << " is invalid";
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (ext_params.aes_key && !HexDecode(*ext_params.aes_key, &config->aes_key)) {
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidAesKey)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidAesKey,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (ext_params.aes_iv_mask &&
!HexDecode(*ext_params.aes_iv_mask, &config->aes_iv_mask)) {
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidAesIvMask)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidAesIvMask,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
return true;
@@ -398,7 +422,9 @@
blink::WebDOMMediaStreamTrack::FromV8Value(args[0]);
if (track.IsNull()) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidStreamArgs)));
+ v8::String::NewFromUtf8(isolate, kInvalidStreamArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
stream1.reset(new CastRtpStream(track.Component(), session));
@@ -409,7 +435,9 @@
blink::WebDOMMediaStreamTrack::FromV8Value(args[1]);
if (track.IsNull()) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidStreamArgs)));
+ v8::String::NewFromUtf8(isolate, kInvalidStreamArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
stream2.reset(new CastRtpStream(track.Component(), session));
@@ -533,13 +561,17 @@
V8ValueConverter::Create()->FromV8Value(args[1], context()->v8_context());
if (!params_value) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertParams)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
std::unique_ptr<RtpParams> params = RtpParams::FromValue(*params_value);
if (!params) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kInvalidRtpParams)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -629,7 +661,9 @@
args[1], context()->v8_context()));
if (!options) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
transport->SetOptions(std::move(options));
@@ -743,8 +777,10 @@
if (iter != rtp_stream_map_.end())
return iter->second.get();
v8::Isolate* isolate = context()->v8_context()->GetIsolate();
- isolate->ThrowException(v8::Exception::RangeError(v8::String::NewFromUtf8(
- isolate, kRtpStreamNotFound)));
+ isolate->ThrowException(v8::Exception::RangeError(
+ v8::String::NewFromUtf8(isolate, kRtpStreamNotFound,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return NULL;
}
@@ -756,7 +792,9 @@
return iter->second.get();
v8::Isolate* isolate = context()->v8_context()->GetIsolate();
isolate->ThrowException(v8::Exception::RangeError(
- v8::String::NewFromUtf8(isolate, kUdpTransportNotFound)));
+ v8::String::NewFromUtf8(isolate, kUdpTransportNotFound,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return NULL;
}
@@ -768,14 +806,18 @@
V8ValueConverter::Create()->FromV8Value(arg, context()->v8_context());
if (!params_value) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kUnableToConvertParams)));
+ v8::String::NewFromUtf8(isolate, kUnableToConvertParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
std::unique_ptr<RtpReceiverParams> params =
RtpReceiverParams::FromValue(*params_value);
if (!params) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidRtpParams)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
@@ -784,7 +826,9 @@
config->rtp_max_delay_ms = params->max_latency;
if (config->rtp_max_delay_ms < 0 || config->rtp_max_delay_ms > 1000) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidLatency)));
+ v8::String::NewFromUtf8(isolate, kInvalidLatency,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
config->channels = 2;
@@ -813,20 +857,26 @@
config->rtp_timebase = *params->rtp_timebase;
if (config->rtp_timebase < 1000 || config->rtp_timebase > 1000000) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidRtpTimebase)));
+ v8::String::NewFromUtf8(isolate, kInvalidRtpTimebase,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
}
if (params->aes_key &&
!HexDecode(*params->aes_key, &config->aes_key)) {
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidAesKey)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidAesKey,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
if (params->aes_iv_mask &&
!HexDecode(*params->aes_iv_mask, &config->aes_iv_mask)) {
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidAesIvMask)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidAesIvMask,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
return true;
@@ -840,20 +890,26 @@
V8ValueConverter::Create()->FromV8Value(arg, context()->v8_context());
if (!destination_value) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidAesIvMask)));
+ v8::String::NewFromUtf8(isolate, kInvalidAesIvMask,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
std::unique_ptr<IPEndPoint> destination =
IPEndPoint::FromValue(*destination_value);
if (!destination) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidDestination)));
+ v8::String::NewFromUtf8(isolate, kInvalidDestination,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
net::IPAddress ip;
if (!ip.AssignFromIPLiteral(destination->address)) {
isolate->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(isolate, kInvalidDestination)));
+ v8::String::NewFromUtf8(isolate, kInvalidDestination,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
*ip_endpoint = net::IPEndPoint(ip, destination->port);
@@ -871,7 +927,9 @@
!args[5]->IsNumber() ||
!args[6]->IsString()) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -896,7 +954,9 @@
if (fps <= 1) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kInvalidFPS)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kInvalidFPS,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -906,7 +966,9 @@
if (stream.IsNull()) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kInvalidMediaStreamURL)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kInvalidMediaStreamURL,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -925,7 +987,9 @@
if (!params.IsValid()) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kInvalidAudioParams,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -938,7 +1002,9 @@
options = base::DictionaryValue::From(std::move(options_value));
if (!options) {
args.GetIsolate()->ThrowException(v8::Exception::TypeError(
- v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs)));
+ v8::String::NewFromUtf8(args.GetIsolate(), kUnableToConvertArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
}
@@ -965,10 +1031,10 @@
v8::CopyablePersistentTraits<v8::Function>::CopyablePersistent function,
const std::string& error_message) {
v8::Isolate* isolate = context()->v8_context()->GetIsolate();
- v8::Local<v8::Value> arg = v8::String::NewFromUtf8(isolate,
- error_message.data(),
- v8::String::kNormalString,
- error_message.size());
+ v8::Local<v8::Value> arg =
+ v8::String::NewFromUtf8(isolate, error_message.data(),
+ v8::NewStringType::kNormal, error_message.size())
+ .ToLocalChecked();
context()->SafeCallFunction(v8::Local<v8::Function>::New(isolate, function),
1, &arg);
}
diff --git a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc
index 960ebbe..997f24ed 100644
--- a/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc
+++ b/chrome/renderer/extensions/file_browser_handler_custom_bindings.cc
@@ -39,15 +39,24 @@
v8::Isolate* isolate = args.GetIsolate();
std::string file_system_name(*v8::String::Utf8Value(
isolate,
- file_def->Get(v8::String::NewFromUtf8(isolate, "fileSystemName"))));
+ file_def->Get(v8::String::NewFromUtf8(isolate, "fileSystemName",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())));
GURL file_system_root(*v8::String::Utf8Value(
isolate,
- file_def->Get(v8::String::NewFromUtf8(isolate, "fileSystemRoot"))));
+ file_def->Get(v8::String::NewFromUtf8(isolate, "fileSystemRoot",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())));
std::string file_full_path(*v8::String::Utf8Value(
isolate,
- file_def->Get(v8::String::NewFromUtf8(isolate, "fileFullPath"))));
+ file_def->Get(v8::String::NewFromUtf8(isolate, "fileFullPath",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())));
bool is_directory =
- file_def->Get(v8::String::NewFromUtf8(isolate, "fileIsDirectory"))
+ file_def
+ ->Get(v8::String::NewFromUtf8(isolate, "fileIsDirectory",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())
->BooleanValue(context->v8_context())
.FromMaybe(false);
blink::WebDOMFileSystem::EntryType entry_type =
diff --git a/chrome/renderer/extensions/webstore_bindings.cc b/chrome/renderer/extensions/webstore_bindings.cc
index ff95be9..bbbda3c 100644
--- a/chrome/renderer/extensions/webstore_bindings.cc
+++ b/chrome/renderer/extensions/webstore_bindings.cc
@@ -75,10 +75,13 @@
v8::Context::Scope context_scope(context()->v8_context());
v8::Local<v8::Value> argv[] = {
v8::Integer::New(isolate, install_id), v8::Boolean::New(isolate, success),
- v8::String::NewFromUtf8(isolate, error.c_str()),
+ v8::String::NewFromUtf8(isolate, error.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
v8::String::NewFromUtf8(
- isolate,
- api::webstore::kInstallResultCodes[static_cast<int>(result)])};
+ isolate, api::webstore::kInstallResultCodes[static_cast<int>(result)],
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()};
context()->module_system()->CallModuleMethodSafe(
"webstore", "onInstallResponse", arraysize(argv), argv);
}
@@ -98,7 +101,8 @@
v8::HandleScope handle_scope(isolate);
v8::Context::Scope context_scope(context()->v8_context());
v8::Local<v8::Value> argv[] = {
- v8::String::NewFromUtf8(isolate, stage_string)};
+ v8::String::NewFromUtf8(isolate, stage_string, v8::NewStringType::kNormal)
+ .ToLocalChecked()};
context()->module_system()->CallModuleMethodSafe(
"webstore", "onInstallStageChanged", arraysize(argv), argv);
}
@@ -143,7 +147,9 @@
if (!GetWebstoreItemIdFromFrame(
frame, preferred_store_link_url, &webstore_item_id, &error)) {
args.GetIsolate()->ThrowException(
- v8::String::NewFromUtf8(args.GetIsolate(), error.c_str()));
+ v8::String::NewFromUtf8(args.GetIsolate(), error.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
return;
}
diff --git a/chrome/renderer/loadtimes_extension_bindings.cc b/chrome/renderer/loadtimes_extension_bindings.cc
index dda7d71..a79a0a2 100644
--- a/chrome/renderer/loadtimes_extension_bindings.cc
+++ b/chrome/renderer/loadtimes_extension_bindings.cc
@@ -64,9 +64,15 @@
v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Local<v8::String> name) override {
- if (name->StringEquals(v8::String::NewFromUtf8(isolate, "GetLoadTimes"))) {
+ if (name->StringEquals(
+ v8::String::NewFromUtf8(isolate, "GetLoadTimes",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, GetLoadTimes);
- } else if (name->StringEquals(v8::String::NewFromUtf8(isolate, "GetCSI"))) {
+ } else if (name->StringEquals(
+ v8::String::NewFromUtf8(isolate, "GetCSI",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, GetCSI);
}
return v8::Local<v8::FunctionTemplate>();
diff --git a/chrome/renderer/net_benchmarking_extension.cc b/chrome/renderer/net_benchmarking_extension.cc
index a43add3..37f75e87 100644
--- a/chrome/renderer/net_benchmarking_extension.cc
+++ b/chrome/renderer/net_benchmarking_extension.cc
@@ -48,16 +48,25 @@
v8::Local<v8::FunctionTemplate> GetNativeFunctionTemplate(
v8::Isolate* isolate,
v8::Local<v8::String> name) override {
- if (name->StringEquals(v8::String::NewFromUtf8(isolate, "ClearCache"))) {
+ if (name->StringEquals(
+ v8::String::NewFromUtf8(isolate, "ClearCache",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, ClearCache);
- } else if (name->StringEquals(v8::String::NewFromUtf8(
- isolate, "ClearHostResolverCache"))) {
+ } else if (name->StringEquals(
+ v8::String::NewFromUtf8(isolate, "ClearHostResolverCache",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, ClearHostResolverCache);
} else if (name->StringEquals(
- v8::String::NewFromUtf8(isolate, "ClearPredictorCache"))) {
+ v8::String::NewFromUtf8(isolate, "ClearPredictorCache",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, ClearPredictorCache);
} else if (name->StringEquals(
- v8::String::NewFromUtf8(isolate, "CloseConnections"))) {
+ v8::String::NewFromUtf8(isolate, "CloseConnections",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())) {
return v8::FunctionTemplate::New(isolate, CloseConnections);
}
diff --git a/chrome/test/base/v8_unit_test.cc b/chrome/test/base/v8_unit_test.cc
index 23cd96a..7f8ed5b 100644
--- a/chrome/test/base/v8_unit_test.cc
+++ b/chrome/test/base/v8_unit_test.cc
@@ -98,8 +98,10 @@
v8::MicrotasksScope microtasks(
isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
- v8::Local<v8::Value> function_property =
- context->Global()->Get(v8::String::NewFromUtf8(isolate, "runTest"));
+ v8::Local<v8::Value> function_property = context->Global()->Get(
+ v8::String::NewFromUtf8(isolate, "runTest",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
EXPECT_FALSE(function_property.IsEmpty());
if (::testing::Test::HasNonfatalFailure())
return false;
@@ -110,19 +112,19 @@
v8::Local<v8::Function>::Cast(function_property);
v8::Local<v8::Array> params = v8::Array::New(isolate);
- params->Set(0,
- v8::String::NewFromUtf8(isolate,
- test_fixture.data(),
- v8::String::kNormalString,
- test_fixture.size()));
- params->Set(1,
- v8::String::NewFromUtf8(isolate,
- test_name.data(),
- v8::String::kNormalString,
- test_name.size()));
+ params->Set(0, v8::String::NewFromUtf8(isolate, test_fixture.data(),
+ v8::NewStringType::kNormal,
+ test_fixture.size())
+ .ToLocalChecked());
+ params->Set(
+ 1, v8::String::NewFromUtf8(isolate, test_name.data(),
+ v8::NewStringType::kNormal, test_name.size())
+ .ToLocalChecked());
v8::Local<v8::Value> args[] = {
v8::Boolean::New(isolate, false),
- v8::String::NewFromUtf8(isolate, "RUN_TEST_F"), params};
+ v8::String::NewFromUtf8(isolate, "RUN_TEST_F", v8::NewStringType::kNormal)
+ .ToLocalChecked(),
+ params};
v8::TryCatch try_catch(isolate);
v8::Local<v8::Value> result = function->Call(context->Global(), 3, args);
@@ -167,7 +169,9 @@
void V8UnitTest::SetUp() {
v8::Isolate* isolate = blink::MainThreadIsolate();
v8::Local<v8::ObjectTemplate> global = v8::ObjectTemplate::New(isolate);
- v8::Local<v8::String> log_string = v8::String::NewFromUtf8(isolate, "log");
+ v8::Local<v8::String> log_string =
+ v8::String::NewFromUtf8(isolate, "log", v8::NewStringType::kInternalized)
+ .ToLocalChecked();
v8::Local<v8::FunctionTemplate> log_function =
v8::FunctionTemplate::New(isolate, &V8UnitTest::Log);
log_function->RemovePrototype();
@@ -175,29 +179,50 @@
// Set up chrome object for chrome.send().
v8::Local<v8::ObjectTemplate> chrome = v8::ObjectTemplate::New(isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "chrome"), chrome);
+ global->Set(v8::String::NewFromUtf8(isolate, "chrome",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ chrome);
v8::Local<v8::FunctionTemplate> send_function =
v8::FunctionTemplate::New(isolate, &V8UnitTest::ChromeSend);
send_function->RemovePrototype();
- chrome->Set(v8::String::NewFromUtf8(isolate, "send"), send_function);
+ chrome->Set(
+ v8::String::NewFromUtf8(isolate, "send", v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ send_function);
context_.Reset(isolate, v8::Context::New(isolate, NULL, global));
// Set up console object for console.log(), etc.
v8::Local<v8::ObjectTemplate> console = v8::ObjectTemplate::New(isolate);
- global->Set(v8::String::NewFromUtf8(isolate, "console"), console);
+ global->Set(v8::String::NewFromUtf8(isolate, "console",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ console);
console->Set(log_string, log_function);
- console->Set(v8::String::NewFromUtf8(isolate, "info"), log_function);
- console->Set(v8::String::NewFromUtf8(isolate, "warn"), log_function);
+ console->Set(
+ v8::String::NewFromUtf8(isolate, "info", v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ log_function);
+ console->Set(
+ v8::String::NewFromUtf8(isolate, "warn", v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ log_function);
v8::Local<v8::FunctionTemplate> error_function =
v8::FunctionTemplate::New(isolate, &V8UnitTest::Error);
error_function->RemovePrototype();
- console->Set(v8::String::NewFromUtf8(isolate, "error"), error_function);
+ console->Set(v8::String::NewFromUtf8(isolate, "error",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ error_function);
{
v8::Local<v8::Context> context = context_.Get(isolate);
v8::Context::Scope context_scope(context);
context->Global()
- ->Set(context, v8::String::NewFromUtf8(isolate, "console"),
+ ->Set(context,
+ v8::String::NewFromUtf8(isolate, "console",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
console->NewInstance(context).ToLocalChecked())
.ToChecked();
}
@@ -210,12 +235,13 @@
v8::Local<v8::Context>::New(isolate, context_);
v8::Context::Scope context_scope(context);
context->Global()->Set(
- v8::String::NewFromUtf8(isolate,
- var_name.c_str(),
- v8::String::kNormalString,
- var_name.length()),
- v8::String::NewFromUtf8(
- isolate, value.c_str(), v8::String::kNormalString, value.length()));
+ v8::String::NewFromUtf8(isolate, var_name.c_str(),
+ v8::NewStringType::kInternalized,
+ var_name.length())
+ .ToLocalChecked(),
+ v8::String::NewFromUtf8(isolate, value.c_str(),
+ v8::NewStringType::kNormal, value.length())
+ .ToLocalChecked());
}
void V8UnitTest::ExecuteScriptInContext(const base::StringPiece& script_source,
@@ -228,15 +254,13 @@
v8::MicrotasksScope microtasks(
isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::String> source =
- v8::String::NewFromUtf8(isolate,
- script_source.data(),
- v8::String::kNormalString,
- script_source.size());
+ v8::String::NewFromUtf8(isolate, script_source.data(),
+ v8::NewStringType::kNormal, script_source.size())
+ .ToLocalChecked();
v8::Local<v8::String> name =
- v8::String::NewFromUtf8(isolate,
- script_name.data(),
- v8::String::kNormalString,
- script_name.size());
+ v8::String::NewFromUtf8(isolate, script_name.data(),
+ v8::NewStringType::kNormal, script_name.size())
+ .ToLocalChecked();
v8::TryCatch try_catch(isolate);
v8::ScriptOrigin origin(name);
@@ -283,7 +307,9 @@
isolate, v8::MicrotasksScope::kDoNotRunMicrotasks);
v8::Local<v8::Value> function_property = context->Global()->Get(
- v8::String::NewFromUtf8(isolate, function_name.c_str()));
+ v8::String::NewFromUtf8(isolate, function_name.c_str(),
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
ASSERT_FALSE(function_property.IsEmpty());
ASSERT_TRUE(function_property->IsFunction());
v8::Local<v8::Function> function =
diff --git a/content/renderer/gpu/gpu_benchmarking_extension.cc b/content/renderer/gpu/gpu_benchmarking_extension.cc
index ec157e0..7f9420a 100644
--- a/content/renderer/gpu/gpu_benchmarking_extension.cc
+++ b/content/renderer/gpu/gpu_benchmarking_extension.cc
@@ -457,8 +457,10 @@
if (!base::PathIsWritable(path.DirName())) {
std::string msg("Path is not writable: ");
msg.append(path.DirName().MaybeAsASCII());
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, msg.c_str(), v8::String::kNormalString, msg.length())));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, msg.c_str(),
+ v8::NewStringType::kNormal, msg.length())
+ .ToLocalChecked()));
return;
}
SkFILEWStream wStream(path.MaybeAsASCII().c_str());
@@ -607,8 +609,10 @@
PrintDocumentTofile(isolate, filename, &MakeXPSDocument);
#else
std::string msg("PrintPagesToXPS is unsupported.");
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, msg.c_str(), v8::String::kNormalString, msg.length())));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, msg.c_str(), v8::NewStringType::kNormal,
+ msg.length())
+ .ToLocalChecked()));
#endif
}
@@ -627,8 +631,10 @@
!base::PathIsWritable(dirpath)) {
std::string msg("Path is not writable: ");
msg.append(dirpath.MaybeAsASCII());
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, msg.c_str(), v8::String::kNormalString, msg.length())));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, msg.c_str(),
+ v8::NewStringType::kNormal, msg.length())
+ .ToLocalChecked()));
return;
}
diff --git a/content/renderer/pepper/v8_var_converter.cc b/content/renderer/pepper/v8_var_converter.cc
index 5c4319d..93cdbdc 100644
--- a/content/renderer/pepper/v8_var_converter.cc
+++ b/content/renderer/pepper/v8_var_converter.cc
@@ -130,8 +130,10 @@
// in the sense that string primitives in JavaScript can't be referenced
// in the same way that string vars can in pepper. But that information
// isn't very useful and primitive strings are a more expected form in JS.
- *result = v8::String::NewFromUtf8(
- isolate, value.c_str(), v8::String::kNormalString, value.size());
+ *result =
+ v8::String::NewFromUtf8(isolate, value.c_str(),
+ v8::NewStringType::kNormal, value.size())
+ .ToLocalChecked();
break;
}
case PP_VARTYPE_ARRAY_BUFFER: {
@@ -419,10 +421,11 @@
if (did_create && CanHaveChildren(child_var))
stack.push_back(child_var);
v8::TryCatch try_catch(isolate);
- v8_object->Set(
- v8::String::NewFromUtf8(
- isolate, key.c_str(), v8::String::kNormalString, key.length()),
- child_v8);
+ v8_object->Set(v8::String::NewFromUtf8(isolate, key.c_str(),
+ v8::NewStringType::kInternalized,
+ key.length())
+ .ToLocalChecked(),
+ child_v8);
if (try_catch.HasCaught()) {
LOG(ERROR) << "Setter for property " << key.c_str() << " threw an "
<< "exception.";
diff --git a/content/renderer/skia_benchmarking_extension.cc b/content/renderer/skia_benchmarking_extension.cc
index 40200bb..ae5dd66b 100644
--- a/content/renderer/skia_benchmarking_extension.cc
+++ b/content/renderer/skia_benchmarking_extension.cc
@@ -285,9 +285,14 @@
}
v8::Local<v8::Object> result = v8::Object::New(isolate);
- result->Set(v8::String::NewFromUtf8(isolate, "total_time"),
+ result->Set(v8::String::NewFromUtf8(isolate, "total_time",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
v8::Number::New(isolate, total_time.InMillisecondsF()));
- result->Set(v8::String::NewFromUtf8(isolate, "cmd_times"), op_times);
+ result->Set(v8::String::NewFromUtf8(isolate, "cmd_times",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ op_times);
args->Return(result);
}
@@ -303,9 +308,13 @@
return;
v8::Local<v8::Object> result = v8::Object::New(isolate);
- result->Set(v8::String::NewFromUtf8(isolate, "width"),
+ result->Set(v8::String::NewFromUtf8(isolate, "width",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
v8::Number::New(isolate, picture->layer_rect.width()));
- result->Set(v8::String::NewFromUtf8(isolate, "height"),
+ result->Set(v8::String::NewFromUtf8(isolate, "height",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
v8::Number::New(isolate, picture->layer_rect.height()));
args->Return(result);
diff --git a/content/renderer/v8_value_converter_impl.cc b/content/renderer/v8_value_converter_impl.cc
index 13f3e8a4..1afe31ed3 100644
--- a/content/renderer/v8_value_converter_impl.cc
+++ b/content/renderer/v8_value_converter_impl.cc
@@ -258,8 +258,9 @@
case base::Value::Type::STRING: {
std::string val;
CHECK(value->GetAsString(&val));
- return v8::String::NewFromUtf8(
- isolate, val.c_str(), v8::String::kNormalString, val.length());
+ return v8::String::NewFromUtf8(isolate, val.c_str(),
+ v8::NewStringType::kNormal, val.length())
+ .ToLocalChecked();
}
case base::Value::Type::LIST:
@@ -325,8 +326,9 @@
v8::Maybe<bool> maybe = result->CreateDataProperty(
context,
- v8::String::NewFromUtf8(isolate, key.c_str(), v8::String::kNormalString,
- key.length()),
+ v8::String::NewFromUtf8(isolate, key.c_str(),
+ v8::NewStringType::kNormal, key.length())
+ .ToLocalChecked(),
child_v8);
if (!maybe.IsJust() || !maybe.FromJust())
LOG(ERROR) << "Failed to set property with key " << key;
diff --git a/extensions/renderer/activity_log_converter_strategy.cc b/extensions/renderer/activity_log_converter_strategy.cc
index 1663d15..d4612a4 100644
--- a/extensions/renderer/activity_log_converter_strategy.cc
+++ b/extensions/renderer/activity_log_converter_strategy.cc
@@ -22,25 +22,35 @@
v8::TryCatch try_catch(isolate);
v8::Isolate::DisallowJavascriptExecutionScope scope(
isolate, v8::Isolate::DisallowJavascriptExecutionScope::THROW_ON_FAILURE);
- v8::Local<v8::String> name = v8::String::NewFromUtf8(isolate, "[");
+ v8::Local<v8::String> name =
+ v8::String::NewFromUtf8(isolate, "[", v8::NewStringType::kNormal)
+ .ToLocalChecked();
if (object->IsFunction()) {
- name = v8::String::Concat(isolate, name,
- v8::String::NewFromUtf8(isolate, "Function"));
+ name = v8::String::Concat(
+ isolate, name,
+ v8::String::NewFromUtf8(isolate, "Function", v8::NewStringType::kNormal)
+ .ToLocalChecked());
v8::Local<v8::Value> fname =
v8::Local<v8::Function>::Cast(object)->GetName();
if (fname->IsString() && v8::Local<v8::String>::Cast(fname)->Length()) {
- name = v8::String::Concat(isolate, name,
- v8::String::NewFromUtf8(isolate, " "));
+ name = v8::String::Concat(
+ isolate, name,
+ v8::String::NewFromUtf8(isolate, " ", v8::NewStringType::kNormal)
+ .ToLocalChecked());
name =
v8::String::Concat(isolate, name, v8::Local<v8::String>::Cast(fname));
- name = v8::String::Concat(isolate, name,
- v8::String::NewFromUtf8(isolate, "()"));
+ name = v8::String::Concat(
+ isolate, name,
+ v8::String::NewFromUtf8(isolate, "()", v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
} else {
name = v8::String::Concat(isolate, name, object->GetConstructorName());
}
- name =
- v8::String::Concat(isolate, name, v8::String::NewFromUtf8(isolate, "]"));
+ name = v8::String::Concat(
+ isolate, name,
+ v8::String::NewFromUtf8(isolate, "]", v8::NewStringType::kNormal)
+ .ToLocalChecked());
if (try_catch.HasCaught()) {
return std::unique_ptr<base::Value>(
diff --git a/extensions/renderer/blob_native_handler.cc b/extensions/renderer/blob_native_handler.cc
index 0a0e5e8..32fc9a6 100644
--- a/extensions/renderer/blob_native_handler.cc
+++ b/extensions/renderer/blob_native_handler.cc
@@ -15,8 +15,10 @@
void GetBlobUuid(const v8::FunctionCallbackInfo<v8::Value>& args) {
CHECK_EQ(1, args.Length());
blink::WebBlob blob = blink::WebBlob::FromV8Value(args[0]);
- args.GetReturnValue().Set(
- v8::String::NewFromUtf8(args.GetIsolate(), blob.Uuid().Utf8().data()));
+ args.GetReturnValue().Set(v8::String::NewFromUtf8(args.GetIsolate(),
+ blob.Uuid().Utf8().data(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
} // namespace
diff --git a/extensions/renderer/dispatcher.cc b/extensions/renderer/dispatcher.cc
index 60a59aac..875ff26 100644
--- a/extensions/renderer/dispatcher.cc
+++ b/extensions/renderer/dispatcher.cc
@@ -172,7 +172,9 @@
void GetChrome(const v8::FunctionCallbackInfo<v8::Value>& args) {
// Check for the chrome property. If one doesn't exist, create one.
v8::Local<v8::String> chrome_string(
- v8::String::NewFromUtf8(context()->isolate(), "chrome"));
+ v8::String::NewFromUtf8(context()->isolate(), "chrome",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
v8::Local<v8::Object> global(context()->v8_context()->Global());
v8::Local<v8::Value> chrome(global->Get(chrome_string));
if (chrome->IsUndefined()) {
diff --git a/extensions/renderer/display_source_custom_bindings.cc b/extensions/renderer/display_source_custom_bindings.cc
index 4cea79d6..88f64ec 100644
--- a/extensions/renderer/display_source_custom_bindings.cc
+++ b/extensions/renderer/display_source_custom_bindings.cc
@@ -91,8 +91,10 @@
CHECK(sink_id_val->IsInt32());
const int sink_id = sink_id_val->ToInt32(isolate)->Value();
if (GetDisplaySession(sink_id)) {
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, kSessionAlreadyStarted)));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, kSessionAlreadyStarted,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -104,7 +106,9 @@
if ((video_stream_val->IsNull() || video_stream_val->IsUndefined()) &&
(audio_stream_val->IsNull() || audio_stream_val->IsUndefined())) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidStreamArgs)));
+ v8::String::NewFromUtf8(isolate, kInvalidStreamArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -116,7 +120,9 @@
.Component();
if (video_track.IsNull()) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidStreamArgs)));
+ v8::String::NewFromUtf8(isolate, kInvalidStreamArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
}
@@ -126,7 +132,9 @@
.Component();
if (audio_track.IsNull()) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidStreamArgs)));
+ v8::String::NewFromUtf8(isolate, kInvalidStreamArgs,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
}
@@ -155,8 +163,10 @@
std::unique_ptr<DisplaySourceSession> session =
DisplaySourceSessionFactory::CreateSession(session_params);
if (!session) {
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, kErrorNotSupported)));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, kErrorNotSupported,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -187,8 +197,10 @@
int sink_id = args[0]->ToInt32(args.GetIsolate())->Value();
DisplaySourceSession* session = GetDisplaySession(sink_id);
if (!session) {
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, kSessionNotFound)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kSessionNotFound,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -197,14 +209,18 @@
if (state == DisplaySourceSession::Establishing) {
// 'session started' callback has not yet been invoked.
// This session is not existing for the user.
- isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kSessionNotFound)));
+ isolate->ThrowException(
+ v8::Exception::Error(v8::String::NewFromUtf8(isolate, kSessionNotFound,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
if (state == DisplaySourceSession::Terminating) {
- isolate->ThrowException(v8::Exception::Error(v8::String::NewFromUtf8(
- isolate, kSessionAlreadyTerminating)));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, kSessionAlreadyTerminating,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return;
}
@@ -232,7 +248,9 @@
if (success)
callback_args[1] = v8::Null(isolate);
else
- callback_args[1] = v8::String::NewFromUtf8(isolate, error_message.c_str());
+ callback_args[1] = v8::String::NewFromUtf8(isolate, error_message.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked();
module_system->CallModuleMethodSafe("displaySource", "callCompletionCallback",
2, callback_args);
diff --git a/extensions/renderer/file_system_natives.cc b/extensions/renderer/file_system_natives.cc
index f4a7cd8..1d906b6 100644
--- a/extensions/renderer/file_system_natives.cc
+++ b/extensions/renderer/file_system_natives.cc
@@ -120,7 +120,8 @@
args.GetReturnValue().Set(
v8::String::NewFromUtf8(isolate, filesystem_id.c_str(),
- v8::String::kNormalString, filesystem_id.size()));
+ v8::NewStringType::kNormal, filesystem_id.size())
+ .ToLocalChecked());
}
} // namespace extensions
diff --git a/extensions/renderer/i18n_custom_bindings.cc b/extensions/renderer/i18n_custom_bindings.cc
index 4a1b298..f43e993f 100644
--- a/extensions/renderer/i18n_custom_bindings.cc
+++ b/extensions/renderer/i18n_custom_bindings.cc
@@ -57,8 +57,11 @@
void I18NCustomBindings::GetL10nUILanguage(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- args.GetReturnValue().Set(v8::String::NewFromUtf8(
- args.GetIsolate(), content::RenderThread::Get()->GetLocale().c_str()));
+ args.GetReturnValue().Set(
+ v8::String::NewFromUtf8(args.GetIsolate(),
+ content::RenderThread::Get()->GetLocale().c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
void I18NCustomBindings::DetectTextLanguage(
diff --git a/extensions/renderer/js_extension_bindings_system.cc b/extensions/renderer/js_extension_bindings_system.cc
index 1a6ff74f..783fa0c 100644
--- a/extensions/renderer/js_extension_bindings_system.cc
+++ b/extensions/renderer/js_extension_bindings_system.cc
@@ -37,7 +37,10 @@
v8::Local<v8::Object> GetOrCreateObject(const v8::Local<v8::Object>& object,
const std::string& field,
v8::Isolate* isolate) {
- v8::Local<v8::String> key = v8::String::NewFromUtf8(isolate, field.c_str());
+ v8::Local<v8::String> key =
+ v8::String::NewFromUtf8(isolate, field.c_str(),
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
// If the object has a callback property, it is assumed it is an unavailable
// API, so it is safe to delete. This is checked before GetOrCreateObject is
// called.
@@ -60,7 +63,9 @@
// an empty object.
v8::Local<v8::Object> GetOrCreateChrome(ScriptContext* context) {
v8::Local<v8::String> chrome_string(
- v8::String::NewFromUtf8(context->isolate(), "chrome"));
+ v8::String::NewFromUtf8(context->isolate(), "chrome",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
v8::Local<v8::Object> global(context->v8_context()->Global());
v8::Local<v8::Value> chrome(global->Get(chrome_string));
if (chrome->IsUndefined()) {
@@ -280,7 +285,9 @@
return;
v8::Local<v8::String> v8_bind_name =
- v8::String::NewFromUtf8(context->isolate(), bind_name.c_str());
+ v8::String::NewFromUtf8(context->isolate(), bind_name.c_str(),
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
if (bind_object->HasRealNamedProperty(v8_bind_name)) {
// The bind object may already have the property if the API has been
// registered before (or if the extension has put something there already,
diff --git a/extensions/renderer/object_backed_native_handler.cc b/extensions/renderer/object_backed_native_handler.cc
index 7cd3ca6..9242b20 100644
--- a/extensions/renderer/object_backed_native_handler.cc
+++ b/extensions/renderer/object_backed_native_handler.cc
@@ -204,10 +204,13 @@
v8::Local<v8::Object> obj,
const char* key,
v8::Local<v8::Value> value) {
- obj->SetPrivate(context, v8::Private::ForApi(context->GetIsolate(),
- v8::String::NewFromUtf8(
- context->GetIsolate(), key)),
- value)
+ obj->SetPrivate(
+ context,
+ v8::Private::ForApi(context->GetIsolate(),
+ v8::String::NewFromUtf8(context->GetIsolate(), key,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()),
+ value)
.FromJust();
}
@@ -222,10 +225,12 @@
v8::Local<v8::Object> obj,
const char* key,
v8::Local<v8::Value>* result) {
- return obj->GetPrivate(context,
- v8::Private::ForApi(context->GetIsolate(),
- v8::String::NewFromUtf8(
- context->GetIsolate(), key)))
+ return obj
+ ->GetPrivate(context, v8::Private::ForApi(context->GetIsolate(),
+ v8::String::NewFromUtf8(
+ context->GetIsolate(), key,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()))
.ToLocal(result);
}
@@ -238,10 +243,12 @@
void ObjectBackedNativeHandler::DeletePrivate(v8::Local<v8::Context> context,
v8::Local<v8::Object> obj,
const char* key) {
- obj->DeletePrivate(context,
- v8::Private::ForApi(
- context->GetIsolate(),
- v8::String::NewFromUtf8(context->GetIsolate(), key)))
+ obj->DeletePrivate(
+ context,
+ v8::Private::ForApi(context->GetIsolate(),
+ v8::String::NewFromUtf8(context->GetIsolate(), key,
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()))
.FromJust();
}
diff --git a/extensions/renderer/process_info_native_handler.cc b/extensions/renderer/process_info_native_handler.cc
index 7b3287d..224c9d48 100644
--- a/extensions/renderer/process_info_native_handler.cc
+++ b/extensions/renderer/process_info_native_handler.cc
@@ -61,14 +61,18 @@
void ProcessInfoNativeHandler::GetExtensionId(
const v8::FunctionCallbackInfo<v8::Value>& args) {
- args.GetReturnValue().Set(
- v8::String::NewFromUtf8(args.GetIsolate(), extension_id_.c_str()));
+ args.GetReturnValue().Set(v8::String::NewFromUtf8(args.GetIsolate(),
+ extension_id_.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
void ProcessInfoNativeHandler::GetContextType(
const v8::FunctionCallbackInfo<v8::Value>& args) {
args.GetReturnValue().Set(
- v8::String::NewFromUtf8(args.GetIsolate(), context_type_.c_str()));
+ v8::String::NewFromUtf8(args.GetIsolate(), context_type_.c_str(),
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked());
}
void ProcessInfoNativeHandler::InIncognitoContext(
@@ -89,10 +93,13 @@
void ProcessInfoNativeHandler::IsSendRequestDisabled(
const v8::FunctionCallbackInfo<v8::Value>& args) {
if (send_request_disabled_) {
- args.GetReturnValue().Set(v8::String::NewFromUtf8(
- args.GetIsolate(),
- "sendRequest and onRequest are obsolete."
- " Please use sendMessage and onMessage instead."));
+ args.GetReturnValue().Set(
+ v8::String::NewFromUtf8(
+ args.GetIsolate(),
+ "sendRequest and onRequest are obsolete."
+ " Please use sendMessage and onMessage instead.",
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
}
}
diff --git a/extensions/renderer/script_context.cc b/extensions/renderer/script_context.cc
index 329803a..69feec88 100644
--- a/extensions/renderer/script_context.cc
+++ b/extensions/renderer/script_context.cc
@@ -353,11 +353,15 @@
v8::Local<v8::Value> argv[] = {
v8::Integer::New(isolate(), request_id),
- v8::String::NewFromUtf8(isolate(), name.c_str()),
+ v8::String::NewFromUtf8(isolate(), name.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked(),
v8::Boolean::New(isolate(), success),
content::V8ValueConverter::Create()->ToV8Value(
&response, v8::Local<v8::Context>::New(isolate(), v8_context_)),
- v8::String::NewFromUtf8(isolate(), error.c_str())};
+ v8::String::NewFromUtf8(isolate(), error.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()};
module_system()->CallModuleMethodSafe("sendRequest", "handleResponse",
arraysize(argv), argv);
@@ -398,14 +402,18 @@
"%s cannot be used within a sandboxed frame.";
std::string error_msg = base::StringPrintf(kMessage, name.c_str());
isolate()->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate(), error_msg.c_str())));
+ v8::String::NewFromUtf8(isolate(), error_msg.c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
Feature::Availability availability = GetAvailability(name);
if (!availability.is_available()) {
isolate()->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate(), availability.message().c_str())));
+ v8::String::NewFromUtf8(isolate(), availability.message().c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked()));
return false;
}
diff --git a/extensions/renderer/set_icon_natives.cc b/extensions/renderer/set_icon_natives.cc
index bc29330..45fd2f1 100644
--- a/extensions/renderer/set_icon_natives.cc
+++ b/extensions/renderer/set_icon_natives.cc
@@ -44,18 +44,30 @@
v8::Local<v8::Context> v8_context = context()->v8_context();
v8::Isolate* isolate = v8_context->GetIsolate();
v8::Local<v8::Object> data =
- image_data->Get(v8::String::NewFromUtf8(isolate, "data"))
+ image_data
+ ->Get(v8::String::NewFromUtf8(isolate, "data",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())
->ToObject(isolate);
- int width = image_data->Get(v8::String::NewFromUtf8(isolate, "width"))
+ int width = image_data
+ ->Get(v8::String::NewFromUtf8(
+ isolate, "width", v8::NewStringType::kInternalized)
+ .ToLocalChecked())
->Int32Value(v8_context)
.FromMaybe(0);
- int height = image_data->Get(v8::String::NewFromUtf8(isolate, "height"))
- ->Int32Value(v8_context)
- .FromMaybe(0);
+ int height =
+ image_data
+ ->Get(v8::String::NewFromUtf8(isolate, "height",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())
+ ->Int32Value(v8_context)
+ .FromMaybe(0);
if (width <= 0 || height <= 0) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidDimensions)));
+ v8::String::NewFromUtf8(isolate, kInvalidDimensions,
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked()));
return false;
}
@@ -64,23 +76,32 @@
int max_width = (std::numeric_limits<int>::max() / 4) / height;
if (width > max_width) {
isolate->ThrowException(v8::Exception::Error(
- v8::String::NewFromUtf8(isolate, kInvalidDimensions)));
+ v8::String::NewFromUtf8(isolate, kInvalidDimensions,
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked()));
return false;
}
- int data_length = data->Get(v8::String::NewFromUtf8(isolate, "length"))
- ->Int32Value(v8_context)
- .FromMaybe(0);
+ int data_length =
+ data->Get(v8::String::NewFromUtf8(isolate, "length",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())
+ ->Int32Value(v8_context)
+ .FromMaybe(0);
if (data_length != 4 * width * height) {
- isolate->ThrowException(
- v8::Exception::Error(v8::String::NewFromUtf8(isolate, kInvalidData)));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, kInvalidData,
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked()));
return false;
}
SkBitmap bitmap;
if (!bitmap.tryAllocN32Pixels(width, height)) {
- isolate->ThrowException(
- v8::Exception::Error(v8::String::NewFromUtf8(isolate, kNoMemory)));
+ isolate->ThrowException(v8::Exception::Error(
+ v8::String::NewFromUtf8(isolate, kNoMemory,
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked()));
return false;
}
bitmap.eraseARGB(0, 0, 0, 0);
@@ -128,7 +149,10 @@
v8::Local<v8::Object>* bitmap_set_value) {
v8::Isolate* isolate = context()->v8_context()->GetIsolate();
v8::Local<v8::Object> image_data_set =
- details->Get(v8::String::NewFromUtf8(isolate, "imageData"))
+ details
+ ->Get(v8::String::NewFromUtf8(isolate, "imageData",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked())
->ToObject(isolate);
DCHECK(bitmap_set_value);
@@ -160,12 +184,16 @@
return;
v8::Local<v8::Object> dict(v8::Object::New(args.GetIsolate()));
- dict->Set(v8::String::NewFromUtf8(args.GetIsolate(), "imageData"),
+ dict->Set(v8::String::NewFromUtf8(args.GetIsolate(), "imageData",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
bitmap_set_value);
- if (details->Has(v8::String::NewFromUtf8(args.GetIsolate(), "tabId"))) {
- dict->Set(
- v8::String::NewFromUtf8(args.GetIsolate(), "tabId"),
- details->Get(v8::String::NewFromUtf8(args.GetIsolate(), "tabId")));
+ v8::Local<v8::String> tabId =
+ v8::String::NewFromUtf8(args.GetIsolate(), "tabId",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked();
+ if (details->Has(tabId)) {
+ dict->Set(tabId, details->Get(tabId));
}
args.GetReturnValue().Set(dict);
}
diff --git a/extensions/renderer/v8_context_native_handler.cc b/extensions/renderer/v8_context_native_handler.cc
index 1ae5ef69..b7e6653c 100644
--- a/extensions/renderer/v8_context_native_handler.cc
+++ b/extensions/renderer/v8_context_native_handler.cc
@@ -35,11 +35,19 @@
v8::Maybe<bool> maybe =
ret->SetPrototype(context_->v8_context(), v8::Null(isolate));
CHECK(maybe.IsJust() && maybe.FromJust());
- ret->Set(v8::String::NewFromUtf8(isolate, "is_available"),
+ ret->Set(v8::String::NewFromUtf8(isolate, "is_available",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
v8::Boolean::New(isolate, availability.is_available()));
- ret->Set(v8::String::NewFromUtf8(isolate, "message"),
- v8::String::NewFromUtf8(isolate, availability.message().c_str()));
- ret->Set(v8::String::NewFromUtf8(isolate, "result"),
+ ret->Set(v8::String::NewFromUtf8(isolate, "message",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
+ v8::String::NewFromUtf8(isolate, availability.message().c_str(),
+ v8::NewStringType::kNormal)
+ .ToLocalChecked());
+ ret->Set(v8::String::NewFromUtf8(isolate, "result",
+ v8::NewStringType::kInternalized)
+ .ToLocalChecked(),
v8::Integer::New(isolate, availability.result()));
args.GetReturnValue().Set(ret);
}