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..a1c2599cdfe4cce564808e4695a49c7434daaf8e 100644 |
--- a/extensions/browser/api/execute_code_function.cc |
+++ b/extensions/browser/api/execute_code_function.cc |
@@ -108,18 +108,22 @@ void ExecuteCodeFunction::GetFileURLAndLocalizeCSS( |
void ExecuteCodeFunction::DidLoadAndLocalizeFile(bool success, |
const std::string& data) { |
+ DidLoadFileForHost(resource_.relative_path().AsUTF8Unsafe(), success, data); |
+} |
+ |
+void ExecuteCodeFunction::DidLoadFileForHost(const std::string& file, |
Devlin
2015/03/25 17:55:15
Why not just make DidLoadAndLocalizeFile() take in
Xi Han
2015/03/25 20:49:21
That is much simpler! Thanks!
|
+ bool success, |
+ const std::string& data) { |
if (success) { |
if (!base::IsStringUTF8(data)) { |
- error_ = ErrorUtils::FormatErrorMessage( |
- kBadFileEncodingError, resource_.relative_path().AsUTF8Unsafe()); |
+ error_ = ErrorUtils::FormatErrorMessage(kBadFileEncodingError, file); |
SendResponse(false); |
} else if (!Execute(data)) |
SendResponse(false); |
} else { |
// TODO(viettrungluu): bug: there's no particular reason the path should be |
// UTF-8, in which case this may fail. |
- error_ = ErrorUtils::FormatErrorMessage( |
- kLoadFileError, resource_.relative_path().AsUTF8Unsafe()); |
+ error_ = ErrorUtils::FormatErrorMessage(kLoadFileError, file); |
SendResponse(false); |
} |
} |
@@ -205,10 +209,11 @@ bool ExecuteCodeFunction::RunAsync() { |
if (!details_->file.get()) |
return false; |
- if (!extension()) |
- return false; |
+ return LoadFile(*details_->file); |
+} |
- resource_ = extension()->GetResource(*details_->file); |
+bool ExecuteCodeFunction::LoadFile(const std::string& file) { |
+ resource_ = extension()->GetResource(file); |
if (resource_.extension_root().empty() || resource_.relative_path().empty()) { |
error_ = kNoCodeOrFileToExecuteError; |