Chromium Code Reviews| 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 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 156 : ScriptExecutor::NO_RESULT, | 156 : ScriptExecutor::NO_RESULT, |
| 157 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); | 157 base::Bind(&ExecuteCodeFunction::OnExecuteCodeFinished, this)); |
| 158 return true; | 158 return true; |
| 159 } | 159 } |
| 160 | 160 |
| 161 bool ExecuteCodeFunction::HasPermission() { | 161 bool ExecuteCodeFunction::HasPermission() { |
| 162 return true; | 162 return true; |
| 163 } | 163 } |
| 164 | 164 |
| 165 bool ExecuteCodeFunction::RunAsync() { | 165 bool ExecuteCodeFunction::RunAsync() { |
| 166 EXTENSION_FUNCTION_VALIDATE(Init()); | 166 InitResult init_result = Init(); |
| 167 EXTENSION_FUNCTION_VALIDATE(init_result != VALIDATION_FAILURE); | |
| 168 if (init_result == FAILURE) { | |
| 169 if (init_error_) | |
| 170 error_ = init_error_.value(); | |
|
Devlin
2017/01/24 16:09:05
nit: since you're here, may as well make this SetE
lazyboy
2017/01/24 23:36:07
Done.
| |
| 171 return false; | |
| 172 } | |
| 167 | 173 |
| 168 if (!details_->code.get() && !details_->file.get()) { | 174 if (!details_->code.get() && !details_->file.get()) { |
| 169 error_ = kNoCodeOrFileToExecuteError; | 175 error_ = kNoCodeOrFileToExecuteError; |
| 170 return false; | 176 return false; |
| 171 } | 177 } |
| 172 if (details_->code.get() && details_->file.get()) { | 178 if (details_->code.get() && details_->file.get()) { |
| 173 error_ = kMoreThanOneValuesError; | 179 error_ = kMoreThanOneValuesError; |
| 174 return false; | 180 return false; |
| 175 } | 181 } |
| 176 | 182 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 245 const base::ListValue& result) { | 251 const base::ListValue& result) { |
| 246 if (!error.empty()) | 252 if (!error.empty()) |
| 247 SetError(error); | 253 SetError(error); |
| 248 | 254 |
| 249 SendResponse(error.empty()); | 255 SendResponse(error.empty()); |
| 250 } | 256 } |
| 251 | 257 |
| 252 } // namespace extensions | 258 } // namespace extensions |
| 253 | 259 |
| 254 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ | 260 #endif // EXTENSIONS_BROWSER_API_EXECUTE_CODE_FUNCTION_IMPL_H_ |
| OLD | NEW |