summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 21:01:53 +0000
committeraa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-08 21:01:53 +0000
commitd2d89d83b409ef32bcbf7fbafe0d4e33c95515f0 (patch)
tree92b8d293fa14edb50312d1fe565852f29823fbdb
parentbca924e224f92b919ac329147e7ba3526b9ce12e (diff)
downloadchromium_src-d2d89d83b409ef32bcbf7fbafe0d4e33c95515f0.zip
chromium_src-d2d89d83b409ef32bcbf7fbafe0d4e33c95515f0.tar.gz
chromium_src-d2d89d83b409ef32bcbf7fbafe0d4e33c95515f0.tar.bz2
Fix user scripts not getting initialized.
BUG=13290,13128 TEST=Add --enable-user-scripts to command line without --enable-extensions or --load-extension. Start Chrome, user scripts should work. Also run ui tests with --enable-extensions. Review URL: http://codereview.chromium.org/119256 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17898 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/extensions/extensions_service.cc20
-rw-r--r--chrome/browser/extensions/extensions_service_unittest.cc52
-rw-r--r--chrome/browser/renderer_host/browser_render_process_host.cc9
-rw-r--r--chrome/test/testing_profile.h6
4 files changed, 31 insertions, 56 deletions
diff --git a/chrome/browser/extensions/extensions_service.cc b/chrome/browser/extensions/extensions_service.cc
index 0b0e31a..388bd71 100644
--- a/chrome/browser/extensions/extensions_service.cc
+++ b/chrome/browser/extensions/extensions_service.cc
@@ -359,25 +359,17 @@ void ExtensionsService::OnExtensionsLoaded(ExtensionList* new_extensions) {
}
}
- // If extensions aren't enabled, we still want to add themes. However, themes
- // should not trigger EXTENSIONS_LOADED.
- // TODO(aa): This can be re-enabled when BUG 13128 is fixed.
- bool has_extension = false;
for (ExtensionList::iterator iter = new_extensions->begin();
iter != new_extensions->end(); ++iter) {
- if (extensions_enabled() || (*iter)->IsTheme()) {
+ if (extensions_enabled() || (*iter)->IsTheme())
extensions_.push_back(*iter);
- if (!(*iter)->IsTheme())
- has_extension = true;
- }
}
- if (has_extension) {
- NotificationService::current()->Notify(
- NotificationType::EXTENSIONS_LOADED,
- NotificationService::AllSources(),
- Details<ExtensionList>(new_extensions));
- }
+ NotificationService::current()->Notify(
+ NotificationType::EXTENSIONS_LOADED,
+ NotificationService::AllSources(),
+ Details<ExtensionList>(new_extensions));
+
delete new_extensions;
}
diff --git a/chrome/browser/extensions/extensions_service_unittest.cc b/chrome/browser/extensions/extensions_service_unittest.cc
index e7cdd6b..630e71f 100644
--- a/chrome/browser/extensions/extensions_service_unittest.cc
+++ b/chrome/browser/extensions/extensions_service_unittest.cc
@@ -138,20 +138,9 @@ class ExtensionsServiceTest
service_->set_extensions_enabled(enabled);
}
- void TestInstallExtension(const FilePath& path,
- bool should_succeed) {
- InstallExtension(path, should_succeed, false);
- }
-
- void TestInstallTheme(const FilePath& path,
- bool should_succeed) {
- InstallExtension(path, should_succeed, true);
- }
-
protected:
void InstallExtension(const FilePath& path,
- bool should_succeed,
- bool is_theme) {
+ bool should_succeed) {
ASSERT_TRUE(file_util::PathExists(path));
service_->InstallExtension(path);
loop_.RunAllPending();
@@ -161,19 +150,12 @@ class ExtensionsServiceTest
EXPECT_TRUE(installed_) << path.value();
- // Themes aren't loaded.
- if (is_theme)
- EXPECT_EQ(0u, loaded_.size()) << path.value();
- else
- EXPECT_EQ(1u, loaded_.size()) << path.value();
-
+ 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())) <<
- path.value();
- }
+ EXPECT_TRUE(service_->GetExtensionByID(loaded_[0]->id())) <<
+ path.value();
for (std::vector<std::string>::iterator err = errors.begin();
err != errors.end(); ++err) {
LOG(ERROR) << *err;
@@ -392,14 +374,14 @@ TEST_F(ExtensionsServiceTest, InstallExtension) {
// Extensions not enabled.
SetExtensionsEnabled(false);
FilePath path = extensions_path.AppendASCII("good.crx");
- TestInstallExtension(path, false);
+ InstallExtension(path, false);
SetExtensionsEnabled(true);
ValidatePrefKeyCount(0);
// A simple extension that should install without error.
path = extensions_path.AppendASCII("good.crx");
- TestInstallExtension(path, true);
+ InstallExtension(path, true);
// TODO(erikkay): verify the contents of the installed extension.
int pref_count = 0;
@@ -409,29 +391,29 @@ TEST_F(ExtensionsServiceTest, InstallExtension) {
// An extension with page actions.
path = extensions_path.AppendASCII("page_action.crx");
- TestInstallExtension(path, true);
+ InstallExtension(path, true);
ValidatePrefKeyCount(++pref_count);
ValidatePref(page_action, L"state", Extension::ENABLED);
ValidatePref(page_action, L"location", Extension::INTERNAL);
// 0-length extension file.
path = extensions_path.AppendASCII("not_an_extension.crx");
- TestInstallExtension(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
// Bad magic number.
path = extensions_path.AppendASCII("bad_magic.crx");
- TestInstallExtension(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
// Poorly formed JSON.
path = extensions_path.AppendASCII("bad_json.crx");
- TestInstallExtension(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
// Incorrect zip hash.
path = extensions_path.AppendASCII("bad_hash.crx");
- TestInstallExtension(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
// TODO(erikkay): add more tests for many of the failure cases.
@@ -445,7 +427,7 @@ TEST_F(ExtensionsServiceTest, InstallTheme) {
// A theme.
FilePath path = extensions_path.AppendASCII("theme.crx");
- TestInstallTheme(path, true);
+ InstallExtension(path, true);
int pref_count = 0;
ValidatePrefKeyCount(++pref_count);
ValidatePref(theme_crx, L"state", Extension::ENABLED);
@@ -455,7 +437,7 @@ TEST_F(ExtensionsServiceTest, InstallTheme) {
// extensions are disabled.
SetExtensionsEnabled(false);
path = extensions_path.AppendASCII("theme2.crx");
- TestInstallTheme(path, true);
+ InstallExtension(path, true);
ValidatePrefKeyCount(++pref_count);
ValidatePref(theme2_crx, L"state", Extension::ENABLED);
ValidatePref(theme2_crx, L"location", Extension::INTERNAL);
@@ -464,12 +446,12 @@ TEST_F(ExtensionsServiceTest, InstallTheme) {
// A theme with extension elements. Themes cannot have extension elements so
// this test should fail.
path = extensions_path.AppendASCII("theme_with_extension.crx");
- TestInstallTheme(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
// A theme with image resources missing (misspelt path).
path = extensions_path.AppendASCII("theme_missing_image.crx");
- TestInstallTheme(path, false);
+ InstallExtension(path, false);
ValidatePrefKeyCount(pref_count);
}
@@ -515,7 +497,7 @@ TEST_F(ExtensionsServiceTest, UninstallExtension) {
// A simple extension that should install without error.
FilePath path = extensions_path.AppendASCII("good.crx");
- TestInstallExtension(path, true);
+ InstallExtension(path, true);
// The directory should be there now.
FilePath install_path = profile_->GetPath().AppendASCII("Extensions");
@@ -549,7 +531,7 @@ TEST_F(ExtensionsServiceTest, UninstallExtension) {
// Try uinstalling one that doesn't have a Current Version file for some
// reason.
unloaded_id_.clear();
- TestInstallExtension(path, true);
+ InstallExtension(path, true);
FilePath current_version_file =
extension_path.AppendASCII(ExtensionsService::kCurrentVersionFileName);
EXPECT_TRUE(file_util::Delete(current_version_file, true));
diff --git a/chrome/browser/renderer_host/browser_render_process_host.cc b/chrome/browser/renderer_host/browser_render_process_host.cc
index 9be8769..829ef47 100644
--- a/chrome/browser/renderer_host/browser_render_process_host.cc
+++ b/chrome/browser/renderer_host/browser_render_process_host.cc
@@ -483,9 +483,12 @@ void BrowserRenderProcessHost::InitExtensions() {
void BrowserRenderProcessHost::SendUserScriptsUpdate(
base::SharedMemory *shared_memory) {
base::SharedMemoryHandle handle_for_process;
- bool r = shared_memory->ShareToProcess(GetRendererProcessHandle(),
- &handle_for_process);
- DCHECK(r);
+ if (!shared_memory->ShareToProcess(GetRendererProcessHandle(),
+ &handle_for_process)) {
+ // This can legitimately fail if the renderer asserts at startup.
+ return;
+ }
+
if (base::SharedMemory::IsHandleValid(handle_for_process)) {
channel_->Send(new ViewMsg_UserScripts_UpdatedScripts(handle_for_process));
}
diff --git a/chrome/test/testing_profile.h b/chrome/test/testing_profile.h
index 7abdd8f..40b88dd 100644
--- a/chrome/test/testing_profile.h
+++ b/chrome/test/testing_profile.h
@@ -106,11 +106,9 @@ class TestingProfile : public Profile {
return NULL;
}
virtual PrefService* GetPrefs() {
- FilePath prefs_filename;
- PathService::Get(base::DIR_TEMP, &prefs_filename);
- prefs_filename =
- prefs_filename.Append(FILE_PATH_LITERAL("TestPreferences"));
if (!prefs_.get()) {
+ FilePath prefs_filename =
+ path_.Append(FILE_PATH_LITERAL("TestPreferences"));
prefs_.reset(new PrefService(prefs_filename, NULL));
Profile::RegisterUserPrefs(prefs_.get());
browser::RegisterAllPrefs(prefs_.get(), prefs_.get());