diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 23:25:27 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 23:25:27 +0000 |
commit | 4aca1ba4b4e571d389720710ca7964445bd1d5ac (patch) | |
tree | f1667f75091304a84928279b8d030486df860956 /chrome | |
parent | 92a68c6423124d6f73739d24d294df531d2cc621 (diff) | |
download | chromium_src-4aca1ba4b4e571d389720710ca7964445bd1d5ac.zip chromium_src-4aca1ba4b4e571d389720710ca7964445bd1d5ac.tar.gz chromium_src-4aca1ba4b4e571d389720710ca7964445bd1d5ac.tar.bz2 |
Revert 50050 - Revert r48693: This broke existing extensions that wanted to run script on XML
pages. For more info, see: http://code.google.com/p/chromium/issues/detail?id=39845#c7
TBR=rafaelw@chromium.org
TBR=aa@chromium.org
Review URL: http://codereview.chromium.org/2812006
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50051 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 47 | ||||
-rw-r--r-- | chrome/common/extensions/extension.cc | 2 | ||||
-rw-r--r-- | chrome/common/extensions/extension_l10n_util.cc | 4 | ||||
-rw-r--r-- | chrome/renderer/user_script_slave.cc | 15 | ||||
-rw-r--r-- | chrome/test/data/extensions/theme_i18n/_locales/en/messages.json | 8 | ||||
-rw-r--r-- | chrome/test/data/extensions/theme_i18n/manifest.json | 11 |
6 files changed, 19 insertions, 68 deletions
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 5d7aac7..e060b40 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -962,53 +962,6 @@ TEST_F(ExtensionsServiceTest, InstallTheme) { ValidatePrefKeyCount(pref_count); } -TEST_F(ExtensionsServiceTest, LoadLocalizedTheme) { - // Load. - InitializeEmptyExtensionsService(); - FilePath extension_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extension_path)); - extension_path = extension_path - .AppendASCII("extensions") - .AppendASCII("theme_i18n"); - - service_->LoadExtension(extension_path); - loop_.RunAllPending(); - EXPECT_EQ(0u, GetErrors().size()); - ASSERT_EQ(1u, loaded_.size()); - EXPECT_EQ(1u, service_->extensions()->size()); - EXPECT_EQ("name", service_->extensions()->at(0)->name()); - EXPECT_EQ("description", service_->extensions()->at(0)->description()); -} - -TEST_F(ExtensionsServiceTest, InstallLocalizedTheme) { - // Pack. - InitializeEmptyExtensionsService(); - FilePath extension_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extension_path)); - extension_path = extension_path - .AppendASCII("extensions") - .AppendASCII("theme_i18n"); - - FilePath crx_path; - ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &crx_path)); - crx_path = crx_path.AppendASCII("theme.crx"); - FilePath pem_path = crx_path.DirName().AppendASCII("theme.pem"); - - ASSERT_TRUE(file_util::Delete(crx_path, false)); - ASSERT_TRUE(file_util::Delete(pem_path, false)); - scoped_ptr<ExtensionCreator> creator(new ExtensionCreator()); - ASSERT_TRUE(creator->Run(extension_path, crx_path, FilePath(), pem_path)); - ASSERT_TRUE(file_util::PathExists(crx_path)); - - // Install. - service_->UnloadAllExtensions(); - InstallExtension(crx_path, true); - EXPECT_EQ(0u, GetErrors().size()); - EXPECT_EQ(1u, service_->extensions()->size()); - EXPECT_EQ("name", service_->extensions()->at(0)->name()); - EXPECT_EQ("description", service_->extensions()->at(0)->description()); -} - TEST_F(ExtensionsServiceTest, InstallApps) { InitializeEmptyExtensionsService(); FilePath extensions_path; diff --git a/chrome/common/extensions/extension.cc b/chrome/common/extensions/extension.cc index a5780c2..4a6bac3 100644 --- a/chrome/common/extensions/extension.cc +++ b/chrome/common/extensions/extension.cc @@ -92,8 +92,6 @@ const FilePath::CharType Extension::kMessagesFilename[] = // A list of all the keys allowed by themes. static const wchar_t* kValidThemeKeys[] = { - keys::kCurrentLocale, - keys::kDefaultLocale, keys::kDescription, keys::kName, keys::kPublicKey, diff --git a/chrome/common/extensions/extension_l10n_util.cc b/chrome/common/extensions/extension_l10n_util.cc index b9c2b1c..2848d8f 100644 --- a/chrome/common/extensions/extension_l10n_util.cc +++ b/chrome/common/extensions/extension_l10n_util.cc @@ -79,6 +79,10 @@ static bool LocalizeManifestValue(const std::wstring& key, bool LocalizeManifest(const ExtensionMessageBundle& messages, DictionaryValue* manifest, std::string* error) { + // Don't localize themes. + if (manifest->HasKey(keys::kTheme)) + return true; + // Initialize name. std::string result; if (!manifest->GetString(keys::kName, &result)) { diff --git a/chrome/renderer/user_script_slave.cc b/chrome/renderer/user_script_slave.cc index 4015484..25a272b 100644 --- a/chrome/renderer/user_script_slave.cc +++ b/chrome/renderer/user_script_slave.cc @@ -18,6 +18,8 @@ #include "chrome/renderer/extension_groups.h" #include "chrome/renderer/render_thread.h" #include "googleurl/src/gurl.h" +#include "third_party/WebKit/WebKit/chromium/public/WebDocument.h" +#include "third_party/WebKit/WebKit/chromium/public/WebElement.h" #include "third_party/WebKit/WebKit/chromium/public/WebFrame.h" #include "grit/renderer_resources.h" @@ -149,6 +151,19 @@ bool UserScriptSlave::InjectScripts(WebFrame* frame, if (!URLPattern::IsValidScheme(frame_url.scheme())) return true; + // Only inject user scripts into documents with an <html> tag as the root + // element. Note that WebCore fixes up html pages that lack a root HTML + // element so that they include one. Also, documents like text/plain and + // image/* are wrapped in a simple HTML document. + // + // Basically, this check filters out SVG documents and other types of XML + // documents. + if (frame->document().isNull() || + frame->document().documentElement().isNull() || + !frame->document().documentElement().hasTagName("html")) { + return true; + } + // Don't inject user scripts into the gallery itself. This prevents // a user script from removing the "report abuse" link, for example. if (frame_url.host() == GURL(extension_urls::kGalleryBrowsePrefix).host()) diff --git a/chrome/test/data/extensions/theme_i18n/_locales/en/messages.json b/chrome/test/data/extensions/theme_i18n/_locales/en/messages.json deleted file mode 100644 index 544e460..0000000 --- a/chrome/test/data/extensions/theme_i18n/_locales/en/messages.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "name": { - "message": "name" - }, - "description": { - "message": "description" - } -} diff --git a/chrome/test/data/extensions/theme_i18n/manifest.json b/chrome/test/data/extensions/theme_i18n/manifest.json deleted file mode 100644 index c35276e..0000000 --- a/chrome/test/data/extensions/theme_i18n/manifest.json +++ /dev/null @@ -1,11 +0,0 @@ -{ - "name": "__MSG_name__", - "description": "__MSG_description__", - "version": "1", - "default_locale": "en", - "theme": { - "properties" : { - "ntp_background_alignment" : "top" - } - } -} |