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/chrome_setting.h" | 5 #include "extensions/renderer/chrome_setting.h" |
6 | 6 |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "base/values.h" | 9 #include "base/values.h" |
10 #include "extensions/renderer/api_event_handler.h" | 10 #include "extensions/renderer/api_event_handler.h" |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
126 } | 126 } |
127 return event; | 127 return event; |
128 } | 128 } |
129 | 129 |
130 void ChromeSetting::HandleFunction(const std::string& method_name, | 130 void ChromeSetting::HandleFunction(const std::string& method_name, |
131 gin::Arguments* arguments) { | 131 gin::Arguments* arguments) { |
132 v8::Isolate* isolate = arguments->isolate(); | 132 v8::Isolate* isolate = arguments->isolate(); |
133 v8::HandleScope handle_scope(isolate); | 133 v8::HandleScope handle_scope(isolate); |
134 v8::Local<v8::Context> context = arguments->GetHolderCreationContext(); | 134 v8::Local<v8::Context> context = arguments->GetHolderCreationContext(); |
135 | 135 |
136 std::vector<v8::Local<v8::Value>> argument_list; | 136 std::vector<v8::Local<v8::Value>> argument_list = arguments->GetAll(); |
137 if (arguments->Length() > 0) { | |
138 // Just copying handles should never fail. | |
139 CHECK(arguments->GetRemaining(&argument_list)); | |
140 } | |
141 | 137 |
142 std::string full_name = "types.ChromeSetting." + method_name; | 138 std::string full_name = "types.ChromeSetting." + method_name; |
143 std::unique_ptr<base::ListValue> converted_arguments; | 139 std::unique_ptr<base::ListValue> converted_arguments; |
144 v8::Local<v8::Function> callback; | 140 v8::Local<v8::Function> callback; |
145 std::string error; | 141 std::string error; |
146 if (!type_refs_->GetTypeMethodSignature(full_name)->ParseArgumentsToJSON( | 142 if (!type_refs_->GetTypeMethodSignature(full_name)->ParseArgumentsToJSON( |
147 context, argument_list, *type_refs_, &converted_arguments, &callback, | 143 context, argument_list, *type_refs_, &converted_arguments, &callback, |
148 &error)) { | 144 &error)) { |
149 arguments->ThrowTypeError("Invalid invocation"); | 145 arguments->ThrowTypeError("Invalid invocation"); |
150 return; | 146 return; |
151 } | 147 } |
152 | 148 |
153 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_)); | 149 converted_arguments->Insert(0u, base::MakeUnique<base::Value>(pref_name_)); |
154 request_handler_->StartRequest( | 150 request_handler_->StartRequest( |
155 context, full_name, std::move(converted_arguments), callback, | 151 context, full_name, std::move(converted_arguments), callback, |
156 v8::Local<v8::Function>(), binding::RequestThread::UI); | 152 v8::Local<v8::Function>(), binding::RequestThread::UI); |
157 } | 153 } |
158 | 154 |
159 } // namespace extensions | 155 } // namespace extensions |
OLD | NEW |