| Index: extensions/renderer/content_setting.cc
|
| diff --git a/extensions/renderer/content_setting.cc b/extensions/renderer/content_setting.cc
|
| index ffa085822e094c5f4aaf56c769a8194df6b55966..b21f729a7f6641ce892e97d4bc7a7c116a4cef49 100644
|
| --- a/extensions/renderer/content_setting.cc
|
| +++ b/extensions/renderer/content_setting.cc
|
| @@ -109,20 +109,6 @@ void ContentSetting::Get(gin::Arguments* arguments) {
|
| }
|
|
|
| void ContentSetting::Set(gin::Arguments* arguments) {
|
| - v8::Isolate* isolate = arguments->isolate();
|
| - v8::HandleScope handle_scope(isolate);
|
| - v8::Local<v8::Context> context = arguments->GetHolderCreationContext();
|
| -
|
| - v8::Local<v8::Value> value = arguments->PeekNext();
|
| - // The set schema included in the Schema object is generic, since it varies
|
| - // per-setting. However, this is only ever for a single setting, so we can
|
| - // enforce the types more thoroughly.
|
| - std::string error;
|
| - if (!value.IsEmpty() && !argument_spec_.ParseArgument(
|
| - context, value, *type_refs_, nullptr, &error)) {
|
| - arguments->ThrowTypeError("Invalid invocation");
|
| - return;
|
| - }
|
| HandleFunction("set", arguments);
|
| }
|
|
|
| @@ -149,7 +135,7 @@ void ContentSetting::HandleFunction(const std::string& method_name,
|
| if (!type_refs_->GetTypeMethodSignature(full_name)->ParseArgumentsToJSON(
|
| context, argument_list, *type_refs_, &converted_arguments, &callback,
|
| &error)) {
|
| - arguments->ThrowTypeError("Invalid invocation");
|
| + arguments->ThrowTypeError("Invalid invocation: " + error);
|
| return;
|
| }
|
|
|
| @@ -178,6 +164,21 @@ void ContentSetting::HandleFunction(const std::string& method_name,
|
| return;
|
| }
|
|
|
| + if (method_name == "set") {
|
| + v8::Local<v8::Value> value = argument_list[0];
|
| + // The set schema included in the Schema object is generic, since it varies
|
| + // per-setting. However, this is only ever for a single setting, so we can
|
| + // enforce the types more thoroughly.
|
| + // Note: we do this *after* checking if the setting is deprecated, since
|
| + // this validation will fail for deprecated settings.
|
| + std::string error;
|
| + if (!value.IsEmpty() && !argument_spec_.ParseArgument(
|
| + context, value, *type_refs_, nullptr, &error)) {
|
| + arguments->ThrowTypeError("Invalid invocation: " + error);
|
| + return;
|
| + }
|
| + }
|
| +
|
| converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_));
|
| request_handler_->StartRequest(
|
| context, "contentSettings." + method_name, std::move(converted_arguments),
|
|
|