Chromium Code Reviews| Index: chrome/browser/extensions/extension_service_test_with_install.cc |
| diff --git a/chrome/browser/extensions/extension_service_test_with_install.cc b/chrome/browser/extensions/extension_service_test_with_install.cc |
| index 9ff4cf07e22e1857a8d6baa20e5c2f03e42d08cc..c00b4c6f57e5d3f76823b5f3e41542ed706e5afd 100644 |
| --- a/chrome/browser/extensions/extension_service_test_with_install.cc |
| +++ b/chrome/browser/extensions/extension_service_test_with_install.cc |
| @@ -101,14 +101,24 @@ const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| const base::FilePath& dir_path, |
| const base::FilePath& pem_path, |
| InstallState install_state, |
| - int creation_flags) { |
| + int creation_flags, |
| + Manifest::Location install_location) { |
| base::FilePath crx_path; |
| base::ScopedTempDir temp_dir; |
| EXPECT_TRUE(temp_dir.CreateUniqueTempDir()); |
| crx_path = temp_dir.GetPath().AppendASCII("temp.crx"); |
| - |
| PackCRX(dir_path, pem_path, crx_path); |
| - return InstallCRX(crx_path, install_state, creation_flags); |
| + |
| + scoped_refptr<CrxInstaller> installer(CrxInstaller::CreateSilent(service())); |
| + installer->set_install_source(install_location); |
| + |
| + content::WindowedNotificationObserver observer( |
| + extensions::NOTIFICATION_CRX_INSTALLER_DONE, |
| + content::NotificationService::AllSources()); |
| + installer->InstallCrx(crx_path); |
|
catmullings
2016/10/12 18:58:58
This line replaces:
return InstallCRX(crx_path,
Devlin
2016/10/12 20:16:53
Instead, we should just be adding a new parameter
catmullings
2016/10/14 23:16:46
Done.
|
| + observer.Wait(); |
| + |
| + return VerifyCrxInstall(crx_path, install_state); |
| } |
| const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| @@ -116,14 +126,22 @@ const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| const base::FilePath& pem_path, |
| InstallState install_state) { |
| return PackAndInstallCRX(dir_path, pem_path, install_state, |
| - Extension::NO_FLAGS); |
| + Extension::NO_FLAGS, Manifest::Location::INTERNAL); |
|
catmullings
2016/10/12 18:58:58
What is the default for Manifest::Location among t
Devlin
2016/10/12 20:16:53
INTERNAL is the default value (you can see it in C
catmullings
2016/10/14 23:16:46
Done.
catmullings
2016/10/14 23:16:46
In addressing your other CL comment above, refacto
|
| +} |
| + |
| +const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| + const base::FilePath& dir_path, |
| + InstallState install_state) { |
| + return PackAndInstallCRX(dir_path, base::FilePath(), install_state, |
| + Extension::NO_FLAGS, Manifest::Location::INTERNAL); |
| } |
| const Extension* ExtensionServiceTestWithInstall::PackAndInstallCRX( |
| const base::FilePath& dir_path, |
| + Manifest::Location install_location, |
| InstallState install_state) { |
| return PackAndInstallCRX(dir_path, base::FilePath(), install_state, |
| - Extension::NO_FLAGS); |
| + Extension::NO_FLAGS, install_location); |
| } |
| // Attempts to install an extension. Use INSTALL_FAILED if the installation |
| @@ -330,6 +348,9 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| EXPECT_GT(pref_key_count, 0u); |
| ValidateIntegerPref(id, "state", expected_state); |
| + // We make a copy of the extension's id since the extension can be deleted |
| + // once it's uninstalled. |
| + std::string extension_id = id; |
| // Uninstall it. |
| if (use_helper) { |
| EXPECT_TRUE(ExtensionService::UninstallExtensionHelper( |
| @@ -343,7 +364,7 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| // We should get an unload notification. |
| EXPECT_FALSE(unloaded_id_.empty()); |
| - EXPECT_EQ(id, unloaded_id_); |
| + EXPECT_EQ(extension_id, unloaded_id_); |
| // Verify uninstalled state. |
| size_t new_pref_key_count = GetPrefKeyCount(); |
| @@ -355,7 +376,7 @@ void ExtensionServiceTestWithInstall::UninstallExtension( |
| } |
| // The extension should not be in the service anymore. |
| - EXPECT_FALSE(service()->GetInstalledExtension(id)); |
| + EXPECT_FALSE(service()->GetInstalledExtension(extension_id)); |
| base::RunLoop().RunUntilIdle(); |
| // The directory should be gone. |