Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: extensions/browser/api/execute_code_function.cc

Issue 1004253002: Enable <webview>.executeScript outside of Apps and Extensions [2] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: nits Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..8f3d616cfe7989b854bed156ca4328c2c9a63bb5 100644
--- a/extensions/browser/api/execute_code_function.cc
+++ b/extensions/browser/api/execute_code_function.cc
@@ -43,7 +43,8 @@ ExecuteCodeFunction::~ExecuteCodeFunction() {
void ExecuteCodeFunction::DidLoadFile(bool success, const std::string& data) {
if (!success || !details_->file) {
- DidLoadAndLocalizeFile(success, data);
+ DidLoadAndLocalizeFile(
+ resource_.relative_path().AsUTF8Unsafe(), success, data);
return;
}
@@ -102,24 +103,24 @@ void ExecuteCodeFunction::GetFileURLAndLocalizeCSS(
FROM_HERE,
base::Bind(&ExecuteCodeFunction::DidLoadAndLocalizeFile,
this,
+ resource_.relative_path().AsUTF8Unsafe(),
true,
localized_data));
}
-void ExecuteCodeFunction::DidLoadAndLocalizeFile(bool success,
+void ExecuteCodeFunction::DidLoadAndLocalizeFile(const std::string& file,
+ 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 +206,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;
« no previous file with comments | « extensions/browser/api/execute_code_function.h ('k') | extensions/browser/api/guest_view/web_view/web_view_internal_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698