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..394d0dd5deec884a97350d817891956367b516ef 100644 |
--- a/extensions/browser/api/execute_code_function.cc |
+++ b/extensions/browser/api/execute_code_function.cc |
@@ -41,6 +41,13 @@ ExecuteCodeFunction::ExecuteCodeFunction() { |
ExecuteCodeFunction::~ExecuteCodeFunction() { |
} |
+bool ExecuteCodeFunction::LoadFileForWebUI( |
+ const std::string& file_src, |
+ const WebUILoadFileCallback& callback) { |
+ callback.Run(false, std::string()); |
+ return false; |
+} |
+ |
void ExecuteCodeFunction::DidLoadFile(bool success, const std::string& data) { |
if (!success || !details_->file) { |
DidLoadAndLocalizeFile(success, data); |
@@ -124,6 +131,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 +224,18 @@ bool ExecuteCodeFunction::RunAsync() { |
if (!details_->file.get()) |
return false; |
- if (!extension()) |
- return false; |
+ if (!extension()) { |
asargent_no_longer_on_chrome
2015/03/17 21:41:14
should this test be "if (IsWebView())" instead of
Xi Han
2015/03/17 22:28:21
This is for webUI, which we have to use different
|
+ 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; |
+ } |
asargent_no_longer_on_chrome
2015/03/17 21:41:14
Also, can you explain why this code is here in thi
Xi Han
2015/03/17 22:28:21
That is fair. Move them back to web_view_internal_
|
resource_ = extension()->GetResource(*details_->file); |