| Index: extensions/browser/api/execute_code_function.cc
|
| diff --git a/extensions/browser/api/execute_code_function.cc b/extensions/browser/api/execute_code_function.cc
|
| index aebf61f46b4dd9dcec948e8cfa5326fea796cef3..ce4b29cfc2c9f68c070d35c3754cd639de4c2230 100644
|
| --- a/extensions/browser/api/execute_code_function.cc
|
| +++ b/extensions/browser/api/execute_code_function.cc
|
| @@ -124,6 +124,18 @@ void ExecuteCodeFunction::DidLoadAndLocalizeFile(bool success,
|
| }
|
| }
|
|
|
| +void ExecuteCodeFunction::DidLoadFileForWebUI(bool success,
|
| + const std::string& data) {
|
| + if (success) {
|
| + if (!base::IsStringUTF8(data))
|
| + SendResponse(false);
|
| + else if (!Execute(data))
|
| + SendResponse(false);
|
| + } else {
|
| + SendResponse(false);
|
| + }
|
| +}
|
| +
|
| bool ExecuteCodeFunction::Execute(const std::string& code_string) {
|
| ScriptExecutor* executor = GetScriptExecutor();
|
| if (!executor)
|
| @@ -205,8 +217,18 @@ bool ExecuteCodeFunction::RunAsync() {
|
| if (!details_->file.get())
|
| return false;
|
|
|
| - if (!extension())
|
| - return false;
|
| + if (!extension()) {
|
| + bool is_success = false;
|
| + is_success = LoadFileForWebUI(
|
| + *details_->file,
|
| + base::Bind(&ExecuteCodeFunction::DidLoadFileForWebUI, this));
|
| + if (!is_success) {
|
| + SendResponse(false);
|
| + return false;
|
| + }
|
| + // Will finish asynchronously.
|
| + return true;
|
| + }
|
|
|
| resource_ = extension()->GetResource(*details_->file);
|
|
|
|
|