| Index: extensions/renderer/i18n_custom_bindings.cc
|
| diff --git a/extensions/renderer/i18n_custom_bindings.cc b/extensions/renderer/i18n_custom_bindings.cc
|
| index 762627088ef020edda6d8603b421177df45da93a..0ba18c208e06e1c468a0ebd8d68870af2d5a593c 100644
|
| --- a/extensions/renderer/i18n_custom_bindings.cc
|
| +++ b/extensions/renderer/i18n_custom_bindings.cc
|
| @@ -10,6 +10,7 @@
|
| #include "extensions/common/extension_messages.h"
|
| #include "extensions/common/message_bundle.h"
|
| #include "extensions/renderer/script_context.h"
|
| +#include "extensions/renderer/v8_maybe_helpers.h"
|
|
|
| namespace extensions {
|
|
|
| @@ -73,22 +74,28 @@ void I18NCustomBindings::GetL10nMessage(
|
| if (count > 9)
|
| return;
|
| for (uint32_t i = 0; i < count; ++i) {
|
| - substitutions.push_back(*v8::String::Utf8Value(placeholders->Get(
|
| - v8::Integer::New(isolate, i))));
|
| + v8::Local<v8::Value> param;
|
| + if (!placeholders->Get(isolate->GetCurrentContext(),
|
| + v8::Integer::New(isolate, i))
|
| + .ToLocal(¶m))
|
| + return;
|
| + substitutions.push_back(*v8::String::Utf8Value(param));
|
| }
|
| } else if (args[1]->IsString()) {
|
| // chrome.i18n.getMessage("message_name", "one param");
|
| substitutions.push_back(*v8::String::Utf8Value(args[1]));
|
| }
|
|
|
| - args.GetReturnValue().Set(v8::String::NewFromUtf8(
|
| - isolate,
|
| - ReplaceStringPlaceholders(message, substitutions, NULL).c_str()));
|
| + std::string ret_value =
|
| + ReplaceStringPlaceholders(message, substitutions, NULL);
|
| + if (ret_value.size() >= v8::String::kMaxLength)
|
| + return;
|
| + args.GetReturnValue().Set(ToV8String(isolate, ret_value.c_str()));
|
| }
|
|
|
| void I18NCustomBindings::GetL10nUILanguage(
|
| const v8::FunctionCallbackInfo<v8::Value>& args) {
|
| - args.GetReturnValue().Set(v8::String::NewFromUtf8(
|
| + args.GetReturnValue().Set(ToV8String(
|
| args.GetIsolate(), content::RenderThread::Get()->GetLocale().c_str()));
|
| }
|
|
|
|
|