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/installer_state.h" | 5 #include "chrome/installer/setup/installer_state.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") | 73 VLOG(1) << (is_uninstall ? "Uninstall" : "Install") |
74 << " distribution: " << dist->GetDisplayName(); | 74 << " distribution: " << dist->GetDisplayName(); |
75 | 75 |
76 state_key_ = dist->GetStateKey(); | 76 state_key_ = dist->GetStateKey(); |
77 | 77 |
78 if (is_uninstall) { | 78 if (is_uninstall) { |
79 operation_ = UNINSTALL; | 79 operation_ = UNINSTALL; |
80 } else { | 80 } else { |
81 operation_ = SINGLE_INSTALL_OR_UPDATE; | 81 operation_ = SINGLE_INSTALL_OR_UPDATE; |
82 // Is this a migration from multi-install to single-install? | 82 // Is this a migration from multi-install to single-install? |
83 const ProductState* state = | 83 const ProductState* state = machine_state.GetProductState(system_install()); |
84 machine_state.GetProductState(system_install(), dist->GetType()); | |
85 is_migrating_to_single_ = state && state->is_multi_install(); | 84 is_migrating_to_single_ = state && state->is_multi_install(); |
86 } | 85 } |
87 | 86 |
88 // Parse --critical-update-version=W.X.Y.Z | 87 // Parse --critical-update-version=W.X.Y.Z |
89 std::string critical_version_value( | 88 std::string critical_version_value( |
90 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); | 89 command_line.GetSwitchValueASCII(switches::kCriticalUpdateVersion)); |
91 critical_update_version_ = base::Version(critical_version_value); | 90 critical_update_version_ = base::Version(critical_version_value); |
92 } | 91 } |
93 | 92 |
94 void InstallerState::set_level(Level level) { | 93 void InstallerState::set_level(Level level) { |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
157 Product* InstallerState::AddProductFromPreferences( | 156 Product* InstallerState::AddProductFromPreferences( |
158 const MasterPreferences& prefs, | 157 const MasterPreferences& prefs, |
159 const InstallationState& machine_state) { | 158 const InstallationState& machine_state) { |
160 std::unique_ptr<Product> product_ptr( | 159 std::unique_ptr<Product> product_ptr( |
161 new Product(BrowserDistribution::GetDistribution())); | 160 new Product(BrowserDistribution::GetDistribution())); |
162 product_ptr->InitializeFromPreferences(prefs); | 161 product_ptr->InitializeFromPreferences(prefs); |
163 | 162 |
164 Product* product = AddProductInDirectory(nullptr, std::move(product_ptr)); | 163 Product* product = AddProductInDirectory(nullptr, std::move(product_ptr)); |
165 | 164 |
166 if (product != NULL && !msi_) { | 165 if (product != NULL && !msi_) { |
167 const ProductState* product_state = machine_state.GetProductState( | 166 const ProductState* product_state = |
168 system_install(), BrowserDistribution::CHROME_BROWSER); | 167 machine_state.GetProductState(system_install()); |
169 if (product_state != NULL) | 168 if (product_state != NULL) |
170 msi_ = product_state->is_msi(); | 169 msi_ = product_state->is_msi(); |
171 } | 170 } |
172 | 171 |
173 return product; | 172 return product; |
174 } | 173 } |
175 | 174 |
176 Product* InstallerState::AddProductFromState( | 175 Product* InstallerState::AddProductFromState( |
177 const ProductState& state) { | 176 const ProductState& state) { |
178 std::unique_ptr<Product> product_ptr( | 177 std::unique_ptr<Product> product_ptr( |
(...skipping 15 matching lines...) Expand all Loading... |
194 | 193 |
195 bool InstallerState::system_install() const { | 194 bool InstallerState::system_install() const { |
196 DCHECK(level_ == USER_LEVEL || level_ == SYSTEM_LEVEL); | 195 DCHECK(level_ == USER_LEVEL || level_ == SYSTEM_LEVEL); |
197 return level_ == SYSTEM_LEVEL; | 196 return level_ == SYSTEM_LEVEL; |
198 } | 197 } |
199 | 198 |
200 base::Version* InstallerState::GetCurrentVersion( | 199 base::Version* InstallerState::GetCurrentVersion( |
201 const InstallationState& machine_state) const { | 200 const InstallationState& machine_state) const { |
202 DCHECK(product_); | 201 DCHECK(product_); |
203 std::unique_ptr<base::Version> current_version; | 202 std::unique_ptr<base::Version> current_version; |
204 const ProductState* product_state = machine_state.GetProductState( | 203 const ProductState* product_state = |
205 level_ == SYSTEM_LEVEL, BrowserDistribution::CHROME_BROWSER); | 204 machine_state.GetProductState(level_ == SYSTEM_LEVEL); |
206 | 205 |
207 if (product_state != NULL) { | 206 if (product_state != NULL) { |
208 const base::Version* version = NULL; | 207 const base::Version* version = NULL; |
209 | 208 |
210 // Be aware that there might be a pending "new_chrome.exe" already in the | 209 // Be aware that there might be a pending "new_chrome.exe" already in the |
211 // installation path. If so, we use old_version, which holds the version of | 210 // installation path. If so, we use old_version, which holds the version of |
212 // "chrome.exe" itself. | 211 // "chrome.exe" itself. |
213 if (base::PathExists(target_path().Append(kChromeNewExe))) | 212 if (base::PathExists(target_path().Append(kChromeNewExe))) |
214 version = product_state->old_version(); | 213 version = product_state->old_version(); |
215 | 214 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
324 #endif | 323 #endif |
325 } | 324 } |
326 install_list->Do(); | 325 install_list->Do(); |
327 } | 326 } |
328 | 327 |
329 bool InstallerState::RequiresActiveSetup() const { | 328 bool InstallerState::RequiresActiveSetup() const { |
330 return system_install(); | 329 return system_install(); |
331 } | 330 } |
332 | 331 |
333 } // namespace installer | 332 } // namespace installer |
OLD | NEW |