Commit cdcc3a2e authored by Greg Thompson's avatar Greg Thompson Committed by Commit Bot

[mini_installer] Remove handling of --cleanup command line switch.

The cleanup code was removed in r819537. This CL removes the handling of
the --cleanup command line switch.

BUG=none
R=gab@chromium.org

Change-Id: Iba5e9cd057378ccf2712f12f37589d6b84b0f7d7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2502161
Commit-Queue: Gabriel Charette <gab@chromium.org>
Auto-Submit: Greg Thompson <grt@chromium.org>
Reviewed-by: default avatarGabriel Charette <gab@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821404}
parent 6c686364
...@@ -57,7 +57,6 @@ void Configuration::Clear() { ...@@ -57,7 +57,6 @@ void Configuration::Clear() {
} }
chrome_app_guid_ = google_update::kAppGuid; chrome_app_guid_ = google_update::kAppGuid;
command_line_ = nullptr; command_line_ = nullptr;
operation_ = INSTALL_PRODUCT;
argument_count_ = 0; argument_count_ = 0;
is_system_level_ = false; is_system_level_ = false;
has_invalid_switch_ = false; has_invalid_switch_ = false;
...@@ -86,7 +85,7 @@ bool Configuration::ParseCommandLine(const wchar_t* command_line) { ...@@ -86,7 +85,7 @@ bool Configuration::ParseCommandLine(const wchar_t* command_line) {
chrome_app_guid_ = google_update::kSxSAppGuid; chrome_app_guid_ = google_update::kSxSAppGuid;
#endif #endif
else if (0 == ::lstrcmpi(args_[i], L"--cleanup")) else if (0 == ::lstrcmpi(args_[i], L"--cleanup"))
operation_ = CLEANUP; has_invalid_switch_ = true;
else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame")) else if (0 == ::lstrcmpi(args_[i], L"--chrome-frame"))
has_invalid_switch_ = true; has_invalid_switch_ = true;
} }
......
...@@ -13,20 +13,12 @@ namespace mini_installer { ...@@ -13,20 +13,12 @@ namespace mini_installer {
// command line used to invoke it. // command line used to invoke it.
class Configuration { class Configuration {
public: public:
enum Operation {
INSTALL_PRODUCT,
CLEANUP,
};
Configuration(); Configuration();
~Configuration(); ~Configuration();
// Initializes this instance on the basis of the process's command line. // Initializes this instance on the basis of the process's command line.
bool Initialize(HMODULE module); bool Initialize(HMODULE module);
// Returns the desired operation dictated by the command line options.
Operation operation() const { return operation_; }
// Returns the program portion of the command line, or nullptr if it cannot be // Returns the program portion of the command line, or nullptr if it cannot be
// determined (e.g., by misuse). // determined (e.g., by misuse).
const wchar_t* program() const; const wchar_t* program() const;
...@@ -67,7 +59,6 @@ class Configuration { ...@@ -67,7 +59,6 @@ class Configuration {
const wchar_t* chrome_app_guid_; const wchar_t* chrome_app_guid_;
const wchar_t* command_line_; const wchar_t* command_line_;
int argument_count_; int argument_count_;
Operation operation_;
bool is_system_level_; bool is_system_level_;
bool has_invalid_switch_; bool has_invalid_switch_;
bool should_delete_extracted_files_; bool should_delete_extracted_files_;
......
...@@ -67,21 +67,6 @@ class MiniInstallerConfigurationTest : public ::testing::Test { ...@@ -67,21 +67,6 @@ class MiniInstallerConfigurationTest : public ::testing::Test {
DISALLOW_COPY_AND_ASSIGN(MiniInstallerConfigurationTest); DISALLOW_COPY_AND_ASSIGN(MiniInstallerConfigurationTest);
}; };
// Test that the operation type is CLEANUP iff --cleanup is on the cmdline.
TEST_F(MiniInstallerConfigurationTest, Operation) {
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe").operation());
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe --clean").operation());
EXPECT_EQ(Configuration::INSTALL_PRODUCT,
TestConfiguration(L"spam.exe --cleanupthis").operation());
EXPECT_EQ(Configuration::CLEANUP,
TestConfiguration(L"spam.exe --cleanup").operation());
EXPECT_EQ(Configuration::CLEANUP,
TestConfiguration(L"spam.exe --cleanup now").operation());
}
TEST_F(MiniInstallerConfigurationTest, Program) { TEST_F(MiniInstallerConfigurationTest, Program) {
EXPECT_EQ(nullptr, mini_installer::Configuration().program()); EXPECT_EQ(nullptr, mini_installer::Configuration().program());
EXPECT_TRUE(std::wstring(L"spam.exe") == EXPECT_TRUE(std::wstring(L"spam.exe") ==
...@@ -143,6 +128,7 @@ TEST_F(MiniInstallerConfigurationTest, HasInvalidSwitch) { ...@@ -143,6 +128,7 @@ TEST_F(MiniInstallerConfigurationTest, HasInvalidSwitch) {
EXPECT_FALSE(TestConfiguration(L"spam.exe").has_invalid_switch()); EXPECT_FALSE(TestConfiguration(L"spam.exe").has_invalid_switch());
EXPECT_TRUE( EXPECT_TRUE(
TestConfiguration(L"spam.exe --chrome-frame").has_invalid_switch()); TestConfiguration(L"spam.exe --chrome-frame").has_invalid_switch());
EXPECT_TRUE(TestConfiguration(L"spam.exe --cleanup").has_invalid_switch());
} }
TEST_F(MiniInstallerConfigurationTest, DeleteExtractedFilesDefaultTrue) { TEST_F(MiniInstallerConfigurationTest, DeleteExtractedFilesDefaultTrue) {
......
...@@ -736,24 +736,6 @@ bool GetWorkDir(HMODULE module, ...@@ -736,24 +736,6 @@ bool GetWorkDir(HMODULE module,
CreateWorkDir(base_path.get(), work_dir, exit_code); CreateWorkDir(base_path.get(), work_dir, exit_code);
} }
// Checks the command line for specific mini installer flags.
// If the function returns true, the command line has been processed and all
// required actions taken. The installer must exit and return the returned
// |exit_code|.
bool ProcessNonInstallOperations(const Configuration& configuration,
ProcessExitResult* exit_code) {
switch (configuration.operation()) {
case Configuration::CLEANUP:
// Cleanup has already taken place in DeleteOldChromeTempDirectories at
// this point, so just tell our caller to exit early.
*exit_code = ProcessExitResult(SUCCESS_EXIT_CODE);
return true;
default:
return false;
}
}
ProcessExitResult WMain(HMODULE module) { ProcessExitResult WMain(HMODULE module) {
ProcessExitResult exit_code = ProcessExitResult(SUCCESS_EXIT_CODE); ProcessExitResult exit_code = ProcessExitResult(SUCCESS_EXIT_CODE);
...@@ -767,11 +749,6 @@ ProcessExitResult WMain(HMODULE module) { ...@@ -767,11 +749,6 @@ ProcessExitResult WMain(HMODULE module) {
if (configuration.has_invalid_switch()) if (configuration.has_invalid_switch())
return ProcessExitResult(INVALID_OPTION); return ProcessExitResult(INVALID_OPTION);
// If the --cleanup switch was specified on the command line, then that means
// we should only do the cleanup and then exit.
if (ProcessNonInstallOperations(configuration, &exit_code))
return exit_code;
// First get a path where we can extract payload // First get a path where we can extract payload
bool work_dir_in_fallback = false; bool work_dir_in_fallback = false;
PathString base_path; PathString base_path;
......
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