diff options
author | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 07:29:51 +0000 |
---|---|---|
committer | miket@chromium.org <miket@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2011-12-06 07:29:51 +0000 |
commit | 47fc70c16a93058b6ccb4883a22c2b67c58b273e (patch) | |
tree | 1567bb8fd6b03ab1e8e6e1fe5e870342e4495f73 | |
parent | 26a6defebfd665f964c6dde5104aea6795e70f79 (diff) | |
download | chromium_src-47fc70c16a93058b6ccb4883a22c2b67c58b273e.zip chromium_src-47fc70c16a93058b6ccb4883a22c2b67c58b273e.tar.gz chromium_src-47fc70c16a93058b6ccb4883a22c2b67c58b273e.tar.bz2 |
Exempt default apps from external-extension alerts.
BUG=106188
TEST=added
Review URL: http://codereview.chromium.org/8800016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113144 0039d316-1c4b-4281-b951-d872f2087c98
8 files changed, 49 insertions, 19 deletions
diff --git a/chrome/browser/extensions/default_apps.cc b/chrome/browser/extensions/default_apps.cc index fbd85fe..33ed772 100644 --- a/chrome/browser/extensions/default_apps.cc +++ b/chrome/browser/extensions/default_apps.cc @@ -114,6 +114,7 @@ Provider::Provider(Profile* profile, download_location, creation_flags), profile_(profile) { DCHECK(profile); + set_auto_acknowledge(true); } void Provider::VisitRegisteredExtension() { diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc index 4f06365..8bf574a 100644 --- a/chrome/browser/extensions/extension_service.cc +++ b/chrome/browser/extensions/extension_service.cc @@ -1739,7 +1739,7 @@ void ExtensionService::HandleExtensionAlertAccept( global_error.get_external_extension_ids(); for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); iter != extension_ids->end(); ++iter) { - extension_prefs_->AcknowledgeExternalExtension(*iter); + AcknowledgeExternalExtension(*iter); } extension_ids = global_error.get_blacklisted_extension_ids(); for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); @@ -1753,6 +1753,10 @@ void ExtensionService::HandleExtensionAlertAccept( } } +void ExtensionService::AcknowledgeExternalExtension(const std::string& id) { + extension_prefs_->AcknowledgeExternalExtension(id); +} + void ExtensionService::HandleExtensionAlertDetails( const ExtensionGlobalError& global_error, Browser* browser) { if (browser) { @@ -2245,7 +2249,8 @@ void ExtensionService::OnExternalExtensionFileFound( const Version* version, const FilePath& path, Extension::Location location, - int creation_flags) { + int creation_flags, + bool mark_acknowledged) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(Extension::IdIsValid(id)); if (extension_prefs_->IsExternalExtensionUninstalled(id)) @@ -2282,6 +2287,12 @@ void ExtensionService::OnExternalExtensionFileFound( installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); installer->set_creation_flags(creation_flags); installer->InstallCrx(path); + + // Depending on the source, a new external extension might not need a user + // notification on installation. For such extensions, mark them acknowledged + // now to suppress the notification. + if (mark_acknowledged) + AcknowledgeExternalExtension(id); } void ExtensionService::ReportExtensionLoadError( diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h index 006d655..370ad22 100644 --- a/chrome/browser/extensions/extension_service.h +++ b/chrome/browser/extensions/extension_service.h @@ -505,7 +505,8 @@ class ExtensionService const Version* version, const FilePath& path, Extension::Location location, - int creation_flags) + int creation_flags, + bool mark_acknowledged) OVERRIDE; virtual void OnExternalExtensionUpdateUrlFound(const std::string& id, @@ -527,6 +528,10 @@ class ExtensionService void HandleExtensionAlertAccept(const ExtensionGlobalError& global_error, Browser* browser); + // Given a (presumably just-installed) extension id, mark that extension as + // acknowledged. + void AcknowledgeExternalExtension(const std::string& id); + // Opens the Extensions page because the user wants to get more details // about the alerts. void HandleExtensionAlertDetails(const ExtensionGlobalError& global_error, diff --git a/chrome/browser/extensions/extension_service_unittest.cc b/chrome/browser/extensions/extension_service_unittest.cc index 6f3fc61..78ef149 100644 --- a/chrome/browser/extensions/extension_service_unittest.cc +++ b/chrome/browser/extensions/extension_service_unittest.cc @@ -155,7 +155,7 @@ class MockExtensionProvider : public ExternalExtensionProviderInterface { visitor_->OnExternalExtensionFileFound( i->first, version.get(), i->second.second, location_, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); } visitor_->OnExternalProviderReady(this); } @@ -254,7 +254,8 @@ class MockProviderVisitor const Version* version, const FilePath& path, Extension::Location unused, - int creation_flags) { + int creation_flags, + bool mark_acknowledged) { EXPECT_EQ(Extension::NO_FLAGS, creation_flags); ++ids_found_; @@ -1255,7 +1256,7 @@ TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) { // Install an external extension. service_->OnExternalExtensionFileFound(good_crx, version.get(), path, Extension::EXTERNAL_PREF, - Extension::FROM_BOOKMARK); + Extension::FROM_BOOKMARK, false); loop_.RunAllPending(); const Extension* extension = service_->GetExtensionById(good_crx, false); @@ -1276,7 +1277,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { // Install an external extension. service_->OnExternalExtensionFileFound(good_crx, version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); @@ -1288,7 +1289,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { // Try to re-install it externally. This should fail because of the killbit. service_->OnExternalExtensionFileFound(good_crx, version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); ValidateIntegerPref(good_crx, "location", @@ -1299,7 +1300,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { path = data_dir_.AppendASCII("good2.crx"); service_->OnExternalExtensionFileFound(good_crx, version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); ValidateIntegerPref(good_crx, "location", @@ -1359,7 +1360,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) { // source that is not equal to the ID in the extension manifest. service_->OnExternalExtensionFileFound( wrong_id, version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); @@ -1367,7 +1368,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) { // Try again with the right ID. Expect success. service_->OnExternalExtensionFileFound( correct_id, version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); } @@ -1384,7 +1385,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) { wrong_version.reset(Version::GetVersionFromString("1.2.3.4")); service_->OnExternalExtensionFileFound( good_crx, wrong_version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); @@ -1394,7 +1395,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) { correct_version.reset(Version::GetVersionFromString("1.0.0.0")); service_->OnExternalExtensionFileFound( good_crx, correct_version.get(), path, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); loop_.RunAllPending(); ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); } @@ -4172,7 +4173,7 @@ class ExtensionSourcePriorityTest : public ExtensionServiceTest { service_->OnExternalExtensionFileFound( crx_id_, version.get(), crx_path_, Extension::EXTERNAL_PREF, - Extension::NO_FLAGS); + Extension::NO_FLAGS, false); } // Fake a request from sync to install an extension. diff --git a/chrome/browser/extensions/external_extension_provider_impl.cc b/chrome/browser/extensions/external_extension_provider_impl.cc index b8fbdb0..cc1dd9b 100644 --- a/chrome/browser/extensions/external_extension_provider_impl.cc +++ b/chrome/browser/extensions/external_extension_provider_impl.cc @@ -56,7 +56,8 @@ ExternalExtensionProviderImpl::ExternalExtensionProviderImpl( prefs_(NULL), ready_(false), loader_(loader), - creation_flags_(creation_flags) { + creation_flags_(creation_flags), + auto_acknowledge_(false) { loader_->Init(this); } @@ -73,7 +74,7 @@ void ExternalExtensionProviderImpl::VisitRegisteredExtension() { void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) { CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); - // Check if the service is still alive. It is possible that it had went + // Check if the service is still alive. It is possible that it went // away while |loader_| was working on the FILE thread. if (!service_) return; @@ -196,7 +197,8 @@ void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) { continue; } service_->OnExternalExtensionFileFound(extension_id, version.get(), path, - crx_location_, creation_flags_); + crx_location_, creation_flags_, + auto_acknowledge_); } else { // if (has_external_update_url) CHECK(has_external_update_url); // Checking of keys above ensures this. if (download_location_ == Extension::INVALID) { diff --git a/chrome/browser/extensions/external_extension_provider_impl.h b/chrome/browser/extensions/external_extension_provider_impl.h index 80044c9..242c6183 100644 --- a/chrome/browser/extensions/external_extension_provider_impl.h +++ b/chrome/browser/extensions/external_extension_provider_impl.h @@ -71,6 +71,10 @@ class ExternalExtensionProviderImpl static const char kExternalUpdateUrl[]; static const char kSupportedLocales[]; + void set_auto_acknowledge(bool auto_acknowledge) { + auto_acknowledge_ = auto_acknowledge; + } + private: // Location for external extensions that are provided by this provider from // local crx files. @@ -99,6 +103,10 @@ class ExternalExtensionProviderImpl // when calling Extenion::Create() by the crx installer. int creation_flags_; + // Whether loaded extensions should be automatically acknowledged, so that + // the user doesn't see an alert about them. + bool auto_acknowledge_; + DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl); }; diff --git a/chrome/browser/extensions/external_extension_provider_interface.h b/chrome/browser/extensions/external_extension_provider_interface.h index 313e2c7..088b179 100644 --- a/chrome/browser/extensions/external_extension_provider_interface.h +++ b/chrome/browser/extensions/external_extension_provider_interface.h @@ -30,7 +30,8 @@ class ExternalExtensionProviderInterface { const Version* version, const FilePath& path, Extension::Location location, - int creation_flags) = 0; + int creation_flags, + bool mark_acknowledged) = 0; virtual void OnExternalExtensionUpdateUrlFound( const std::string& id, diff --git a/chrome/browser/extensions/external_policy_extension_loader_unittest.cc b/chrome/browser/extensions/external_policy_extension_loader_unittest.cc index c5fa9f5..4d0d085 100644 --- a/chrome/browser/extensions/external_policy_extension_loader_unittest.cc +++ b/chrome/browser/extensions/external_policy_extension_loader_unittest.cc @@ -69,7 +69,8 @@ class MockExternalPolicyExtensionProviderVisitor const Version* version, const FilePath& path, Extension::Location unused, - int unused2) { + int unused2, + bool unused3) { ADD_FAILURE() << "There should be no external extensions from files."; } |