Chromium Code Reviews| Index: chrome/installer/util/installer_state.cc |
| diff --git a/chrome/installer/util/installer_state.cc b/chrome/installer/util/installer_state.cc |
| index b7ab42ba04e7635808035d563462fb39292e7a5c..3f75f9037bd2a37cad7e1af32eec1be20db5129c 100644 |
| --- a/chrome/installer/util/installer_state.cc |
| +++ b/chrome/installer/util/installer_state.cc |
| @@ -119,23 +119,21 @@ void InstallerState::Initialize(const CommandLine& command_line, |
| const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); |
| if (prefs.install_chrome()) { |
| - Product* p = |
| - AddProductFromPreferences(BrowserDistribution::CHROME_BROWSER, prefs, |
| - machine_state); |
| + Product* p = AddProductFromPreferences( |
| + BrowserDistribution::CHROME_BROWSER, prefs, machine_state); |
| VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| << " distribution: " << p->distribution()->GetAppShortCutName(); |
| } |
| if (prefs.install_chrome_frame()) { |
| - Product* p = |
| - AddProductFromPreferences(BrowserDistribution::CHROME_FRAME, prefs, |
| - machine_state); |
| + Product* p = AddProductFromPreferences( |
| + BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| << " distribution: " << p->distribution()->GetAppShortCutName(); |
| } |
| + |
| if (prefs.install_chrome_app_host()) { |
| - Product* p = |
| - AddProductFromPreferences(BrowserDistribution::CHROME_APP_HOST, prefs, |
| - machine_state); |
| + Product* p = AddProductFromPreferences( |
| + BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); |
| VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| << " distribution: " << p->distribution()->GetAppShortCutName(); |
| } |
| @@ -167,10 +165,8 @@ void InstallerState::Initialize(const CommandLine& command_line, |
| if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| // Force binaries to be installed/updated. |
| - Product* p = |
| - AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, |
| - prefs, |
| - machine_state); |
| + Product* p = AddProductFromPreferences( |
| + BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| VLOG(1) << "Install distribution: " |
| << p->distribution()->GetAppShortCutName(); |
| } |
| @@ -178,19 +174,38 @@ void InstallerState::Initialize(const CommandLine& command_line, |
| if (is_uninstall && prefs.is_multi_install()) { |
| if (FindProduct(BrowserDistribution::CHROME_BROWSER)) { |
| - const ProductState* chrome_frame_state = machine_state.GetProductState( |
| - system_install(), BrowserDistribution::CHROME_FRAME); |
| - |
| - if (chrome_frame_state != NULL && |
| - chrome_frame_state->uninstall_command().HasSwitch( |
| - switches::kChromeFrameReadyMode) && |
| - !FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| - // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. |
| - Product* p = AddProductFromPreferences( |
| - BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| - |
| - VLOG(1) << "Uninstall distribution: " |
| - << p->distribution()->GetAppShortCutName(); |
| + // Uninstall each product of type |type| listed below based on the |
| + // presence or absence of |switch_name| in that product's uninstall |
| + // command. |
| + const struct { |
| + BrowserDistribution::Type type; |
| + const char* switch_name; |
| + bool switch_expected; |
| + } conditional_additions[] = { |
| + // If Chrome Frame is installed in Ready Mode, remove it with Chrome. |
| + { BrowserDistribution::CHROME_FRAME, switches::kChromeFrameReadyMode, |
| + true }, |
|
gab
2012/11/19 17:24:38
1) This "true" should be aligned with "BrowserDist
huangs
2012/11/19 19:06:05
Done. Did 1) and 2) only.
|
| + // App Host (non-App Launcher) is installed. Remove it with Chrome. |
| + // Hwoever, for system-level Chrome uninstall, any installed user-level |
| + // (non-App Launcher) App Host will remain. When the orphaned |
| + // app_host.exe is executed, it prompts user for further action. |
|
gab
2012/11/19 17:24:38
What about:
// If the App Host is installed, but
huangs
2012/11/19 19:06:05
Done.
|
| + { BrowserDistribution::CHROME_APP_HOST, switches::kChromeAppLauncher, |
| + false }, |
|
gab
2012/11/19 17:24:38
same as above.
huangs
2012/11/19 19:06:05
Done.
|
| + }; |
| + |
| + for (size_t i = 0; i < arraysize(conditional_additions); ++i) { |
| + const ProductState* product_state = machine_state.GetProductState( |
| + system_install(), conditional_additions[i].type); |
| + if (product_state != NULL && |
| + product_state->uninstall_command().HasSwitch( |
| + conditional_additions[i].switch_name) == |
| + conditional_additions[i].switch_expected && |
|
gab
2012/11/19 17:24:38
nit: indent 4 more spaces.
huangs
2012/11/19 19:06:05
Done.
|
| + !FindProduct(conditional_additions[i].type)) { |
| + Product* p = AddProductFromPreferences( |
| + conditional_additions[i].type, prefs, machine_state); |
| + VLOG(1) << "Uninstall distribution: " |
| + << p->distribution()->GetAppShortCutName(); |
| + } |
| } |
| } |
| @@ -236,9 +251,8 @@ void InstallerState::Initialize(const CommandLine& command_line, |
| // The product is being uninstalled. |
| } |
| if (!keep_binaries) { |
| - Product* p = |
| - AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, prefs, |
| - machine_state); |
| + Product* p = AddProductFromPreferences( |
| + BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| << " distribution: " << p->distribution()->GetAppShortCutName(); |
| } |