Commit 4d82f7b6 authored by xiyuan's avatar xiyuan Committed by Commit bot

kiosk: Ensure launching latest version.

- Add a install_immediately flag to ExternalProviderImpl;
- Set install_immediately flag to true for kiosk app provider
  so that updated app install is not delayed;
- Set auto acknowledge since kiosk should not show external
  install alert;

BUG=461419

Review URL: https://codereview.chromium.org/974713002

Cr-Commit-Position: refs/heads/master@{#319005}
parent a575346d
...@@ -179,12 +179,13 @@ class MockExternalProviderVisitor ...@@ -179,12 +179,13 @@ class MockExternalProviderVisitor
public: public:
MockExternalProviderVisitor() {} MockExternalProviderVisitor() {}
MOCK_METHOD6(OnExternalExtensionFileFound, MOCK_METHOD7(OnExternalExtensionFileFound,
bool(const std::string&, bool(const std::string&,
const base::Version*, const base::Version*,
const base::FilePath&, const base::FilePath&,
extensions::Manifest::Location, extensions::Manifest::Location,
int, int,
bool,
bool)); bool));
MOCK_METHOD6(OnExternalExtensionUpdateUrlFound, MOCK_METHOD6(OnExternalExtensionUpdateUrlFound,
bool(const std::string&, bool(const std::string&,
...@@ -345,7 +346,7 @@ TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) { ...@@ -345,7 +346,7 @@ TEST_F(ServicesCustomizationDocumentTest, NoCustomizationIdInVpd) {
extensions::Extension::FROM_WEBSTORE | extensions::Extension::FROM_WEBSTORE |
extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(0); .Times(0);
...@@ -390,7 +391,7 @@ TEST_F(ServicesCustomizationDocumentTest, DefaultApps) { ...@@ -390,7 +391,7 @@ TEST_F(ServicesCustomizationDocumentTest, DefaultApps) {
extensions::Extension::FROM_WEBSTORE | extensions::Extension::FROM_WEBSTORE |
extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(0); .Times(0);
...@@ -401,7 +402,7 @@ TEST_F(ServicesCustomizationDocumentTest, DefaultApps) { ...@@ -401,7 +402,7 @@ TEST_F(ServicesCustomizationDocumentTest, DefaultApps) {
loader->StartLoading(); loader->StartLoading();
Mock::VerifyAndClearExpectations(&visitor); Mock::VerifyAndClearExpectations(&visitor);
EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(2); .Times(2);
...@@ -440,7 +441,7 @@ TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) { ...@@ -440,7 +441,7 @@ TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) {
extensions::Extension::FROM_WEBSTORE | extensions::Extension::FROM_WEBSTORE |
extensions::Extension::WAS_INSTALLED_BY_DEFAULT)); extensions::Extension::WAS_INSTALLED_BY_DEFAULT));
EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(0); .Times(0);
...@@ -451,7 +452,7 @@ TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) { ...@@ -451,7 +452,7 @@ TEST_F(ServicesCustomizationDocumentTest, CustomizationManifestNotFound) {
loader->StartLoading(); loader->StartLoading();
Mock::VerifyAndClearExpectations(&visitor); Mock::VerifyAndClearExpectations(&visitor);
EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(0); .Times(0);
......
...@@ -68,12 +68,13 @@ class MockExternalPolicyProviderVisitor ...@@ -68,12 +68,13 @@ class MockExternalPolicyProviderVisitor
MockExternalPolicyProviderVisitor(); MockExternalPolicyProviderVisitor();
virtual ~MockExternalPolicyProviderVisitor(); virtual ~MockExternalPolicyProviderVisitor();
MOCK_METHOD6(OnExternalExtensionFileFound, MOCK_METHOD7(OnExternalExtensionFileFound,
bool(const std::string&, bool(const std::string&,
const base::Version*, const base::Version*,
const base::FilePath&, const base::FilePath&,
extensions::Manifest::Location, extensions::Manifest::Location,
int, int,
bool,
bool)); bool));
MOCK_METHOD6(OnExternalExtensionUpdateUrlFound, MOCK_METHOD6(OnExternalExtensionUpdateUrlFound,
bool(const std::string&, bool(const std::string&,
...@@ -165,7 +166,7 @@ void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() { ...@@ -165,7 +166,7 @@ void DeviceLocalAccountExternalPolicyLoaderTest::TearDown() {
void DeviceLocalAccountExternalPolicyLoaderTest:: void DeviceLocalAccountExternalPolicyLoaderTest::
VerifyAndResetVisitorCallExpectations() { VerifyAndResetVisitorCallExpectations() {
Mock::VerifyAndClearExpectations(&visitor_); Mock::VerifyAndClearExpectations(&visitor_);
EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _)) EXPECT_CALL(visitor_, OnExternalExtensionFileFound(_, _, _, _, _, _, _))
.Times(0); .Times(0);
EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _)) EXPECT_CALL(visitor_, OnExternalExtensionUpdateUrlFound(_, _, _, _, _, _))
.Times(0); .Times(0);
...@@ -290,6 +291,7 @@ TEST_F(DeviceLocalAccountExternalPolicyLoaderTest, ForceInstallListSet) { ...@@ -290,6 +291,7 @@ TEST_F(DeviceLocalAccountExternalPolicyLoaderTest, ForceInstallListSet) {
cached_crx_path, cached_crx_path,
extensions::Manifest::EXTERNAL_POLICY, extensions::Manifest::EXTERNAL_POLICY,
_, _,
_,
_)); _));
EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get())) EXPECT_CALL(visitor_, OnExternalProviderReady(provider_.get()))
.Times(1) .Times(1)
......
...@@ -2108,7 +2108,8 @@ bool ExtensionService::OnExternalExtensionFileFound( ...@@ -2108,7 +2108,8 @@ bool ExtensionService::OnExternalExtensionFileFound(
const base::FilePath& path, const base::FilePath& path,
Manifest::Location location, Manifest::Location location,
int creation_flags, int creation_flags,
bool mark_acknowledged) { bool mark_acknowledged,
bool install_immediately) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
CHECK(crx_file::id_util::IdIsValid(id)); CHECK(crx_file::id_util::IdIsValid(id));
if (extension_prefs_->IsExternalExtensionUninstalled(id)) if (extension_prefs_->IsExternalExtensionUninstalled(id))
...@@ -2159,6 +2160,7 @@ bool ExtensionService::OnExternalExtensionFileFound( ...@@ -2159,6 +2160,7 @@ bool ExtensionService::OnExternalExtensionFileFound(
installer->set_expected_id(id); installer->set_expected_id(id);
installer->set_expected_version(*version); installer->set_expected_version(*version);
installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE); installer->set_install_cause(extension_misc::INSTALL_CAUSE_EXTERNAL_FILE);
installer->set_install_immediately(install_immediately);
installer->set_creation_flags(creation_flags); installer->set_creation_flags(creation_flags);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
extensions::InstallLimiter::Get(profile_)->Add(installer, path); extensions::InstallLimiter::Get(profile_)->Add(installer, path);
......
...@@ -232,7 +232,8 @@ class ExtensionService ...@@ -232,7 +232,8 @@ class ExtensionService
const base::FilePath& path, const base::FilePath& path,
extensions::Manifest::Location location, extensions::Manifest::Location location,
int creation_flags, int creation_flags,
bool mark_acknowledged) override; bool mark_acknowledged,
bool install_immediately) override;
bool OnExternalExtensionUpdateUrlFound( bool OnExternalExtensionUpdateUrlFound(
const std::string& id, const std::string& id,
const std::string& install_parameter, const std::string& install_parameter,
......
...@@ -74,7 +74,8 @@ class MockExternalPolicyProviderVisitor ...@@ -74,7 +74,8 @@ class MockExternalPolicyProviderVisitor
const base::FilePath& path, const base::FilePath& path,
Manifest::Location unused, Manifest::Location unused,
int unused2, int unused2,
bool unused3) override { bool unused3,
bool unused4) override {
ADD_FAILURE() << "There should be no external extensions from files."; ADD_FAILURE() << "There should be no external extensions from files.";
return false; return false;
} }
......
...@@ -80,7 +80,8 @@ ExternalProviderImpl::ExternalProviderImpl( ...@@ -80,7 +80,8 @@ ExternalProviderImpl::ExternalProviderImpl(
loader_(loader), loader_(loader),
profile_(profile), profile_(profile),
creation_flags_(creation_flags), creation_flags_(creation_flags),
auto_acknowledge_(false) { auto_acknowledge_(false),
install_immediately_(false) {
loader_->Init(this); loader_->Init(this);
} }
...@@ -271,7 +272,8 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) { ...@@ -271,7 +272,8 @@ void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
} }
service_->OnExternalExtensionFileFound(extension_id, &version, path, service_->OnExternalExtensionFileFound(extension_id, &version, path,
crx_location_, creation_flags, crx_location_, creation_flags,
auto_acknowledge_); auto_acknowledge_,
install_immediately_);
} 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_ == Manifest::INVALID_LOCATION) { if (download_location_ == Manifest::INVALID_LOCATION) {
...@@ -423,13 +425,15 @@ void ExternalProviderImpl::CreateExternalProviders( ...@@ -423,13 +425,15 @@ void ExternalProviderImpl::CreateExternalProviders(
chromeos::KioskAppManager::Get(); chromeos::KioskAppManager::Get();
DCHECK(kiosk_app_manager); DCHECK(kiosk_app_manager);
if (kiosk_app_manager && !kiosk_app_manager->external_loader_created()) { if (kiosk_app_manager && !kiosk_app_manager->external_loader_created()) {
provider_list->push_back(linked_ptr<ExternalProviderInterface>( scoped_ptr<ExternalProviderImpl> kiosk_app_provider(
new ExternalProviderImpl(service, new ExternalProviderImpl(
kiosk_app_manager->CreateExternalLoader(), service, kiosk_app_manager->CreateExternalLoader(), profile,
profile, Manifest::EXTERNAL_PREF, Manifest::INVALID_LOCATION,
Manifest::EXTERNAL_PREF, Extension::NO_FLAGS));
Manifest::INVALID_LOCATION, kiosk_app_provider->set_auto_acknowledge(true);
Extension::NO_FLAGS))); kiosk_app_provider->set_install_immediately(true);
provider_list->push_back(
linked_ptr<ExternalProviderInterface>(kiosk_app_provider.release()));
} }
#endif #endif
return; return;
......
...@@ -78,6 +78,10 @@ class ExternalProviderImpl : public ExternalProviderInterface { ...@@ -78,6 +78,10 @@ class ExternalProviderImpl : public ExternalProviderInterface {
auto_acknowledge_ = auto_acknowledge; auto_acknowledge_ = auto_acknowledge;
} }
void set_install_immediately(bool install_immediately) {
install_immediately_ = install_immediately;
}
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.
...@@ -113,6 +117,9 @@ class ExternalProviderImpl : public ExternalProviderInterface { ...@@ -113,6 +117,9 @@ class ExternalProviderImpl : public ExternalProviderInterface {
// the user doesn't see an alert about them. // the user doesn't see an alert about them.
bool auto_acknowledge_; bool auto_acknowledge_;
// Whether the extensions from this provider should be installed immediately.
bool install_immediately_;
DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl); DISALLOW_COPY_AND_ASSIGN(ExternalProviderImpl);
}; };
......
...@@ -40,7 +40,8 @@ class ExternalProviderInterface { ...@@ -40,7 +40,8 @@ class ExternalProviderInterface {
const base::FilePath& path, const base::FilePath& path,
Manifest::Location location, Manifest::Location location,
int creation_flags, int creation_flags,
bool mark_acknowledged) = 0; bool mark_acknowledged,
bool install_immediately) = 0;
// Return true if the extension install will proceed. Install might not // Return true if the extension install will proceed. Install might not
// proceed if the extension is already installed from a higher priority // proceed if the extension is already installed from a higher priority
......
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