diff options
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 23 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 8 | ||||
-rw-r--r-- | chrome/test/data/extensions/theme_missing_image.crx | bin | 0 -> 68408 bytes |
3 files changed, 28 insertions, 3 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index 16a7c1a..4d0f4f5 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -544,7 +544,28 @@ Extension* ExtensionsServiceBackend::LoadExtension( else extension->set_location(Extension::INTERNAL); - // TODO(glen): Add theme resource validation here. http://crbug.com/11678 + // Theme resource validation. + if (extension->IsTheme()) { + DictionaryValue* images_value = extension->GetThemeImages(); + DictionaryValue::key_iterator iter = images_value->begin_keys(); + while (iter != images_value->end_keys()) { + std::string val; + if (images_value->GetString(*iter, &val)) { + FilePath image_path = extension->path().AppendASCII(val); + if (!file_util::PathExists(image_path)) { + ReportExtensionLoadError(extension_path, + StringPrintf("Could not load '%s' for theme.", + WideToUTF8(image_path.ToWStringHack()).c_str())); + return NULL; + } + } + ++iter; + } + + // Themes cannot contain other extension types. + return extension.release(); + } + // Validate that claimed script resources actually exist. for (size_t i = 0; i < extension->content_scripts().size(); ++i) { const UserScript& script = extension->content_scripts()[i]; diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index f6016ce..e59a627 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -153,14 +153,14 @@ class ExtensionsServiceTest // Themes aren't loaded. if (is_theme) EXPECT_EQ(0u, loaded_.size()) << path.value(); - else + else EXPECT_EQ(1u, loaded_.size()) << path.value(); EXPECT_EQ(0u, errors.size()) << path.value(); EXPECT_EQ(total_successes_, service_->extensions()->size()) << path.value(); if (loaded_.size() > 0) { - EXPECT_TRUE(service_->GetExtensionByID(loaded_[0]->id())) << + EXPECT_TRUE(service_->GetExtensionByID(loaded_[0]->id())) << path.value(); } for (std::vector<std::string>::iterator err = errors.begin(); @@ -388,6 +388,10 @@ TEST_F(ExtensionsServiceTest, InstallTheme) { // A theme with extension elements. path = extensions_path.AppendASCII("theme_with_extension.crx"); TestInstallTheme(path, false); + + // A theme with image resources missing (misspelt path). + path = extensions_path.AppendASCII("theme_missing_image.crx"); + TestInstallTheme(path, false); } // Test that when an extension version is reinstalled, nothing happens. diff --git a/chrome/test/data/extensions/theme_missing_image.crx b/chrome/test/data/extensions/theme_missing_image.crx Binary files differnew file mode 100644 index 0000000..f8ee133d --- /dev/null +++ b/chrome/test/data/extensions/theme_missing_image.crx |