OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_test_utils.h" | 5 #include "chrome/browser/extensions/extension_function_test_utils.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
| 8 #include <utility> |
8 | 9 |
9 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
10 #include "base/json/json_reader.h" | 11 #include "base/json/json_reader.h" |
11 #include "base/macros.h" | 12 #include "base/macros.h" |
12 #include "base/values.h" | 13 #include "base/values.h" |
13 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" | 14 #include "chrome/browser/extensions/api/tabs/tabs_constants.h" |
14 #include "chrome/browser/profiles/profile.h" | 15 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/ui/browser.h" | 16 #include "chrome/browser/ui/browser.h" |
16 #include "components/crx_file/id_util.h" | 17 #include "components/crx_file/id_util.h" |
17 #include "extensions/browser/api_test_utils.h" | 18 #include "extensions/browser/api_test_utils.h" |
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
158 bool should_post_quit_; | 159 bool should_post_quit_; |
159 }; | 160 }; |
160 | 161 |
161 bool RunFunction(UIThreadExtensionFunction* function, | 162 bool RunFunction(UIThreadExtensionFunction* function, |
162 const std::string& args, | 163 const std::string& args, |
163 Browser* browser, | 164 Browser* browser, |
164 RunFunctionFlags flags) { | 165 RunFunctionFlags flags) { |
165 scoped_ptr<base::ListValue> parsed_args(ParseList(args)); | 166 scoped_ptr<base::ListValue> parsed_args(ParseList(args)); |
166 EXPECT_TRUE(parsed_args.get()) | 167 EXPECT_TRUE(parsed_args.get()) |
167 << "Could not parse extension function arguments: " << args; | 168 << "Could not parse extension function arguments: " << args; |
168 return RunFunction(function, parsed_args.Pass(), browser, flags); | 169 return RunFunction(function, std::move(parsed_args), browser, flags); |
169 } | 170 } |
170 | 171 |
171 bool RunFunction(UIThreadExtensionFunction* function, | 172 bool RunFunction(UIThreadExtensionFunction* function, |
172 scoped_ptr<base::ListValue> args, | 173 scoped_ptr<base::ListValue> args, |
173 Browser* browser, | 174 Browser* browser, |
174 RunFunctionFlags flags) { | 175 RunFunctionFlags flags) { |
175 TestFunctionDispatcherDelegate dispatcher_delegate(browser); | 176 TestFunctionDispatcherDelegate dispatcher_delegate(browser); |
176 scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher( | 177 scoped_ptr<extensions::ExtensionFunctionDispatcher> dispatcher( |
177 new extensions::ExtensionFunctionDispatcher(browser->profile())); | 178 new extensions::ExtensionFunctionDispatcher(browser->profile())); |
178 dispatcher->set_delegate(&dispatcher_delegate); | 179 dispatcher->set_delegate(&dispatcher_delegate); |
179 // TODO(yoz): The cast is a hack; these flags should be defined in | 180 // TODO(yoz): The cast is a hack; these flags should be defined in |
180 // only one place. See crbug.com/394840. | 181 // only one place. See crbug.com/394840. |
181 return extensions::api_test_utils::RunFunction( | 182 return extensions::api_test_utils::RunFunction( |
182 function, | 183 function, std::move(args), browser->profile(), std::move(dispatcher), |
183 args.Pass(), | |
184 browser->profile(), | |
185 dispatcher.Pass(), | |
186 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); | 184 static_cast<extensions::api_test_utils::RunFunctionFlags>(flags)); |
187 } | 185 } |
188 | 186 |
189 } // namespace extension_function_test_utils | 187 } // namespace extension_function_test_utils |
OLD | NEW |