Commit 47fc70c1 authored by miket@chromium.org's avatar miket@chromium.org

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
parent 26a6defe
...@@ -114,6 +114,7 @@ Provider::Provider(Profile* profile, ...@@ -114,6 +114,7 @@ Provider::Provider(Profile* profile,
download_location, creation_flags), download_location, creation_flags),
profile_(profile) { profile_(profile) {
DCHECK(profile); DCHECK(profile);
set_auto_acknowledge(true);
} }
void Provider::VisitRegisteredExtension() { void Provider::VisitRegisteredExtension() {
......
...@@ -1739,7 +1739,7 @@ void ExtensionService::HandleExtensionAlertAccept( ...@@ -1739,7 +1739,7 @@ void ExtensionService::HandleExtensionAlertAccept(
global_error.get_external_extension_ids(); global_error.get_external_extension_ids();
for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); for (ExtensionIdSet::const_iterator iter = extension_ids->begin();
iter != extension_ids->end(); ++iter) { iter != extension_ids->end(); ++iter) {
extension_prefs_->AcknowledgeExternalExtension(*iter); AcknowledgeExternalExtension(*iter);
} }
extension_ids = global_error.get_blacklisted_extension_ids(); extension_ids = global_error.get_blacklisted_extension_ids();
for (ExtensionIdSet::const_iterator iter = extension_ids->begin(); for (ExtensionIdSet::const_iterator iter = extension_ids->begin();
...@@ -1753,6 +1753,10 @@ void ExtensionService::HandleExtensionAlertAccept( ...@@ -1753,6 +1753,10 @@ void ExtensionService::HandleExtensionAlertAccept(
} }
} }
void ExtensionService::AcknowledgeExternalExtension(const std::string& id) {
extension_prefs_->AcknowledgeExternalExtension(id);
}
void ExtensionService::HandleExtensionAlertDetails( void ExtensionService::HandleExtensionAlertDetails(
const ExtensionGlobalError& global_error, Browser* browser) { const ExtensionGlobalError& global_error, Browser* browser) {
if (browser) { if (browser) {
...@@ -2245,7 +2249,8 @@ void ExtensionService::OnExternalExtensionFileFound( ...@@ -2245,7 +2249,8 @@ void ExtensionService::OnExternalExtensionFileFound(
const Version* version, const Version* version,
const FilePath& path, const FilePath& path,
Extension::Location location, Extension::Location location,
int creation_flags) { int creation_flags,
bool mark_acknowledged) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CHECK(Extension::IdIsValid(id)); CHECK(Extension::IdIsValid(id));
if (extension_prefs_->IsExternalExtensionUninstalled(id)) if (extension_prefs_->IsExternalExtensionUninstalled(id))
...@@ -2282,6 +2287,12 @@ void ExtensionService::OnExternalExtensionFileFound( ...@@ -2282,6 +2287,12 @@ void ExtensionService::OnExternalExtensionFileFound(
installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE);
installer->set_creation_flags(creation_flags); installer->set_creation_flags(creation_flags);
installer->InstallCrx(path); 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( void ExtensionService::ReportExtensionLoadError(
......
...@@ -505,7 +505,8 @@ class ExtensionService ...@@ -505,7 +505,8 @@ class ExtensionService
const Version* version, const Version* version,
const FilePath& path, const FilePath& path,
Extension::Location location, Extension::Location location,
int creation_flags) int creation_flags,
bool mark_acknowledged)
OVERRIDE; OVERRIDE;
virtual void OnExternalExtensionUpdateUrlFound(const std::string& id, virtual void OnExternalExtensionUpdateUrlFound(const std::string& id,
...@@ -527,6 +528,10 @@ class ExtensionService ...@@ -527,6 +528,10 @@ class ExtensionService
void HandleExtensionAlertAccept(const ExtensionGlobalError& global_error, void HandleExtensionAlertAccept(const ExtensionGlobalError& global_error,
Browser* browser); 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 // Opens the Extensions page because the user wants to get more details
// about the alerts. // about the alerts.
void HandleExtensionAlertDetails(const ExtensionGlobalError& global_error, void HandleExtensionAlertDetails(const ExtensionGlobalError& global_error,
......
...@@ -155,7 +155,7 @@ class MockExtensionProvider : public ExternalExtensionProviderInterface { ...@@ -155,7 +155,7 @@ class MockExtensionProvider : public ExternalExtensionProviderInterface {
visitor_->OnExternalExtensionFileFound( visitor_->OnExternalExtensionFileFound(
i->first, version.get(), i->second.second, location_, i->first, version.get(), i->second.second, location_,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
} }
visitor_->OnExternalProviderReady(this); visitor_->OnExternalProviderReady(this);
} }
...@@ -254,7 +254,8 @@ class MockProviderVisitor ...@@ -254,7 +254,8 @@ class MockProviderVisitor
const Version* version, const Version* version,
const FilePath& path, const FilePath& path,
Extension::Location unused, Extension::Location unused,
int creation_flags) { int creation_flags,
bool mark_acknowledged) {
EXPECT_EQ(Extension::NO_FLAGS, creation_flags); EXPECT_EQ(Extension::NO_FLAGS, creation_flags);
++ids_found_; ++ids_found_;
...@@ -1255,7 +1256,7 @@ TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) { ...@@ -1255,7 +1256,7 @@ TEST_F(ExtensionServiceTest, InstallingExternalExtensionWithFlags) {
// Install an external extension. // Install an external extension.
service_->OnExternalExtensionFileFound(good_crx, version.get(), service_->OnExternalExtensionFileFound(good_crx, version.get(),
path, Extension::EXTERNAL_PREF, path, Extension::EXTERNAL_PREF,
Extension::FROM_BOOKMARK); Extension::FROM_BOOKMARK, false);
loop_.RunAllPending(); loop_.RunAllPending();
const Extension* extension = service_->GetExtensionById(good_crx, false); const Extension* extension = service_->GetExtensionById(good_crx, false);
...@@ -1276,7 +1277,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { ...@@ -1276,7 +1277,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
// Install an external extension. // Install an external extension.
service_->OnExternalExtensionFileFound(good_crx, version.get(), service_->OnExternalExtensionFileFound(good_crx, version.get(),
path, Extension::EXTERNAL_PREF, path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
...@@ -1288,7 +1289,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { ...@@ -1288,7 +1289,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
// Try to re-install it externally. This should fail because of the killbit. // Try to re-install it externally. This should fail because of the killbit.
service_->OnExternalExtensionFileFound(good_crx, version.get(), service_->OnExternalExtensionFileFound(good_crx, version.get(),
path, Extension::EXTERNAL_PREF, path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
ValidateIntegerPref(good_crx, "location", ValidateIntegerPref(good_crx, "location",
...@@ -1299,7 +1300,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) { ...@@ -1299,7 +1300,7 @@ TEST_F(ExtensionServiceTest, UninstallingExternalExtensions) {
path = data_dir_.AppendASCII("good2.crx"); path = data_dir_.AppendASCII("good2.crx");
service_->OnExternalExtensionFileFound(good_crx, version.get(), service_->OnExternalExtensionFileFound(good_crx, version.get(),
path, Extension::EXTERNAL_PREF, path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false)); ASSERT_TRUE(NULL == service_->GetExtensionById(good_crx, false));
ValidateIntegerPref(good_crx, "location", ValidateIntegerPref(good_crx, "location",
...@@ -1359,7 +1360,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) { ...@@ -1359,7 +1360,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) {
// source that is not equal to the ID in the extension manifest. // source that is not equal to the ID in the extension manifest.
service_->OnExternalExtensionFileFound( service_->OnExternalExtensionFileFound(
wrong_id, version.get(), path, Extension::EXTERNAL_PREF, wrong_id, version.get(), path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
...@@ -1367,7 +1368,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) { ...@@ -1367,7 +1368,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongId) {
// Try again with the right ID. Expect success. // Try again with the right ID. Expect success.
service_->OnExternalExtensionFileFound( service_->OnExternalExtensionFileFound(
correct_id, version.get(), path, Extension::EXTERNAL_PREF, correct_id, version.get(), path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
} }
...@@ -1384,7 +1385,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) { ...@@ -1384,7 +1385,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
wrong_version.reset(Version::GetVersionFromString("1.2.3.4")); wrong_version.reset(Version::GetVersionFromString("1.2.3.4"));
service_->OnExternalExtensionFileFound( service_->OnExternalExtensionFileFound(
good_crx, wrong_version.get(), path, Extension::EXTERNAL_PREF, good_crx, wrong_version.get(), path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_FALSE(service_->GetExtensionById(good_crx, false)); ASSERT_FALSE(service_->GetExtensionById(good_crx, false));
...@@ -1394,7 +1395,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) { ...@@ -1394,7 +1395,7 @@ TEST_F(ExtensionServiceTest, FailOnWrongVersion) {
correct_version.reset(Version::GetVersionFromString("1.0.0.0")); correct_version.reset(Version::GetVersionFromString("1.0.0.0"));
service_->OnExternalExtensionFileFound( service_->OnExternalExtensionFileFound(
good_crx, correct_version.get(), path, Extension::EXTERNAL_PREF, good_crx, correct_version.get(), path, Extension::EXTERNAL_PREF,
Extension::NO_FLAGS); Extension::NO_FLAGS, false);
loop_.RunAllPending(); loop_.RunAllPending();
ASSERT_TRUE(service_->GetExtensionById(good_crx, false)); ASSERT_TRUE(service_->GetExtensionById(good_crx, false));
} }
...@@ -4172,7 +4173,7 @@ class ExtensionSourcePriorityTest : public ExtensionServiceTest { ...@@ -4172,7 +4173,7 @@ class ExtensionSourcePriorityTest : public ExtensionServiceTest {
service_->OnExternalExtensionFileFound( service_->OnExternalExtensionFileFound(
crx_id_, version.get(), crx_path_, Extension::EXTERNAL_PREF, 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. // Fake a request from sync to install an extension.
......
...@@ -56,7 +56,8 @@ ExternalExtensionProviderImpl::ExternalExtensionProviderImpl( ...@@ -56,7 +56,8 @@ ExternalExtensionProviderImpl::ExternalExtensionProviderImpl(
prefs_(NULL), prefs_(NULL),
ready_(false), ready_(false),
loader_(loader), loader_(loader),
creation_flags_(creation_flags) { creation_flags_(creation_flags),
auto_acknowledge_(false) {
loader_->Init(this); loader_->Init(this);
} }
...@@ -73,7 +74,7 @@ void ExternalExtensionProviderImpl::VisitRegisteredExtension() { ...@@ -73,7 +74,7 @@ void ExternalExtensionProviderImpl::VisitRegisteredExtension() {
void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) { void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 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. // away while |loader_| was working on the FILE thread.
if (!service_) return; if (!service_) return;
...@@ -196,7 +197,8 @@ void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) { ...@@ -196,7 +197,8 @@ void ExternalExtensionProviderImpl::SetPrefs(DictionaryValue* prefs) {
continue; continue;
} }
service_->OnExternalExtensionFileFound(extension_id, version.get(), path, service_->OnExternalExtensionFileFound(extension_id, version.get(), path,
crx_location_, creation_flags_); crx_location_, creation_flags_,
auto_acknowledge_);
} else { // if (has_external_update_url) } else { // if (has_external_update_url)
CHECK(has_external_update_url); // Checking of keys above ensures this. CHECK(has_external_update_url); // Checking of keys above ensures this.
if (download_location_ == Extension::INVALID) { if (download_location_ == Extension::INVALID) {
......
...@@ -71,6 +71,10 @@ class ExternalExtensionProviderImpl ...@@ -71,6 +71,10 @@ class ExternalExtensionProviderImpl
static const char kExternalUpdateUrl[]; static const char kExternalUpdateUrl[];
static const char kSupportedLocales[]; static const char kSupportedLocales[];
void set_auto_acknowledge(bool auto_acknowledge) {
auto_acknowledge_ = auto_acknowledge;
}
private: private:
// Location for external extensions that are provided by this provider from // Location for external extensions that are provided by this provider from
// local crx files. // local crx files.
...@@ -99,6 +103,10 @@ class ExternalExtensionProviderImpl ...@@ -99,6 +103,10 @@ class ExternalExtensionProviderImpl
// when calling Extenion::Create() by the crx installer. // when calling Extenion::Create() by the crx installer.
int creation_flags_; 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); DISALLOW_COPY_AND_ASSIGN(ExternalExtensionProviderImpl);
}; };
......
...@@ -30,7 +30,8 @@ class ExternalExtensionProviderInterface { ...@@ -30,7 +30,8 @@ class ExternalExtensionProviderInterface {
const Version* version, const Version* version,
const FilePath& path, const FilePath& path,
Extension::Location location, Extension::Location location,
int creation_flags) = 0; int creation_flags,
bool mark_acknowledged) = 0;
virtual void OnExternalExtensionUpdateUrlFound( virtual void OnExternalExtensionUpdateUrlFound(
const std::string& id, const std::string& id,
......
...@@ -69,7 +69,8 @@ class MockExternalPolicyExtensionProviderVisitor ...@@ -69,7 +69,8 @@ class MockExternalPolicyExtensionProviderVisitor
const Version* version, const Version* version,
const FilePath& path, const FilePath& path,
Extension::Location unused, Extension::Location unused,
int unused2) { int unused2,
bool unused3) {
ADD_FAILURE() << "There should be no external extensions from files."; ADD_FAILURE() << "There should be no external extensions from files.";
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment