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 const ProductState* chrome_frame_state = machine_state.GetProductState( |
| 182 system_install(), BrowserDistribution::CHROME_FRAME); | 178 system_install(), BrowserDistribution::CHROME_FRAME); |
| 183 | 179 |
| 184 if (chrome_frame_state != NULL && | 180 if (chrome_frame_state != NULL && |
|
gab
2012/11/16 22:20:26
This is extremely similar to the code you added be
huangs
2012/11/17 00:15:41
Done.
| |
| 185 chrome_frame_state->uninstall_command().HasSwitch( | 181 chrome_frame_state->uninstall_command().HasSwitch( |
| 186 switches::kChromeFrameReadyMode) && | 182 switches::kChromeFrameReadyMode) && |
| 187 !FindProduct(BrowserDistribution::CHROME_FRAME)) { | 183 !FindProduct(BrowserDistribution::CHROME_FRAME)) { |
| 188 // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. | 184 // Chrome Frame is installed in Ready Mode. Remove it along with Chrome. |
| 189 Product* p = AddProductFromPreferences( | 185 Product* p = AddProductFromPreferences( |
| 190 BrowserDistribution::CHROME_FRAME, prefs, machine_state); | 186 BrowserDistribution::CHROME_FRAME, prefs, machine_state); |
| 191 | |
| 192 VLOG(1) << "Uninstall distribution: " | 187 VLOG(1) << "Uninstall distribution: " |
| 193 << p->distribution()->GetAppShortCutName(); | 188 << p->distribution()->GetAppShortCutName(); |
| 194 } | 189 } |
| 190 | |
| 191 const ProductState* app_host_state = machine_state.GetProductState( | |
|
gab
2012/11/16 22:20:26
Rename variable to make it explicit this is system
huangs
2012/11/17 00:15:41
Disregarding, per F2F.
| |
| 192 system_install(), BrowserDistribution::CHROME_APP_HOST); | |
| 193 | |
| 194 if (app_host_state != NULL && | |
| 195 !app_host_state->uninstall_command().HasSwitch( | |
| 196 switches::kChromeAppLauncher) && | |
| 197 !FindProduct(BrowserDistribution::CHROME_APP_HOST)) { | |
| 198 // App Host (non-App Launcher) is installed. Remove it along with | |
| 199 // Chrome. If we uninstall system-level Chrome, but user-level | |
| 200 // (non-App Launcher) App Host exists, then app_host.exe remains. | |
| 201 // When executed, orphaned app_host.exe prompts user for further action. | |
|
gab
2012/11/16 22:20:26
What about when uninstalling user-level Chrome wit
huangs
2012/11/17 00:15:41
In this case, app_host_state will be NULL, and the
| |
| 202 Product* p = AddProductFromPreferences( | |
| 203 BrowserDistribution::CHROME_APP_HOST, prefs, machine_state); | |
| 204 VLOG(1) << "Uninstall distribution: " | |
| 205 << p->distribution()->GetAppShortCutName(); | |
| 206 } | |
| 195 } | 207 } |
| 196 | 208 |
| 197 bool keep_binaries = false; | 209 bool keep_binaries = false; |
| 198 // Look for a product that is not the binaries and that is not being | 210 // Look for a product that is not the binaries and that is not being |
| 199 // uninstalled. If not found, binaries are uninstalled too. | 211 // uninstalled. If not found, binaries are uninstalled too. |
| 200 for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { | 212 for (size_t i = 0; i < BrowserDistribution::NUM_TYPES; ++i) { |
| 201 BrowserDistribution::Type type = | 213 BrowserDistribution::Type type = |
| 202 static_cast<BrowserDistribution::Type>(i); | 214 static_cast<BrowserDistribution::Type>(i); |
| 203 | 215 |
| 204 if (type == BrowserDistribution::CHROME_BINARIES) | 216 if (type == BrowserDistribution::CHROME_BINARIES) |
| (...skipping 24 matching lines...) Expand all Loading... | |
| 229 keep_binaries = true; | 241 keep_binaries = true; |
| 230 break; | 242 break; |
| 231 } | 243 } |
| 232 | 244 |
| 233 } | 245 } |
| 234 } | 246 } |
| 235 | 247 |
| 236 // The product is being uninstalled. | 248 // The product is being uninstalled. |
| 237 } | 249 } |
| 238 if (!keep_binaries) { | 250 if (!keep_binaries) { |
| 239 Product* p = | 251 Product* p = AddProductFromPreferences( |
| 240 AddProductFromPreferences(BrowserDistribution::CHROME_BINARIES, prefs, | 252 BrowserDistribution::CHROME_BINARIES, prefs, machine_state); |
| 241 machine_state); | |
| 242 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 253 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
| 243 << " distribution: " << p->distribution()->GetAppShortCutName(); | 254 << " distribution: " << p->distribution()->GetAppShortCutName(); |
| 244 } | 255 } |
| 245 } | 256 } |
| 246 | 257 |
| 247 BrowserDistribution* operand = NULL; | 258 BrowserDistribution* operand = NULL; |
| 248 | 259 |
| 249 if (is_uninstall) { | 260 if (is_uninstall) { |
| 250 operation_ = UNINSTALL; | 261 operation_ = UNINSTALL; |
| 251 } else if (!prefs.is_multi_install()) { | 262 } else if (!prefs.is_multi_install()) { |
| (...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 763 if (is_multi_install()) { | 774 if (is_multi_install()) { |
| 764 InstallUtil::AddInstallerResultItems( | 775 InstallUtil::AddInstallerResultItems( |
| 765 system_install, multi_package_binaries_distribution()->GetStateKey(), | 776 system_install, multi_package_binaries_distribution()->GetStateKey(), |
| 766 status, string_resource_id, launch_cmd, install_list.get()); | 777 status, string_resource_id, launch_cmd, install_list.get()); |
| 767 } | 778 } |
| 768 if (!install_list->Do()) | 779 if (!install_list->Do()) |
| 769 LOG(ERROR) << "Failed to record installer error information in registry."; | 780 LOG(ERROR) << "Failed to record installer error information in registry."; |
| 770 } | 781 } |
| 771 | 782 |
| 772 } // namespace installer | 783 } // namespace installer |
| OLD | NEW |