diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 20:53:38 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-18 20:53:38 +0000 |
commit | 62aed757049b77c39b94a2b8939fa86419ade257 (patch) | |
tree | ec7a43d30024f0fc06f797cace5baba697d0cae0 /chrome/browser/extensions | |
parent | 50a74ff479715365b1eb54bee405b184b499ce36 (diff) | |
download | chromium_src-62aed757049b77c39b94a2b8939fa86419ade257.zip chromium_src-62aed757049b77c39b94a2b8939fa86419ade257.tar.gz chromium_src-62aed757049b77c39b94a2b8939fa86419ade257.tar.bz2 |
Some app-related manifest cleanup:
1) Group app-related keys under a new "app" key, and change
the implementation of IsApp() to just check that.
2) Rename IsApp() and IsTheme() -> is_app(), is_theme() to
match style guide.
3) Remove web_content.enabled. That was a stupid idea.
4) Make some kind of launch URL required for apps.
BUG=46632
Review URL: http://codereview.chromium.org/2836012
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50278 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-rw-r--r-- | chrome/browser/extensions/crx_installer.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_install_ui.cc | 6 | ||||
-rw-r--r-- | chrome/browser/extensions/extension_updater.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service.cc | 12 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_service_unittest.cc | 52 | ||||
-rw-r--r-- | chrome/browser/extensions/extensions_ui.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/sandboxed_extension_unpacker.cc | 5 |
7 files changed, 41 insertions, 40 deletions
diff --git a/chrome/browser/extensions/crx_installer.cc b/chrome/browser/extensions/crx_installer.cc index 832318c..e5bed66 100644 --- a/chrome/browser/extensions/crx_installer.cc +++ b/chrome/browser/extensions/crx_installer.cc @@ -137,7 +137,7 @@ void CrxInstaller::OnUnpackSuccess(const FilePath& temp_dir, // Determine whether to allow installation. We always allow themes and // external installs. - if (!extensions_enabled_ && !extension->IsTheme() && + if (!extensions_enabled_ && !extension->is_theme() && !Extension::IsExternalLocation(install_source_)) { ReportFailureFromFileThread("Extensions are not enabled."); return; diff --git a/chrome/browser/extensions/extension_install_ui.cc b/chrome/browser/extensions/extension_install_ui.cc index dfd3ef6..c5c22f6 100644 --- a/chrome/browser/extensions/extension_install_ui.cc +++ b/chrome/browser/extensions/extension_install_ui.cc @@ -158,7 +158,7 @@ void ExtensionInstallUI::ConfirmInstall(Delegate* delegate, // We special-case themes to not show any confirm UI. Instead they are // immediately installed, and then we show an infobar (see OnInstallSuccess) // to allow the user to revert if they don't like it. - if (extension->IsTheme()) { + if (extension->is_theme()) { // Remember the current theme in case the user pressed undo. Extension* previous_theme = profile_->GetTheme(); if (previous_theme) @@ -190,7 +190,7 @@ void ExtensionInstallUI::ConfirmUninstall(Delegate* delegate, } void ExtensionInstallUI::OnInstallSuccess(Extension* extension) { - if (extension->IsTheme()) { + if (extension->is_theme()) { ShowThemeInfoBar(previous_theme_id_, previous_use_system_theme_, extension, profile_); return; @@ -302,7 +302,7 @@ void ExtensionInstallUI::OnImageLoaded( void ExtensionInstallUI::ShowThemeInfoBar( const std::string& previous_theme_id, bool previous_use_system_theme, Extension* new_theme, Profile* profile) { - if (!new_theme->IsTheme()) + if (!new_theme->is_theme()) return; // Get last active normal browser of profile. diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc index f4a0443..781a200 100644 --- a/chrome/browser/extensions/extension_updater.cc +++ b/chrome/browser/extensions/extension_updater.cc @@ -166,7 +166,7 @@ void ManifestFetchesBuilder::AddExtension(const Extension& extension) { extension.id(), *extension.version(), extension.converted_from_user_script(), - extension.IsTheme(), + extension.is_theme(), extension.update_url()); } diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc index e474576..57ef3e2 100644 --- a/chrome/browser/extensions/extensions_service.cc +++ b/chrome/browser/extensions/extensions_service.cc @@ -504,7 +504,7 @@ void ExtensionsService::ContinueLoadAllExtensions( if ((*ex)->location() == Extension::LOAD) continue; - if ((*ex)->IsTheme()) { + if ((*ex)->is_theme()) { theme_count++; } else if ((*ex)->converted_from_user_script()) { user_script_count++; @@ -780,7 +780,7 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, // TODO(aa): Need to re-evaluate this branch. Does this still make sense now // that extensions are enabled by default? if (extensions_enabled() || - extension->IsTheme() || + extension->is_theme() || extension->location() == Extension::LOAD || Extension::IsExternalLocation(extension->location())) { Extension* old = GetExtensionByIdInternal(extension->id(), true, true); @@ -842,7 +842,7 @@ void ExtensionsService::OnExtensionLoaded(Extension* extension, void ExtensionsService::UpdateActiveExtensionsInCrashReporter() { std::set<std::string> extension_ids; for (size_t i = 0; i < extensions_.size(); ++i) { - if (!extensions_[i]->IsTheme()) + if (!extensions_[i]->is_theme()) extension_ids.insert(extensions_[i]->id()); } @@ -854,9 +854,9 @@ void ExtensionsService::OnExtensionInstalled(Extension* extension, PendingExtensionMap::iterator it = pending_extensions_.find(extension->id()); if (it != pending_extensions_.end() && - (it->second.is_theme != extension->IsTheme())) { + (it->second.is_theme != extension->is_theme())) { LOG(WARNING) << "Not installing pending extension " << extension->id() - << " with is_theme = " << extension->IsTheme() + << " with is_theme = " << extension->is_theme() << "; expected is_theme = " << it->second.is_theme; // Delete the extension directory since we're not going to load // it. @@ -871,7 +871,7 @@ void ExtensionsService::OnExtensionInstalled(Extension* extension, // If the extension is a theme, tell the profile (and therefore ThemeProvider) // to apply it. - if (extension->IsTheme()) { + if (extension->is_theme()) { NotificationService::current()->Notify( NotificationType::THEME_INSTALLED, Source<Profile>(profile_), diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc index 5d7aac7..f3660cf 100644 --- a/chrome/browser/extensions/extensions_service_unittest.cc +++ b/chrome/browser/extensions/extensions_service_unittest.cc @@ -61,7 +61,6 @@ const char* const good_crx = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; const char* const page_action = "obcimlgaoabeegjmmpldobjndiealpln"; const char* const theme_crx = "iamefpfkojoapidjnbafmgkgncegbkad"; const char* const theme2_crx = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; -const char* const app_crx = "hnbefahlpjbkldcaldefcnonockppomb"; struct ExtensionsOrder { bool operator()(const Extension* a, const Extension* b) { @@ -382,6 +381,22 @@ class ExtensionsServiceTest void TestExternalProvider(MockExtensionProvider* provider, Extension::Location location); + void PackAndInstallExtension(const FilePath& dir_path, + bool should_succeed) { + FilePath crx_path; + ASSERT_TRUE(PathService::Get(base::DIR_TEMP, &crx_path)); + crx_path = crx_path.AppendASCII("temp.crx"); + FilePath pem_path = crx_path.DirName().AppendASCII("temp.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(dir_path, crx_path, FilePath(), pem_path)); + ASSERT_TRUE(file_util::PathExists(crx_path)); + + InstallExtension(crx_path, should_succeed); + } + void InstallExtension(const FilePath& path, bool should_succeed) { ASSERT_TRUE(file_util::PathExists(path)); @@ -981,28 +996,15 @@ TEST_F(ExtensionsServiceTest, LoadLocalizedTheme) { } TEST_F(ExtensionsServiceTest, InstallLocalizedTheme) { - // Pack. InitializeEmptyExtensionsService(); - FilePath extension_path; - ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &extension_path)); - extension_path = extension_path + FilePath theme_path; + ASSERT_TRUE(PathService::Get(chrome::DIR_TEST_DATA, &theme_path)); + theme_path = theme_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)); + PackAndInstallExtension(theme_path, true); - // 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()); @@ -1016,18 +1018,20 @@ TEST_F(ExtensionsServiceTest, InstallApps) { extensions_path = extensions_path.AppendASCII("extensions"); // An empty app. - InstallExtension(extensions_path.AppendASCII("app1.crx"), true); + PackAndInstallExtension(extensions_path.AppendASCII("app1"), true); int pref_count = 0; ValidatePrefKeyCount(++pref_count); - ValidateIntegerPref(app_crx, L"state", Extension::ENABLED); - ValidateIntegerPref(app_crx, L"location", Extension::INTERNAL); + ASSERT_EQ(1u, service_->extensions()->size()); + std::string id = service_->extensions()->at(0)->id(); + ValidateIntegerPref(id, L"state", Extension::ENABLED); + ValidateIntegerPref(id, L"location", Extension::INTERNAL); // Another app with non-overlapping extent. Should succeed. - InstallExtension(extensions_path.AppendASCII("app2.crx"), true); + PackAndInstallExtension(extensions_path.AppendASCII("app2"), true); ValidatePrefKeyCount(++pref_count); // A third app whose extent overlaps the first. Should fail. - InstallExtension(extensions_path.AppendASCII("app3.crx"), false); + PackAndInstallExtension(extensions_path.AppendASCII("app3"), false); ValidatePrefKeyCount(pref_count); } @@ -1299,7 +1303,7 @@ TEST_F(ExtensionsServiceTest, UpdatePendingExtensionAlreadyInstalled) { // balk. service_->AddPendingExtensionInternal( good->id(), good->update_url(), *good->version(), - good->IsTheme(), kGoodInstallSilently); + good->is_theme(), kGoodInstallSilently); UpdateExtension(good->id(), path, true, true, false); diff --git a/chrome/browser/extensions/extensions_ui.cc b/chrome/browser/extensions/extensions_ui.cc index 9155705..8c6664b 100644 --- a/chrome/browser/extensions/extensions_ui.cc +++ b/chrome/browser/extensions/extensions_ui.cc @@ -55,7 +55,7 @@ namespace { static bool ShouldShowExtension(Extension* extension) { // Don't show the themes since this page's UI isn't really useful for // themes. - if (extension->IsTheme()) + if (extension->is_theme()) return false; // Don't show component extensions because they are only extensions as an diff --git a/chrome/browser/extensions/sandboxed_extension_unpacker.cc b/chrome/browser/extensions/sandboxed_extension_unpacker.cc index 600d832..ab72325 100644 --- a/chrome/browser/extensions/sandboxed_extension_unpacker.cc +++ b/chrome/browser/extensions/sandboxed_extension_unpacker.cc @@ -276,10 +276,7 @@ DictionaryValue* SandboxedExtensionUnpacker::RewriteManifestFile( static_cast<DictionaryValue*>(manifest.DeepCopy())); final_manifest->SetString(extension_manifest_keys::kPublicKey, public_key_); - bool web_content_enabled = false; - if (final_manifest->GetBoolean(extension_manifest_keys::kWebContentEnabled, - &web_content_enabled) && - web_content_enabled) { + if (final_manifest->HasKey(extension_manifest_keys::kApp)) { bool has_web_origin = final_manifest->Get(extension_manifest_keys::kWebOrigin, NULL); if (force_web_origin_override_) { |