OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 5 #ifndef EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 6 #define EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
7 | 7 |
8 #include "extensions/browser/api/execute_code_function.h" | 8 #include "extensions/browser/api/execute_code_function.h" |
9 | 9 |
10 #include "extensions/browser/component_extension_resource_manager.h" | 10 #include "extensions/browser/component_extension_resource_manager.h" |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 | 198 |
199 if (!CanExecuteScriptOnPage()) | 199 if (!CanExecuteScriptOnPage()) |
200 return false; | 200 return false; |
201 | 201 |
202 if (details_->code.get()) | 202 if (details_->code.get()) |
203 return Execute(*details_->code); | 203 return Execute(*details_->code); |
204 | 204 |
205 if (!details_->file.get()) | 205 if (!details_->file.get()) |
206 return false; | 206 return false; |
207 | 207 |
208 if (!extension()) | 208 return LoadFile(*details_->file); |
209 return false; | 209 } |
210 | 210 |
211 resource_ = extension()->GetResource(*details_->file); | 211 bool ExecuteCodeFunction::LoadFile(const std::string& file) { |
| 212 resource_ = extension()->GetResource(file); |
212 | 213 |
213 if (resource_.extension_root().empty() || resource_.relative_path().empty()) { | 214 if (resource_.extension_root().empty() || resource_.relative_path().empty()) { |
214 error_ = kNoCodeOrFileToExecuteError; | 215 error_ = kNoCodeOrFileToExecuteError; |
215 return false; | 216 return false; |
216 } | 217 } |
217 | 218 |
218 int resource_id; | 219 int resource_id; |
219 const ComponentExtensionResourceManager* | 220 const ComponentExtensionResourceManager* |
220 component_extension_resource_manager = | 221 component_extension_resource_manager = |
221 ExtensionsBrowserClient::Get() | 222 ExtensionsBrowserClient::Get() |
(...skipping 19 matching lines...) Expand all Loading... |
241 const base::ListValue& result) { | 242 const base::ListValue& result) { |
242 if (!error.empty()) | 243 if (!error.empty()) |
243 SetError(error); | 244 SetError(error); |
244 | 245 |
245 SendResponse(error.empty()); | 246 SendResponse(error.empty()); |
246 } | 247 } |
247 | 248 |
248 } // namespace extensions | 249 } // namespace extensions |
249 | 250 |
250 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 251 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
OLD | NEW |