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/setup/install_worker.h" | 5 #include "chrome/installer/setup/install_worker.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 uninstall_command_.AppendSwitch(option); | 141 uninstall_command_.AppendSwitch(option); |
142 } | 142 } |
143 }; | 143 }; |
144 | 144 |
145 // Okay, so this isn't really a mock as such, but it does add setter methods | 145 // Okay, so this isn't really a mock as such, but it does add setter methods |
146 // to make it easier to build custom InstallationStates. | 146 // to make it easier to build custom InstallationStates. |
147 class MockInstallationState : public InstallationState { | 147 class MockInstallationState : public InstallationState { |
148 public: | 148 public: |
149 // Included for testing. | 149 // Included for testing. |
150 void SetProductState(bool system_install, | 150 void SetProductState(bool system_install, |
151 BrowserDistribution::Type type, | |
152 const ProductState& product_state) { | 151 const ProductState& product_state) { |
153 ProductState& target = (system_install ? system_products_ : | 152 ProductState& target = system_install ? system_chrome_ : user_chrome_; |
154 user_products_)[IndexFromDistType(type)]; | |
155 target.CopyFrom(product_state); | 153 target.CopyFrom(product_state); |
156 } | 154 } |
157 }; | 155 }; |
158 | 156 |
159 class MockInstallerState : public InstallerState { | 157 class MockInstallerState : public InstallerState { |
160 public: | 158 public: |
161 void set_level(Level level) { | 159 void set_level(Level level) { |
162 InstallerState::set_level(level); | 160 InstallerState::set_level(level); |
163 } | 161 } |
164 | 162 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 base::FilePath install_path = | 203 base::FilePath install_path = |
206 installer::GetChromeInstallPath(system_level, dist); | 204 installer::GetChromeInstallPath(system_level, dist); |
207 product_state.SetUninstallProgram( | 205 product_state.SetUninstallProgram( |
208 install_path.AppendASCII(current_version_->GetString()) | 206 install_path.AppendASCII(current_version_->GetString()) |
209 .Append(installer::kInstallerDir) | 207 .Append(installer::kInstallerDir) |
210 .Append(installer::kSetupExe)); | 208 .Append(installer::kSetupExe)); |
211 product_state.AddUninstallSwitch(installer::switches::kUninstall); | 209 product_state.AddUninstallSwitch(installer::switches::kUninstall); |
212 if (system_level) | 210 if (system_level) |
213 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); | 211 product_state.AddUninstallSwitch(installer::switches::kSystemLevel); |
214 | 212 |
215 installation_state->SetProductState(system_level, | 213 installation_state->SetProductState(system_level, product_state); |
216 BrowserDistribution::CHROME_BROWSER, | |
217 product_state); | |
218 } | 214 } |
219 | 215 |
220 MockInstallationState* BuildChromeInstallationState(bool system_level) { | 216 MockInstallationState* BuildChromeInstallationState(bool system_level) { |
221 std::unique_ptr<MockInstallationState> installation_state( | 217 std::unique_ptr<MockInstallationState> installation_state( |
222 new MockInstallationState()); | 218 new MockInstallationState()); |
223 AddChromeToInstallationState(system_level, installation_state.get()); | 219 AddChromeToInstallationState(system_level, installation_state.get()); |
224 return installation_state.release(); | 220 return installation_state.release(); |
225 } | 221 } |
226 | 222 |
227 static MockInstallerState* BuildBasicInstallerState( | 223 static MockInstallerState* BuildBasicInstallerState( |
(...skipping 10 matching lines...) Expand all Loading... |
238 // Hope this next one isn't checked for now. | 234 // Hope this next one isn't checked for now. |
239 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); | 235 installer_state->set_state_key(L"PROBABLY_INVALID_REG_PATH"); |
240 return installer_state.release(); | 236 return installer_state.release(); |
241 } | 237 } |
242 | 238 |
243 static void AddChromeToInstallerState( | 239 static void AddChromeToInstallerState( |
244 const InstallationState& machine_state, | 240 const InstallationState& machine_state, |
245 MockInstallerState* installer_state) { | 241 MockInstallerState* installer_state) { |
246 // Fresh install or upgrade? | 242 // Fresh install or upgrade? |
247 const ProductState* chrome = | 243 const ProductState* chrome = |
248 machine_state.GetProductState(installer_state->system_install(), | 244 machine_state.GetProductState(installer_state->system_install()); |
249 BrowserDistribution::CHROME_BROWSER); | |
250 if (chrome) { | 245 if (chrome) { |
251 installer_state->AddProductFromState(*chrome); | 246 installer_state->AddProductFromState(*chrome); |
252 } else { | 247 } else { |
253 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); | 248 BrowserDistribution* dist = BrowserDistribution::GetDistribution(); |
254 installer_state->AddProduct(base::MakeUnique<Product>(dist)); | 249 installer_state->AddProduct(base::MakeUnique<Product>(dist)); |
255 } | 250 } |
256 } | 251 } |
257 | 252 |
258 static MockInstallerState* BuildChromeInstallerState( | 253 static MockInstallerState* BuildChromeInstallerState( |
259 bool system_install, | 254 bool system_install, |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 AddInstallWorkItems(*installation_state.get(), | 314 AddInstallWorkItems(*installation_state.get(), |
320 *installer_state.get(), | 315 *installer_state.get(), |
321 setup_path_, | 316 setup_path_, |
322 archive_path_, | 317 archive_path_, |
323 src_path_, | 318 src_path_, |
324 temp_dir_, | 319 temp_dir_, |
325 current_version_.get(), | 320 current_version_.get(), |
326 *new_version_.get(), | 321 *new_version_.get(), |
327 &work_item_list); | 322 &work_item_list); |
328 } | 323 } |
OLD | NEW |