OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/browser/extension_function.h" | 5 #include "extensions/browser/extension_function.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
284 bool ExtensionFunction::user_gesture() const { | 284 bool ExtensionFunction::user_gesture() const { |
285 return user_gesture_ || UserGestureForTests::GetInstance()->HaveGesture(); | 285 return user_gesture_ || UserGestureForTests::GetInstance()->HaveGesture(); |
286 } | 286 } |
287 | 287 |
288 ExtensionFunction::ResponseValue ExtensionFunction::NoArguments() { | 288 ExtensionFunction::ResponseValue ExtensionFunction::NoArguments() { |
289 return ResponseValue(new ArgumentListResponseValue( | 289 return ResponseValue(new ArgumentListResponseValue( |
290 name(), "NoArguments", this, base::WrapUnique(new base::ListValue()))); | 290 name(), "NoArguments", this, base::WrapUnique(new base::ListValue()))); |
291 } | 291 } |
292 | 292 |
293 ExtensionFunction::ResponseValue ExtensionFunction::OneArgument( | 293 ExtensionFunction::ResponseValue ExtensionFunction::OneArgument( |
294 base::Value* arg) { | 294 std::unique_ptr<base::Value> arg) { |
295 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 295 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
296 args->Append(arg); | 296 args->Append(std::move(arg)); |
297 return ResponseValue(new ArgumentListResponseValue(name(), "OneArgument", | 297 return ResponseValue(new ArgumentListResponseValue(name(), "OneArgument", |
298 this, std::move(args))); | 298 this, std::move(args))); |
299 } | 299 } |
300 | 300 |
301 ExtensionFunction::ResponseValue ExtensionFunction::OneArgument( | |
302 std::unique_ptr<base::Value> arg) { | |
303 return OneArgument(arg.release()); | |
304 } | |
305 | |
306 ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments( | 301 ExtensionFunction::ResponseValue ExtensionFunction::TwoArguments( |
307 base::Value* arg1, | 302 std::unique_ptr<base::Value> arg1, |
308 base::Value* arg2) { | 303 std::unique_ptr<base::Value> arg2) { |
309 std::unique_ptr<base::ListValue> args(new base::ListValue()); | 304 std::unique_ptr<base::ListValue> args(new base::ListValue()); |
310 args->Append(arg1); | 305 args->Append(std::move(arg1)); |
311 args->Append(arg2); | 306 args->Append(std::move(arg2)); |
312 return ResponseValue(new ArgumentListResponseValue(name(), "TwoArguments", | 307 return ResponseValue(new ArgumentListResponseValue(name(), "TwoArguments", |
313 this, std::move(args))); | 308 this, std::move(args))); |
314 } | 309 } |
315 | 310 |
316 ExtensionFunction::ResponseValue ExtensionFunction::ArgumentList( | 311 ExtensionFunction::ResponseValue ExtensionFunction::ArgumentList( |
317 std::unique_ptr<base::ListValue> args) { | 312 std::unique_ptr<base::ListValue> args) { |
318 return ResponseValue(new ArgumentListResponseValue(name(), "ArgumentList", | 313 return ResponseValue(new ArgumentListResponseValue(name(), "ArgumentList", |
319 this, std::move(args))); | 314 this, std::move(args))); |
320 } | 315 } |
321 | 316 |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
572 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { | 567 ExtensionFunction::ResponseAction SyncIOThreadExtensionFunction::Run() { |
573 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) | 568 return RespondNow(RunSync() ? ArgumentList(std::move(results_)) |
574 : Error(error_)); | 569 : Error(error_)); |
575 } | 570 } |
576 | 571 |
577 // static | 572 // static |
578 bool SyncIOThreadExtensionFunction::ValidationFailure( | 573 bool SyncIOThreadExtensionFunction::ValidationFailure( |
579 SyncIOThreadExtensionFunction* function) { | 574 SyncIOThreadExtensionFunction* function) { |
580 return false; | 575 return false; |
581 } | 576 } |
OLD | NEW |