OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "chrome/browser/extensions/extension_function.h" | 5 #include "chrome/browser/extensions/extension_function.h" |
6 | 6 |
7 #include "base/json/json_writer.h" | 7 #include "base/json/json_writer.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 9 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
10 | 10 |
11 void AsyncExtensionFunction::SetArgs(const Value* args) { | 11 void AsyncExtensionFunction::SetArgs(const Value* args) { |
(...skipping 12 matching lines...) Expand all Loading... |
24 void AsyncExtensionFunction::SendResponse(bool success) { | 24 void AsyncExtensionFunction::SendResponse(bool success) { |
25 if (!dispatcher()) | 25 if (!dispatcher()) |
26 return; | 26 return; |
27 if (bad_message_) { | 27 if (bad_message_) { |
28 dispatcher()->HandleBadMessage(this); | 28 dispatcher()->HandleBadMessage(this); |
29 } else { | 29 } else { |
30 dispatcher()->SendResponse(this, success); | 30 dispatcher()->SendResponse(this, success); |
31 } | 31 } |
32 } | 32 } |
33 | 33 |
| 34 bool AsyncExtensionFunction::HasOptionalArgument(size_t index) { |
| 35 DCHECK(args_->IsType(Value::TYPE_LIST)); |
| 36 ListValue* args_list = static_cast<ListValue*>(args_.get()); |
| 37 Value* value; |
| 38 return args_list->Get(index, &value) && !value->IsType(Value::TYPE_NULL); |
| 39 } |
| 40 |
34 std::string AsyncExtensionFunction::extension_id() { | 41 std::string AsyncExtensionFunction::extension_id() { |
35 DCHECK(dispatcher()); | 42 DCHECK(dispatcher()); |
36 return dispatcher()->extension_id(); | 43 return dispatcher()->extension_id(); |
37 } | 44 } |
38 | 45 |
39 Profile* AsyncExtensionFunction::profile() const { | 46 Profile* AsyncExtensionFunction::profile() const { |
40 DCHECK(dispatcher()); | 47 DCHECK(dispatcher()); |
41 return dispatcher()->profile(); | 48 return dispatcher()->profile(); |
42 } | 49 } |
OLD | NEW |