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/declarative_event.h" | 5 #include "extensions/renderer/declarative_event.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <memory> | 8 #include <memory> |
9 | 9 |
10 #include "base/memory/ptr_util.h" | 10 #include "base/memory/ptr_util.h" |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 HandleFunction("events.Event.getRules", "events.getRules", arguments); | 167 HandleFunction("events.Event.getRules", "events.getRules", arguments); |
168 } | 168 } |
169 | 169 |
170 void DeclarativeEvent::HandleFunction(const std::string& signature_name, | 170 void DeclarativeEvent::HandleFunction(const std::string& signature_name, |
171 const std::string& request_name, | 171 const std::string& request_name, |
172 gin::Arguments* arguments) { | 172 gin::Arguments* arguments) { |
173 v8::Isolate* isolate = arguments->isolate(); | 173 v8::Isolate* isolate = arguments->isolate(); |
174 v8::HandleScope handle_scope(isolate); | 174 v8::HandleScope handle_scope(isolate); |
175 v8::Local<v8::Context> context = arguments->GetHolderCreationContext(); | 175 v8::Local<v8::Context> context = arguments->GetHolderCreationContext(); |
176 | 176 |
177 // TODO(devlin): This pattern is getting common. We should probably pull it | 177 std::vector<v8::Local<v8::Value>> argument_list = arguments->GetAll(); |
178 // out somewhere. | |
179 std::vector<v8::Local<v8::Value>> argument_list; | |
180 if (arguments->Length() > 0) { | |
181 // Just copying handles should never fail. | |
182 CHECK(arguments->GetRemaining(&argument_list)); | |
183 } | |
184 | 178 |
185 // The events API has two undocumented parameters for each function: the name | 179 // The events API has two undocumented parameters for each function: the name |
186 // of the event, and the "webViewInstanceId". Currently, stub 0 for webview | 180 // of the event, and the "webViewInstanceId". Currently, stub 0 for webview |
187 // instance id. | 181 // instance id. |
188 // TODO(devlin): We'll need to fix that to get it to work with webviews. | 182 // TODO(devlin): We'll need to fix that to get it to work with webviews. |
189 // Longer term, it would be *great* to just factor that out entirely (can we | 183 // Longer term, it would be *great* to just factor that out entirely (can we |
190 // not get that information on the browser side? Investigate). | 184 // not get that information on the browser side? Investigate). |
191 argument_list.insert(argument_list.begin(), | 185 argument_list.insert(argument_list.begin(), |
192 {gin::StringToSymbol(isolate, event_name_), | 186 {gin::StringToSymbol(isolate, event_name_), |
193 v8::Integer::New(isolate, 0)}); | 187 v8::Integer::New(isolate, 0)}); |
(...skipping 10 matching lines...) Expand all Loading... |
204 arguments->ThrowTypeError("Invalid invocation"); | 198 arguments->ThrowTypeError("Invalid invocation"); |
205 return; | 199 return; |
206 } | 200 } |
207 | 201 |
208 request_handler_->StartRequest( | 202 request_handler_->StartRequest( |
209 context, request_name, std::move(converted_arguments), callback, | 203 context, request_name, std::move(converted_arguments), callback, |
210 v8::Local<v8::Function>(), binding::RequestThread::UI); | 204 v8::Local<v8::Function>(), binding::RequestThread::UI); |
211 } | 205 } |
212 | 206 |
213 } // namespace extensions | 207 } // namespace extensions |
OLD | NEW |