Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(264)

Side by Side Diff: extensions/renderer/chrome_setting.cc

Issue 2843673002: [Extensions Bindings] Use gin::Arguments::GetAll() (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/declarative_event.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
OLDNEW
« no previous file with comments | « extensions/renderer/api_binding.cc ('k') | extensions/renderer/declarative_event.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698