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

Unified Diff: chrome/common/extensions/extension_file_util.cc

Issue 9150008: Introduce background.scripts feature for extension manifests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: ready to land Created 8 years, 11 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: chrome/common/extensions/extension_file_util.cc
diff --git a/chrome/common/extensions/extension_file_util.cc b/chrome/common/extensions/extension_file_util.cc
index e0912421a7e3077d014681306906c85b851740db..ebc064443aab7b62950233e387af8cb957350514 100644
--- a/chrome/common/extensions/extension_file_util.cc
+++ b/chrome/common/extensions/extension_file_util.cc
@@ -288,12 +288,26 @@ bool ValidateExtension(const Extension* extension, std::string* error) {
}
}
+ // Validate that background scripts exist.
+ for (size_t i = 0; i < extension->background_scripts().size(); ++i) {
+ if (!file_util::PathExists(
+ extension->GetResource(
+ extension->background_scripts()[i]).GetFilePath())) {
+ *error = l10n_util::GetStringFUTF8(
+ IDS_EXTENSION_LOAD_BACKGROUND_SCRIPT_FAILED,
+ UTF8ToUTF16(extension->background_scripts()[i]));
+ return false;
+ }
+ }
+
// Validate background page location, except for hosted apps, which should use
// an external URL. Background page for hosted apps are verified when the
// extension is created (in Extension::InitFromValue)
- if (!extension->background_url().is_empty() && !extension->is_hosted_app()) {
+ if (extension->has_background_page() &&
+ !extension->is_hosted_app() &&
+ extension->background_scripts().empty()) {
FilePath page_path = ExtensionURLToRelativeFilePath(
- extension->background_url());
+ extension->GetBackgroundURL());
const FilePath path = extension->GetResource(page_path).GetFilePath();
if (path.empty() || !file_util::PathExists(path)) {
*error =
« no previous file with comments | « chrome/common/extensions/extension_constants.cc ('k') | chrome/common/extensions/extension_file_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698