| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "extensions/renderer/web_request_hooks.h" | 5 #include "extensions/renderer/web_request_hooks.h" |
| 6 | 6 |
| 7 #include "base/values.h" | 7 #include "base/values.h" |
| 8 #include "content/public/child/v8_value_converter.h" | 8 #include "content/public/child/v8_value_converter.h" |
| 9 #include "extensions/common/extension_api.h" | 9 #include "extensions/common/extension_api.h" |
| 10 #include "extensions/renderer/api_binding_hooks.h" | 10 #include "extensions/renderer/api_binding_hooks.h" |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 } | 52 } |
| 53 | 53 |
| 54 // The JS validates that the extra parameters passed to the web request event | 54 // The JS validates that the extra parameters passed to the web request event |
| 55 // match the expected schema. We need to initialize the event with that | 55 // match the expected schema. We need to initialize the event with that |
| 56 // schema. | 56 // schema. |
| 57 const base::DictionaryValue* event_spec = | 57 const base::DictionaryValue* event_spec = |
| 58 ExtensionAPI::GetSharedInstance()->GetSchema(event_name); | 58 ExtensionAPI::GetSharedInstance()->GetSchema(event_name); |
| 59 DCHECK(event_spec); | 59 DCHECK(event_spec); |
| 60 const base::ListValue* extra_params = nullptr; | 60 const base::ListValue* extra_params = nullptr; |
| 61 CHECK(event_spec->GetList("extraParameters", &extra_params)); | 61 CHECK(event_spec->GetList("extraParameters", &extra_params)); |
| 62 std::unique_ptr<content::V8ValueConverter> converter( | |
| 63 content::V8ValueConverter::create()); | |
| 64 v8::Local<v8::Value> extra_parameters_spec = | 62 v8::Local<v8::Value> extra_parameters_spec = |
| 65 converter->ToV8Value(extra_params, context); | 63 content::V8ValueConverter::Create()->ToV8Value(extra_params, context); |
| 66 | 64 |
| 67 v8::Local<v8::Function> get_event = get_event_value.As<v8::Function>(); | 65 v8::Local<v8::Function> get_event = get_event_value.As<v8::Function>(); |
| 68 v8::Local<v8::Value> args[] = { | 66 v8::Local<v8::Value> args[] = { |
| 69 gin::StringToSymbol(isolate, event_name), | 67 gin::StringToSymbol(isolate, event_name), |
| 70 v8::Undefined(isolate), // opt_argSchemas are ignored. | 68 v8::Undefined(isolate), // opt_argSchemas are ignored. |
| 71 extra_parameters_spec, | 69 extra_parameters_spec, |
| 72 // opt_eventOptions and opt_webViewInstanceId are ignored. | 70 // opt_eventOptions and opt_webViewInstanceId are ignored. |
| 73 }; | 71 }; |
| 74 *event_out = | 72 *event_out = |
| 75 run_js_sync.Run(get_event, context, arraysize(args), args).Get(isolate); | 73 run_js_sync.Run(get_event, context, arraysize(args), args).Get(isolate); |
| 76 return true; | 74 return true; |
| 77 } | 75 } |
| 78 | 76 |
| 79 } // namespace extensions | 77 } // namespace extensions |
| OLD | NEW |