Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/installer/util/installer_state.h" | 5 #include "chrome/installer/util/installer_state.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 112 | 112 |
| 113 if (!prefs.GetBool(master_preferences::kMsi, &msi_)) | 113 if (!prefs.GetBool(master_preferences::kMsi, &msi_)) |
| 114 msi_ = false; | 114 msi_ = false; |
| 115 | 115 |
| 116 ensure_google_update_present_ = | 116 ensure_google_update_present_ = |
| 117 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); | 117 command_line.HasSwitch(installer::switches::kEnsureGoogleUpdatePresent); |
| 118 | 118 |
| 119 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); | 119 const bool is_uninstall = command_line.HasSwitch(switches::kUninstall); |
| 120 | 120 |
| 121 if (prefs.install_chrome()) { | 121 if (prefs.install_chrome()) { |
| 122 Product* p = | 122 Product* p = AddProductFromPreferences( |
| 123 AddProductFromPreferences(BrowserDistribution::CHROME_BROWSER, prefs, | 123 BrowserDistribution::CHROME_BROWSER, prefs, machine_state); |
| 124 machine_state); | |
| 125 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 124 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 126 << " distribution: " << p->distribution()->GetAppShortCutName(); | 125 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 127 } | 126 } |
| 128 if (prefs.install_chrome_frame()) { | 127 if (prefs.install_chrome_frame()) { |
| 129 Product* p = | 128 Product* p = AddProductFromPreferences( |
| 130 AddProductFromPreferences(BrowserDistribution::CHROME_FRAME, prefs, | 129 BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| 131 machine_state); | |
| 132 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 130 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 133 << " distribution: " << p->distribution()->GetAppShortCutName(); | 131 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 134 } | 132 } |
| 133 | |
| 135 if (prefs.install_chrome_app_host()) { | 134 if (prefs.install_chrome_app_host()) { |
| 136 Product* p = | 135 Product* p = AddProductFromPreferences( |
| 137 AddProductFromPreferences(BrowserDistribution::CHROME_APP_HOST, prefs, | 136 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); |
| 138 machine_state); | |
| 139 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 137 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 140 << " distribution: " << p->distribution()->GetAppShortCutName(); | 138 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 141 } | 139 } |
| 142 | 140 |
| 143 if (!is_uninstall && is_multi_install()) { | 141 if (!is_uninstall && is_multi_install()) { |
| 144 bool need_binaries = false; | 142 bool need_binaries = false; |
| 145 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | 143 if (FindProduct(BrowserDistribution::CHROME_APP_HOST)) { |
| 146 // App Host will happily use Chrome at system level, or binaries at system | 144 // App Host will happily use Chrome at system level, or binaries at system |
| 147 // level, even if app host is user level. | 145 // level, even if app host is user level. |
| 148 const ProductState* chrome_state = machine_state.GetProductState( | 146 const ProductState* chrome_state = machine_state.GetProductState( |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 160 | 158 |
| 161 // Chrome/Chrome Frame multi need Binaries at their own level. | 159 // Chrome/Chrome Frame multi need Binaries at their own level. |
| 162 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) | 160 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) |
| 163 need_binaries = true; | 161 need_binaries = true; |
| 164 | 162 |
| 165 if (FindProduct(BrowserDistribution::CHROME_FRAME)) | 163 if (FindProduct(BrowserDistribution::CHROME_FRAME)) |
| 166 need_binaries = true; | 164 need_binaries = true; |
| 167 | 165 |
| 168 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { | 166 if (need_binaries && !FindProduct(BrowserDistribution::CHROME_BINARIES)) { |
| 169 // Force binaries to be installed/updated. | 167 // Force binaries to be installed/updated. |
| 170 Product* p = | 168 Product* p = AddProductFromPreferences( |
| 171 AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, | 169 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| 172 prefs, | |
| 173 machine_state); | |
| 174 VLOG(1) << "Install distribution: " | 170 VLOG(1) << "Install distribution: " |
| 175 << p->distribution()->GetAppShortCutName(); | 171 << p->distribution()->GetAppShortCutName(); |
| 176 } | 172 } |
| 177 } | 173 } |
| 178 | 174 |
| 179 if (is_uninstall && prefs.is_multi_install()) { | 175 if (is_uninstall && prefs.is_multi_install()) { |
| 180 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) { | 176 if (FindProduct(BrowserDistribution::CHROME_BROWSER)) { |
| 181 const ProductState* chrome_frame_state = machine_state.GetProductState( | 177 // Uninstall each product of type |type| listed below based on the |
| 182 system_install(), BrowserDistribution::CHROME_FRAME); | 178 // presence or absence of |switch_name| in that product's uninstall |
| 179 // command. | |
| 180 const struct { | |
| 181 BrowserDistribution::Type type; | |
| 182 const char* switch_name; | |
| 183 bool switch_expected; | |
| 184 } conditional_additions[] = { | |
| 185 // If Chrome Frame is installed in Ready Mode, remove it with Chrome. | |
| 186 { BrowserDistribution::CHROME_FRAME, switches::kChromeFrameReadyMode, | |
| 187 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.
| |
| 188 // App Host (non-App Launcher) is installed. Remove it with Chrome. | |
| 189 // Hwoever, for system-level Chrome uninstall, any installed user-level | |
| 190 // (non-App Launcher) App Host will remain. When the orphaned | |
| 191 // 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.
| |
| 192 { BrowserDistribution::CHROME_APP_HOST, switches::kChromeAppLauncher, | |
| 193 false }, | |
|
gab
2012/11/19 17:24:38
same as above.
huangs
2012/11/19 19:06:05
Done.
| |
| 194 }; | |
| 183 | 195 |
| 184 if (chrome_frame_state != NULL && | 196 for (size_t i = 0; i < arraysize(conditional_additions); ++i) { |
| 185 chrome_frame_state->uninstall_command().HasSwitch( | 197 const ProductState* product_state = machine_state.GetProductState( |
| 186 switches::kChromeFrameReadyMode) && | 198 system_install(), conditional_additions[i].type); |
| 187 !FindProduct(BrowserDistribution::CHROME_FRAME)) { | 199 if (product_state != NULL && |
| 188 // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. | 200 product_state->uninstall_command().HasSwitch( |
| 189 Product* p = AddProductFromPreferences( | 201 conditional_additions[i].switch_name) == |
| 190 BrowserDistribution::CHROME_FRAME, prefs, machine_state); | 202 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.
| |
| 191 | 203 !FindProduct(conditional_additions[i].type)) { |
| 192 VLOG(1) << "Uninstall distribution: " | 204 Product* p = AddProductFromPreferences( |
| 193 << p->distribution()->GetAppShortCutName(); | 205 conditional_additions[i].type, prefs, machine_state); |
| 206 VLOG(1) << "Uninstall distribution: " | |
| 207 << p->distribution()->GetAppShortCutName(); | |
| 208 } | |
| 194 } | 209 } |
| 195 } | 210 } |
| 196 | 211 |
| 197 bool keep_binaries = false; | 212 bool keep_binaries = false; |
| 198 // Look for a product that is not the binaries and that is not being | 213 // Look for a product that is not the binaries and that is not being |
| 199 // uninstalled. If not found, binaries are uninstalled too. | 214 // uninstalled. If not found, binaries are uninstalled too. |
| 200 for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { | 215 for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
| 201 BrowserDistribution::Type type = | 216 BrowserDistribution::Type type = |
| 202 static_cast<BrowserDistribution::Type>(i); | 217 static_cast<BrowserDistribution::Type>(i); |
| 203 | 218 |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 229 keep_binaries = true; | 244 keep_binaries = true; |
| 230 break; | 245 break; |
| 231 } | 246 } |
| 232 | 247 |
| 233 } | 248 } |
| 234 } | 249 } |
| 235 | 250 |
| 236 // The product is being uninstalled. | 251 // The product is being uninstalled. |
| 237 } | 252 } |
| 238 if (!keep_binaries) { | 253 if (!keep_binaries) { |
| 239 Product* p = | 254 Product* p = AddProductFromPreferences( |
| 240 AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, prefs, | 255 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| 241 machine_state); | |
| 242 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 256 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 243 << " distribution: " << p->distribution()->GetAppShortCutName(); | 257 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 244 } | 258 } |
| 245 } | 259 } |
| 246 | 260 |
| 247 BrowserDistribution* operand = NULL; | 261 BrowserDistribution* operand = NULL; |
| 248 | 262 |
| 249 if (is_uninstall) { | 263 if (is_uninstall) { |
| 250 operation_ = UNINSTALL; | 264 operation_ = UNINSTALL; |
| 251 } else if (!prefs.is_multi_install()) { | 265 } else if (!prefs.is_multi_install()) { |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 if (is_multi_install()) { | 777 if (is_multi_install()) { |
| 764 InstallUtil::AddInstallerResultItems( | 778 InstallUtil::AddInstallerResultItems( |
| 765 system_install, multi_package_binaries_distribution()->GetStateKey(), | 779 system_install, multi_package_binaries_distribution()->GetStateKey(), |
| 766 status, string_resource_id, launch_cmd, install_list.get()); | 780 status, string_resource_id, launch_cmd, install_list.get()); |
| 767 } | 781 } |
| 768 if (!install_list->Do()) | 782 if (!install_list->Do()) |
| 769 LOG(ERROR) << "Failed to record installer error information in registry."; | 783 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 770 } | 784 } |
| 771 | 785 |
| 772 } // namespace installer | 786 } // namespace installer |
| OLD | NEW |