Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(501)

Side by Side Diff: chrome/installer/setup/install_worker.cc

Issue 10823437: Callback flow to register Chrome and update shortcuts after OS upgrade to Windows 8 (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Abandoning the use of ON_OS_UPGRADE_SUCCESSFUL installer message. Created 8 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 // This file contains the definitions of the installer functions that build 5 // This file contains the definitions of the installer functions that build
6 // the WorkItemList used to install the application. 6 // the WorkItemList used to install the application.
7 7
8 #include "chrome/installer/setup/install_worker.h" 8 #include "chrome/installer/setup/install_worker.h"
9 9
10 #include <oaidl.h> 10 #include <oaidl.h>
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 // means that Chrome Frame is being uninstalled, so there's no need to do any 164 // means that Chrome Frame is being uninstalled, so there's no need to do any
165 // looping. 165 // looping.
166 if (product.is_chrome() && 166 if (product.is_chrome() &&
167 installer_state.operation() != InstallerState::UNINSTALL) { 167 installer_state.operation() != InstallerState::UNINSTALL) {
168 const Product* chrome_frame = 168 const Product* chrome_frame =
169 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME); 169 installer_state.FindProduct(BrowserDistribution::CHROME_FRAME);
170 if (chrome_frame && chrome_frame->HasOption(kOptionReadyMode)) 170 if (chrome_frame && chrome_frame->HasOption(kOptionReadyMode))
171 chrome_frame->AppendProductFlags(&uninstall_arguments); 171 chrome_frame->AppendProductFlags(&uninstall_arguments);
172 } 172 }
173 173
174 std::wstring update_state_key(browser_dist->GetStateKey()); 174 string16 update_state_key(browser_dist->GetStateKey());
175 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key); 175 install_list->AddCreateRegKeyWorkItem(reg_root, update_state_key);
176 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, 176 install_list->AddSetRegValueWorkItem(reg_root, update_state_key,
177 installer::kUninstallStringField, installer_path.value(), true); 177 installer::kUninstallStringField, installer_path.value(), true);
178 install_list->AddSetRegValueWorkItem(reg_root, update_state_key, 178 install_list->AddSetRegValueWorkItem(reg_root, update_state_key,
179 installer::kUninstallArgumentsField, 179 installer::kUninstallArgumentsField,
180 uninstall_arguments.GetCommandLineString(), true); 180 uninstall_arguments.GetCommandLineString(), true);
181 181
182 // MSI installations will manage their own uninstall shortcuts. 182 // MSI installations will manage their own uninstall shortcuts.
183 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) { 183 if (!installer_state.is_msi() && product.ShouldCreateUninstallEntry()) {
184 // We need to quote the command line for the Add/Remove Programs dialog. 184 // We need to quote the command line for the Add/Remove Programs dialog.
185 CommandLine quoted_uninstall_cmd(installer_path); 185 CommandLine quoted_uninstall_cmd(installer_path);
186 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"'); 186 DCHECK_EQ(quoted_uninstall_cmd.GetCommandLineString()[0], '"');
187 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false); 187 quoted_uninstall_cmd.AppendArguments(uninstall_arguments, false);
188 188
189 std::wstring uninstall_reg = browser_dist->GetUninstallRegPath(); 189 string16 uninstall_reg = browser_dist->GetUninstallRegPath();
190 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg); 190 install_list->AddCreateRegKeyWorkItem(reg_root, uninstall_reg);
191 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 191 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
192 installer::kUninstallDisplayNameField, 192 installer::kUninstallDisplayNameField,
193 browser_dist->GetAppShortCutName(), true); 193 browser_dist->GetAppShortCutName(), true);
194 install_list->AddSetRegValueWorkItem(reg_root, 194 install_list->AddSetRegValueWorkItem(reg_root,
195 uninstall_reg, installer::kUninstallStringField, 195 uninstall_reg, installer::kUninstallStringField,
196 quoted_uninstall_cmd.GetCommandLineString(), true); 196 quoted_uninstall_cmd.GetCommandLineString(), true);
197 install_list->AddSetRegValueWorkItem(reg_root, 197 install_list->AddSetRegValueWorkItem(reg_root,
198 uninstall_reg, 198 uninstall_reg,
199 L"InstallLocation", 199 L"InstallLocation",
200 install_path.value(), 200 install_path.value(),
201 true); 201 true);
202 202
203 // DisplayIcon, NoModify and NoRepair 203 // DisplayIcon, NoModify and NoRepair
204 std::wstring chrome_icon = ShellUtil::GetChromeIcon( 204 string16 chrome_icon = ShellUtil::GetChromeIcon(
205 product.distribution(), 205 product.distribution(),
206 install_path.Append(installer::kChromeExe).value()); 206 install_path.Append(installer::kChromeExe).value());
207 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 207 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
208 L"DisplayIcon", chrome_icon, true); 208 L"DisplayIcon", chrome_icon, true);
209 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 209 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
210 L"NoModify", static_cast<DWORD>(1), 210 L"NoModify", static_cast<DWORD>(1),
211 true); 211 true);
212 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg, 212 install_list->AddSetRegValueWorkItem(reg_root, uninstall_reg,
213 L"NoRepair", static_cast<DWORD>(1), 213 L"NoRepair", static_cast<DWORD>(1),
214 true); 214 true);
(...skipping 28 matching lines...) Expand all
243 243
244 // Create Version key for a product (if not already present) and sets the new 244 // Create Version key for a product (if not already present) and sets the new
245 // product version as the last step. 245 // product version as the last step.
246 void AddVersionKeyWorkItems(HKEY root, 246 void AddVersionKeyWorkItems(HKEY root,
247 BrowserDistribution* dist, 247 BrowserDistribution* dist,
248 const Version& new_version, 248 const Version& new_version,
249 bool add_language_identifier, 249 bool add_language_identifier,
250 WorkItemList* list) { 250 WorkItemList* list) {
251 // Create Version key for each distribution (if not already present) and set 251 // Create Version key for each distribution (if not already present) and set
252 // the new product version as the last step. 252 // the new product version as the last step.
253 std::wstring version_key(dist->GetVersionKey()); 253 string16 version_key(dist->GetVersionKey());
254 list->AddCreateRegKeyWorkItem(root, version_key); 254 list->AddCreateRegKeyWorkItem(root, version_key);
255 255
256 std::wstring product_name(dist->GetAppShortCutName()); 256 string16 product_name(dist->GetAppShortCutName());
257 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField, 257 list->AddSetRegValueWorkItem(root, version_key, google_update::kRegNameField,
258 product_name, true); // overwrite name also 258 product_name, true); // overwrite name also
259 list->AddSetRegValueWorkItem(root, version_key, 259 list->AddSetRegValueWorkItem(root, version_key,
260 google_update::kRegOopcrashesField, 260 google_update::kRegOopcrashesField,
261 static_cast<DWORD>(1), 261 static_cast<DWORD>(1),
262 false); // set during first install 262 false); // set during first install
263 if (add_language_identifier) { 263 if (add_language_identifier) {
264 // Write the language identifier of the current translation. Omaha's set of 264 // Write the language identifier of the current translation. Omaha's set of
265 // languages is a superset of Chrome's set of translations with this one 265 // languages is a superset of Chrome's set of translations with this one
266 // exception: what Chrome calls "en-us", Omaha calls "en". sigh. 266 // exception: what Chrome calls "en-us", Omaha calls "en". sigh.
267 std::wstring language(GetCurrentTranslation()); 267 string16 language(GetCurrentTranslation());
268 if (LowerCaseEqualsASCII(language, "en-us")) 268 if (LowerCaseEqualsASCII(language, "en-us"))
269 language.resize(2); 269 language.resize(2);
270 list->AddSetRegValueWorkItem(root, version_key, 270 list->AddSetRegValueWorkItem(root, version_key,
271 google_update::kRegLangField, language, 271 google_update::kRegLangField, language,
272 false); // do not overwrite language 272 false); // do not overwrite language
273 } 273 }
274 list->AddSetRegValueWorkItem(root, version_key, 274 list->AddSetRegValueWorkItem(root, version_key,
275 google_update::kRegVersionField, 275 google_update::kRegVersionField,
276 ASCIIToWide(new_version.GetString()), 276 ASCIIToWide(new_version.GetString()),
277 true); // overwrite version 277 true); // overwrite version
278 } 278 }
279 279
280 void AddInstallAppCommandWorkItems(const InstallerState& installer_state, 280 void AddInstallAppCommandWorkItems(const InstallerState& installer_state,
281 const InstallationState& machine_state, 281 const InstallationState& machine_state,
282 const FilePath* setup_path, 282 const FilePath* setup_path,
283 const Version* new_version, 283 const Version* new_version,
284 const Product& product, 284 const Product& product,
285 WorkItemList* work_item_list) { 285 WorkItemList* work_item_list) {
286 DCHECK(product.is_chrome_app_host()); 286 DCHECK(product.is_chrome_app_host());
287 287
288 std::wstring cmd_key(product.distribution()->GetVersionKey()); 288 string16 cmd_key(product.distribution()->GetVersionKey());
289 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 289 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
290 .append(1, L'\\').append(kCmdInstallApp); 290 .append(1, L'\\').append(kCmdInstallApp);
291 291
292 if (installer_state.operation() != InstallerState::UNINSTALL) { 292 if (installer_state.operation() != InstallerState::UNINSTALL) {
293 FilePath target_path(installer_state.target_path()); 293 FilePath target_path(installer_state.target_path());
294 CommandLine cmd_line(target_path.Append(installer::kChromeAppHostExe)); 294 CommandLine cmd_line(target_path.Append(installer::kChromeAppHostExe));
295 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1"); 295 cmd_line.AppendSwitchASCII(::switches::kAppsInstallFromManifestURL, "%1");
296 296
297 AppCommand cmd(cmd_line.GetCommandLineString(), true, true); 297 AppCommand cmd(cmd_line.GetCommandLineString());
298 cmd.set_sends_pings(true);
299 cmd.set_is_web_accessible(true);
298 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 300 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
299 } else { 301 } else {
300 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 302 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
301 cmd_key)->set_log_message( 303 cmd_key)->set_log_message(
302 "removing install-application command"); 304 "removing install-application command");
303 } 305 }
304 } 306 }
305 307
306 void AddProductSpecificWorkItems(const InstallationState& original_state, 308 void AddProductSpecificWorkItems(const InstallationState& original_state,
307 const InstallerState& installer_state, 309 const InstallerState& installer_state,
308 const FilePath& setup_path, 310 const FilePath& setup_path,
309 const Version& new_version, 311 const Version& new_version,
310 WorkItemList* list) { 312 WorkItemList* list) {
311 const Products& products = installer_state.products(); 313 const Products& products = installer_state.products();
312 for (size_t i = 0; i < products.size(); ++i) { 314 for (size_t i = 0; i < products.size(); ++i) {
313 const Product& p = *products[i]; 315 const Product& p = *products[i];
314 if (p.is_chrome_frame()) { 316 if (p.is_chrome_frame()) {
315 AddChromeFrameWorkItems(original_state, installer_state, setup_path, 317 AddChromeFrameWorkItems(original_state, installer_state, setup_path,
316 new_version, p, list); 318 new_version, p, list);
317 } 319 }
318 if (p.is_chrome_app_host()) { 320 if (p.is_chrome_app_host()) {
319 AddInstallAppCommandWorkItems(installer_state, original_state, 321 AddInstallAppCommandWorkItems(installer_state, original_state,
320 &setup_path, &new_version, p, list); 322 &setup_path, &new_version, p, list);
321 } 323 }
324 if (p.is_chrome()) {
325 // In Chrome Browser, add registry entries so that when an OS upgrade
grt (UTC plus 2) 2012/08/30 04:15:25 i think this comment is stating the obvious: the l
huangs 2012/08/30 17:13:07 Deleted redundancy; moved comment to body of AddOs
326 // occurs, Google Update will call setup.exe with --on-os-upgrade switch,
327 // which leads to ChromeBrowserOnOsUpgrade() being called.
grt (UTC plus 2) 2012/08/30 04:15:25 "ChromeBrowserOnOsUpgrade" -> "OnOsUpgrade"
huangs 2012/08/30 17:13:07 Done => new name is HandleOsUpgradeForBrowser().
328 AddOsUpgradeWorkItems(installer_state, &setup_path, &new_version, p,
329 list);
330 }
322 } 331 }
323 } 332 }
324 333
325 // Mirror oeminstall the first time anything is installed multi. There is no 334 // Mirror oeminstall the first time anything is installed multi. There is no
326 // need to update the value on future install/update runs since this value never 335 // need to update the value on future install/update runs since this value never
327 // changes. Note that the value is removed by Google Update after EULA 336 // changes. Note that the value is removed by Google Update after EULA
328 // acceptance is processed. 337 // acceptance is processed.
329 void AddOemInstallWorkItems(const InstallationState& original_state, 338 void AddOemInstallWorkItems(const InstallationState& original_state,
330 const InstallerState& installer_state, 339 const InstallerState& installer_state,
331 WorkItemList* install_list) { 340 WorkItemList* install_list) {
332 DCHECK(installer_state.is_multi_install()); 341 DCHECK(installer_state.is_multi_install());
333 const bool system_install = installer_state.system_install(); 342 const bool system_install = installer_state.system_install();
334 if (!original_state.GetProductState(system_install, 343 if (!original_state.GetProductState(system_install,
335 BrowserDistribution::CHROME_BINARIES)) { 344 BrowserDistribution::CHROME_BINARIES)) {
336 const HKEY root_key = installer_state.root_key(); 345 const HKEY root_key = installer_state.root_key();
337 std::wstring multi_key( 346 string16 multi_key(
338 installer_state.multi_package_binaries_distribution()->GetStateKey()); 347 installer_state.multi_package_binaries_distribution()->GetStateKey());
339 348
340 // Copy the value from Chrome unless Chrome isn't installed or being 349 // Copy the value from Chrome unless Chrome isn't installed or being
341 // installed. 350 // installed.
342 BrowserDistribution::Type source_type; 351 BrowserDistribution::Type source_type;
343 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) { 352 if (installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER)) {
344 source_type = BrowserDistribution::CHROME_BROWSER; 353 source_type = BrowserDistribution::CHROME_BROWSER;
345 } else if (!installer_state.products().empty()) { 354 } else if (!installer_state.products().empty()) {
346 // Pick a product, any product. 355 // Pick a product, any product.
347 source_type = installer_state.products()[0]->distribution()->GetType(); 356 source_type = installer_state.products()[0]->distribution()->GetType();
348 } else { 357 } else {
349 // Nothing is being installed? Entirely unexpected, so do no harm. 358 // Nothing is being installed? Entirely unexpected, so do no harm.
350 LOG(ERROR) << "No products found in AddOemInstallWorkItems"; 359 LOG(ERROR) << "No products found in AddOemInstallWorkItems";
351 return; 360 return;
352 } 361 }
353 const ProductState* source_product = 362 const ProductState* source_product =
354 original_state.GetNonVersionedProductState(system_install, source_type); 363 original_state.GetNonVersionedProductState(system_install, source_type);
355 364
356 std::wstring oem_install; 365 string16 oem_install;
357 if (source_product->GetOemInstall(&oem_install)) { 366 if (source_product->GetOemInstall(&oem_install)) {
358 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from " 367 VLOG(1) << "Mirroring oeminstall=\"" << oem_install << "\" from "
359 << BrowserDistribution::GetSpecificDistribution(source_type) 368 << BrowserDistribution::GetSpecificDistribution(source_type)
360 ->GetAppShortCutName(); 369 ->GetAppShortCutName();
361 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 370 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
362 // Always overwrite an old value. 371 // Always overwrite an old value.
363 install_list->AddSetRegValueWorkItem(root_key, multi_key, 372 install_list->AddSetRegValueWorkItem(root_key, multi_key,
364 google_update::kRegOemInstallField, 373 google_update::kRegOemInstallField,
365 oem_install, true); 374 oem_install, true);
366 } else { 375 } else {
367 // Clear any old value. 376 // Clear any old value.
368 install_list->AddDeleteRegValueWorkItem( 377 install_list->AddDeleteRegValueWorkItem(
369 root_key, multi_key, google_update::kRegOemInstallField); 378 root_key, multi_key, google_update::kRegOemInstallField);
370 } 379 }
371 } 380 }
372 } 381 }
373 382
374 // Mirror eulaaccepted the first time anything is installed multi. There is no 383 // Mirror eulaaccepted the first time anything is installed multi. There is no
375 // need to update the value on future install/update runs since 384 // need to update the value on future install/update runs since
376 // GoogleUpdateSettings::SetEULAConsent will modify the value for both the 385 // GoogleUpdateSettings::SetEULAConsent will modify the value for both the
377 // relevant product and for the binaries. 386 // relevant product and for the binaries.
378 void AddEulaAcceptedWorkItems(const InstallationState& original_state, 387 void AddEulaAcceptedWorkItems(const InstallationState& original_state,
379 const InstallerState& installer_state, 388 const InstallerState& installer_state,
380 WorkItemList* install_list) { 389 WorkItemList* install_list) {
381 DCHECK(installer_state.is_multi_install()); 390 DCHECK(installer_state.is_multi_install());
382 const bool system_install = installer_state.system_install(); 391 const bool system_install = installer_state.system_install();
383 if (!original_state.GetProductState(system_install, 392 if (!original_state.GetProductState(system_install,
384 BrowserDistribution::CHROME_BINARIES)) { 393 BrowserDistribution::CHROME_BINARIES)) {
385 const HKEY root_key = installer_state.root_key(); 394 const HKEY root_key = installer_state.root_key();
386 std::wstring multi_key( 395 string16 multi_key(
387 installer_state.multi_package_binaries_distribution()->GetStateKey()); 396 installer_state.multi_package_binaries_distribution()->GetStateKey());
388 397
389 // Copy the value from the product with the greatest value. 398 // Copy the value from the product with the greatest value.
390 bool have_eula_accepted = false; 399 bool have_eula_accepted = false;
391 BrowserDistribution::Type product_type; 400 BrowserDistribution::Type product_type;
392 DWORD eula_accepted; 401 DWORD eula_accepted;
393 const Products& products = installer_state.products(); 402 const Products& products = installer_state.products();
394 for (size_t i = 0, count = products.size(); i != count; ++i) { 403 for (size_t i = 0, count = products.size(); i != count; ++i) {
395 if (products[i]->is_chrome_binaries()) 404 if (products[i]->is_chrome_binaries())
396 continue; 405 continue;
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
430 WorkItemList* install_list) { 439 WorkItemList* install_list) {
431 // Is a multi-install product being installed or over-installed? 440 // Is a multi-install product being installed or over-installed?
432 if (installer_state.operation() != InstallerState::MULTI_INSTALL && 441 if (installer_state.operation() != InstallerState::MULTI_INSTALL &&
433 installer_state.operation() != InstallerState::MULTI_UPDATE) { 442 installer_state.operation() != InstallerState::MULTI_UPDATE) {
434 VLOG(1) << "AddGoogleUpdateWorkItems noop: " << installer_state.operation(); 443 VLOG(1) << "AddGoogleUpdateWorkItems noop: " << installer_state.operation();
435 return; 444 return;
436 } 445 }
437 446
438 const bool system_install = installer_state.system_install(); 447 const bool system_install = installer_state.system_install();
439 const HKEY root_key = installer_state.root_key(); 448 const HKEY root_key = installer_state.root_key();
440 std::wstring multi_key( 449 string16 multi_key(
441 installer_state.multi_package_binaries_distribution()->GetStateKey()); 450 installer_state.multi_package_binaries_distribution()->GetStateKey());
442 451
443 // For system-level installs, make sure the ClientStateMedium key for the 452 // For system-level installs, make sure the ClientStateMedium key for the
444 // binaries exists. 453 // binaries exists.
445 if (system_install) { 454 if (system_install) {
446 install_list->AddCreateRegKeyWorkItem( 455 install_list->AddCreateRegKeyWorkItem(
447 root_key, 456 root_key,
448 installer_state.multi_package_binaries_distribution()-> 457 installer_state.multi_package_binaries_distribution()->
449 GetStateMediumKey().c_str()); 458 GetStateMediumKey().c_str());
450 } 459 }
451 460
452 // Creating the ClientState key for binaries, if we're migrating to multi then 461 // Creating the ClientState key for binaries, if we're migrating to multi then
453 // copy over Chrome's brand code if it has one. Chrome Frame currently never 462 // copy over Chrome's brand code if it has one. Chrome Frame currently never
454 // has a brand code. 463 // has a brand code.
455 if (installer_state.state_type() != BrowserDistribution::CHROME_BINARIES) { 464 if (installer_state.state_type() != BrowserDistribution::CHROME_BINARIES) {
456 const ProductState* chrome_product_state = 465 const ProductState* chrome_product_state =
457 original_state.GetNonVersionedProductState( 466 original_state.GetNonVersionedProductState(
458 system_install, BrowserDistribution::CHROME_BROWSER); 467 system_install, BrowserDistribution::CHROME_BROWSER);
459 468
460 const std::wstring& brand(chrome_product_state->brand()); 469 const string16& brand(chrome_product_state->brand());
grt (UTC plus 2) 2012/08/30 04:15:25 please revert this since ProductState::brand still
gab 2012/08/30 14:24:32 Does it matter? I'd rather be consistent on a per-
grt (UTC plus 2) 2012/08/30 19:10:18 My preferred way of doing the wstring -> string16
461 if (!brand.empty()) { 470 if (!brand.empty()) {
462 install_list->AddCreateRegKeyWorkItem(root_key, multi_key); 471 install_list->AddCreateRegKeyWorkItem(root_key, multi_key);
463 // Write Chrome's brand code to the multi key. Never overwrite the value 472 // Write Chrome's brand code to the multi key. Never overwrite the value
464 // if one is already present (although this shouldn't happen). 473 // if one is already present (although this shouldn't happen).
465 install_list->AddSetRegValueWorkItem(root_key, 474 install_list->AddSetRegValueWorkItem(root_key,
466 multi_key, 475 multi_key,
467 google_update::kRegBrandField, 476 google_update::kRegBrandField,
468 brand, 477 brand,
469 false); 478 false);
470 } 479 }
(...skipping 28 matching lines...) Expand all
499 BrowserDistribution* dist = (*scan)->distribution(); 508 BrowserDistribution* dist = (*scan)->distribution();
500 const ProductState* product_state = 509 const ProductState* product_state =
501 original_state.GetNonVersionedProductState( 510 original_state.GetNonVersionedProductState(
502 installer_state.system_install(), dist->GetType()); 511 installer_state.system_install(), dist->GetType());
503 value_found = product_state->GetUsageStats(&usagestats); 512 value_found = product_state->GetUsageStats(&usagestats);
504 } 513 }
505 514
506 // If a value was found, write it in the appropriate location for the 515 // If a value was found, write it in the appropriate location for the
507 // binaries and remove all values from the products. 516 // binaries and remove all values from the products.
508 if (value_found) { 517 if (value_found) {
509 std::wstring state_key( 518 string16 state_key(
510 installer_state.multi_package_binaries_distribution()->GetStateKey()); 519 installer_state.multi_package_binaries_distribution()->GetStateKey());
511 install_list->AddCreateRegKeyWorkItem(root_key, state_key); 520 install_list->AddCreateRegKeyWorkItem(root_key, state_key);
512 // Overwrite any existing value so that overinstalls (where Omaha writes a 521 // Overwrite any existing value so that overinstalls (where Omaha writes a
513 // new value into a product's state key) pick up the correct value. 522 // new value into a product's state key) pick up the correct value.
514 install_list->AddSetRegValueWorkItem(root_key, state_key, 523 install_list->AddSetRegValueWorkItem(root_key, state_key,
515 google_update::kRegUsageStatsField, 524 google_update::kRegUsageStatsField,
516 usagestats, true); 525 usagestats, true);
517 526
518 for (Products::const_iterator scan = products.begin(), end = products.end(); 527 for (Products::const_iterator scan = products.begin(), end = products.end();
519 scan != end; ++scan) { 528 scan != end; ++scan) {
(...skipping 24 matching lines...) Expand all
544 void AddDeleteUninstallShortcutsForMSIWorkItems( 553 void AddDeleteUninstallShortcutsForMSIWorkItems(
545 const InstallerState& installer_state, 554 const InstallerState& installer_state,
546 const Product& product, 555 const Product& product,
547 const FilePath& temp_path, 556 const FilePath& temp_path,
548 WorkItemList* work_item_list) { 557 WorkItemList* work_item_list) {
549 DCHECK(installer_state.is_msi()) 558 DCHECK(installer_state.is_msi())
550 << "This must only be called for MSI installations!"; 559 << "This must only be called for MSI installations!";
551 560
552 // First attempt to delete the old installation's ARP dialog entry. 561 // First attempt to delete the old installation's ARP dialog entry.
553 HKEY reg_root = installer_state.root_key(); 562 HKEY reg_root = installer_state.root_key();
554 std::wstring uninstall_reg(product.distribution()->GetUninstallRegPath()); 563 string16 uninstall_reg(product.distribution()->GetUninstallRegPath());
555 564
556 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem( 565 WorkItem* delete_reg_key = work_item_list->AddDeleteRegKeyWorkItem(
557 reg_root, uninstall_reg); 566 reg_root, uninstall_reg);
558 delete_reg_key->set_ignore_failure(true); 567 delete_reg_key->set_ignore_failure(true);
559 568
560 // Then attempt to delete the old installation's start menu shortcut. 569 // Then attempt to delete the old installation's start menu shortcut.
561 FilePath uninstall_link; 570 FilePath uninstall_link;
562 if (installer_state.system_install()) { 571 if (installer_state.system_install()) {
563 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link); 572 PathService::Get(base::DIR_COMMON_START_MENU, &uninstall_link);
564 } else { 573 } else {
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
622 .Append(setup_path.BaseName())); 631 .Append(setup_path.BaseName()));
623 632
624 CommandLine rename(installer_path); 633 CommandLine rename(installer_path);
625 rename.AppendSwitch(switches::kRenameChromeExe); 634 rename.AppendSwitch(switches::kRenameChromeExe);
626 if (installer_state.system_install()) 635 if (installer_state.system_install())
627 rename.AppendSwitch(switches::kSystemLevel); 636 rename.AppendSwitch(switches::kSystemLevel);
628 637
629 if (installer_state.verbose_logging()) 638 if (installer_state.verbose_logging())
630 rename.AppendSwitch(switches::kVerboseLogging); 639 rename.AppendSwitch(switches::kVerboseLogging);
631 640
632 std::wstring version_key; 641 string16 version_key;
633 for (size_t i = 0; i < products.size(); ++i) { 642 for (size_t i = 0; i < products.size(); ++i) {
634 BrowserDistribution* dist = products[i]->distribution(); 643 BrowserDistribution* dist = products[i]->distribution();
635 version_key = dist->GetVersionKey(); 644 version_key = dist->GetVersionKey();
636 645
637 if (current_version != NULL) { 646 if (current_version != NULL) {
638 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key, 647 in_use_update_work_items->AddSetRegValueWorkItem(root, version_key,
639 google_update::kRegOldVersionField, 648 google_update::kRegOldVersionField,
640 ASCIIToWide(current_version->GetString()), true); 649 ASCIIToWide(current_version->GetString()), true);
641 } 650 }
642 if (critical_version.IsValid()) { 651 if (critical_version.IsValid()) {
(...skipping 30 matching lines...) Expand all
673 // Append work items that will be executed if this was NOT an in-use update. 682 // Append work items that will be executed if this was NOT an in-use update.
674 { 683 {
675 scoped_ptr<WorkItemList> regular_update_work_items( 684 scoped_ptr<WorkItemList> regular_update_work_items(
676 WorkItem::CreateConditionalWorkItemList( 685 WorkItem::CreateConditionalWorkItemList(
677 new Not(new ConditionRunIfFileExists(new_chrome_exe)))); 686 new Not(new ConditionRunIfFileExists(new_chrome_exe))));
678 regular_update_work_items->set_log_message("RegularUpdateWorkItemList"); 687 regular_update_work_items->set_log_message("RegularUpdateWorkItemList");
679 688
680 // Since this was not an in-use-update, delete 'opv', 'cpv', and 'cmd' keys. 689 // Since this was not an in-use-update, delete 'opv', 'cpv', and 'cmd' keys.
681 for (size_t i = 0; i < products.size(); ++i) { 690 for (size_t i = 0; i < products.size(); ++i) {
682 BrowserDistribution* dist = products[i]->distribution(); 691 BrowserDistribution* dist = products[i]->distribution();
683 std::wstring version_key(dist->GetVersionKey()); 692 string16 version_key(dist->GetVersionKey());
684 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 693 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
685 google_update::kRegOldVersionField); 694 google_update::kRegOldVersionField);
686 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 695 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
687 google_update::kRegCriticalVersionField); 696 google_update::kRegCriticalVersionField);
688 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key, 697 regular_update_work_items->AddDeleteRegValueWorkItem(root, version_key,
689 google_update::kRegRenameCmdField); 698 google_update::kRegRenameCmdField);
690 } 699 }
691 700
692 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) { 701 if (installer_state.FindProduct(BrowserDistribution::CHROME_FRAME)) {
693 AddDeleteOldIELowRightsPolicyWorkItems(installer_state, 702 AddDeleteOldIELowRightsPolicyWorkItems(installer_state,
(...skipping 286 matching lines...) Expand 10 before | Expand all | Expand 10 after
980 const FilePath& setup_path, 989 const FilePath& setup_path,
981 const Version& new_version, 990 const Version& new_version,
982 const Product& product, 991 const Product& product,
983 WorkItemList* list) { 992 WorkItemList* list) {
984 DCHECK(product.is_chrome_frame()); 993 DCHECK(product.is_chrome_frame());
985 if (!installer_state.is_multi_install()) { 994 if (!installer_state.is_multi_install()) {
986 VLOG(1) << "Not adding GCF specific work items for single install."; 995 VLOG(1) << "Not adding GCF specific work items for single install.";
987 return; 996 return;
988 } 997 }
989 998
990 std::wstring version_key(product.distribution()->GetVersionKey()); 999 string16 version_key(product.distribution()->GetVersionKey());
991 bool ready_mode = product.HasOption(kOptionReadyMode); 1000 bool ready_mode = product.HasOption(kOptionReadyMode);
992 HKEY root = installer_state.root_key(); 1001 HKEY root = installer_state.root_key();
993 const bool is_install = 1002 const bool is_install =
994 (installer_state.operation() != InstallerState::UNINSTALL); 1003 (installer_state.operation() != InstallerState::UNINSTALL);
995 bool update_chrome_uninstall_command = false; 1004 bool update_chrome_uninstall_command = false;
996 BrowserDistribution* dist = 1005 BrowserDistribution* dist =
997 installer_state.multi_package_binaries_distribution(); 1006 installer_state.multi_package_binaries_distribution();
998 if (ready_mode) { 1007 if (ready_mode) {
999 // If GCF is being installed in ready mode, we write an entry to the 1008 // If GCF is being installed in ready mode, we write an entry to the
1000 // multi-install state key. If the value already exists, we will not 1009 // multi-install state key. If the value already exists, we will not
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1291 // this is done only as a convenience; there is no need for the GUID of the Low 1300 // this is done only as a convenience; there is no need for the GUID of the Low
1292 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to 1301 // Rights policies to match the ChromeFrame class's GUID. Hence, it is safe to
1293 // use this completely unrelated GUID for the "old" policies. 1302 // use this completely unrelated GUID for the "old" policies.
1294 const wchar_t kIELowRightsPolicyOldGuid[] = 1303 const wchar_t kIELowRightsPolicyOldGuid[] =
1295 L"{6C288DD7-76FB-4721-B628-56FAC252E199}"; 1304 L"{6C288DD7-76FB-4721-B628-56FAC252E199}";
1296 1305
1297 const wchar_t kElevationPolicyKeyPath[] = 1306 const wchar_t kElevationPolicyKeyPath[] =
1298 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\"; 1307 L"SOFTWARE\\Microsoft\\Internet Explorer\\Low Rights\\ElevationPolicy\\";
1299 1308
1300 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy, 1309 void GetIELowRightsElevationPolicyKeyPath(ElevationPolicyId policy,
1301 std::wstring* key_path) { 1310 string16* key_path) {
1302 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY); 1311 DCHECK(policy == CURRENT_ELEVATION_POLICY || policy == OLD_ELEVATION_POLICY);
1303 1312
1304 key_path->assign(kElevationPolicyKeyPath, 1313 key_path->assign(kElevationPolicyKeyPath,
1305 arraysize(kElevationPolicyKeyPath) - 1); 1314 arraysize(kElevationPolicyKeyPath) - 1);
1306 if (policy == CURRENT_ELEVATION_POLICY) { 1315 if (policy == CURRENT_ELEVATION_POLICY) {
1307 wchar_t cf_clsid[64]; 1316 wchar_t cf_clsid[64];
1308 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0], 1317 int len = StringFromGUID2(__uuidof(ChromeFrame), &cf_clsid[0],
1309 arraysize(cf_clsid)); 1318 arraysize(cf_clsid));
1310 key_path->append(&cf_clsid[0], len - 1); 1319 key_path->append(&cf_clsid[0], len - 1);
1311 } else { 1320 } else {
1312 key_path->append(kIELowRightsPolicyOldGuid, 1321 key_path->append(kIELowRightsPolicyOldGuid,
1313 arraysize(kIELowRightsPolicyOldGuid)- 1); 1322 arraysize(kIELowRightsPolicyOldGuid)- 1);
1314 } 1323 }
1315 } 1324 }
1316 1325
1317 } // namespace 1326 } // namespace
1318 1327
1319 void AddDeleteOldIELowRightsPolicyWorkItems( 1328 void AddDeleteOldIELowRightsPolicyWorkItems(
1320 const InstallerState& installer_state, 1329 const InstallerState& installer_state,
1321 WorkItemList* install_list) { 1330 WorkItemList* install_list) {
1322 DCHECK(install_list); 1331 DCHECK(install_list);
1323 1332
1324 std::wstring key_path; 1333 string16 key_path;
1325 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path); 1334 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &key_path);
1326 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path); 1335 install_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), key_path);
1327 } 1336 }
1328 1337
1329 // Adds work items to copy the chrome_launcher IE low rights elevation policy 1338 // Adds work items to copy the chrome_launcher IE low rights elevation policy
1330 // from the primary policy GUID to the "old" policy GUID. Take care not to 1339 // from the primary policy GUID to the "old" policy GUID. Take care not to
1331 // perform the copy if there is already an old policy present, as the ones under 1340 // perform the copy if there is already an old policy present, as the ones under
1332 // the main kElevationPolicyGuid would then correspond to an intermediate 1341 // the main kElevationPolicyGuid would then correspond to an intermediate
1333 // version (current_version < pv < new_version). 1342 // version (current_version < pv < new_version).
1334 void AddCopyIELowRightsPolicyWorkItems(const InstallerState& installer_state, 1343 void AddCopyIELowRightsPolicyWorkItems(const InstallerState& installer_state,
1335 WorkItemList* install_list) { 1344 WorkItemList* install_list) {
1336 DCHECK(install_list); 1345 DCHECK(install_list);
1337 1346
1338 std::wstring current_key_path; 1347 string16 current_key_path;
1339 std::wstring old_key_path; 1348 string16 old_key_path;
1340 1349
1341 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY, 1350 GetIELowRightsElevationPolicyKeyPath(CURRENT_ELEVATION_POLICY,
1342 &current_key_path); 1351 &current_key_path);
1343 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path); 1352 GetIELowRightsElevationPolicyKeyPath(OLD_ELEVATION_POLICY, &old_key_path);
1344 // Do not clobber existing old policies. 1353 // Do not clobber existing old policies.
1345 install_list->AddCopyRegKeyWorkItem(installer_state.root_key(), 1354 install_list->AddCopyRegKeyWorkItem(installer_state.root_key(),
1346 current_key_path, old_key_path, 1355 current_key_path, old_key_path,
1347 WorkItem::IF_NOT_PRESENT); 1356 WorkItem::IF_NOT_PRESENT);
1348 } 1357 }
1349 1358
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1391 } 1400 }
1392 } 1401 }
1393 1402
1394 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state, 1403 void AddGenericQuickEnableWorkItems(const InstallerState& installer_state,
1395 const InstallationState& machine_state, 1404 const InstallationState& machine_state,
1396 const FilePath* setup_path, 1405 const FilePath* setup_path,
1397 const Version* new_version, 1406 const Version* new_version,
1398 WorkItemList* work_item_list, 1407 WorkItemList* work_item_list,
1399 bool have_child_product, 1408 bool have_child_product,
1400 const CommandLine& child_product_switches, 1409 const CommandLine& child_product_switches,
1401 const std::wstring& command_id) { 1410 const string16& command_id) {
1402 DCHECK(setup_path || 1411 DCHECK(setup_path ||
1403 installer_state.operation() == InstallerState::UNINSTALL); 1412 installer_state.operation() == InstallerState::UNINSTALL);
1404 DCHECK(new_version || 1413 DCHECK(new_version ||
1405 installer_state.operation() == InstallerState::UNINSTALL); 1414 installer_state.operation() == InstallerState::UNINSTALL);
1406 DCHECK(work_item_list); 1415 DCHECK(work_item_list);
1407 1416
1408 const bool system_install = installer_state.system_install(); 1417 const bool system_install = installer_state.system_install();
1409 bool have_chrome_binaries = false; 1418 bool have_chrome_binaries = false;
1410 1419
1411 // STEP 1: Figure out the state of the machine before the operation. 1420 // STEP 1: Figure out the state of the machine before the operation.
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
1472 setup_path->BaseName()); 1481 setup_path->BaseName());
1473 } 1482 }
1474 } 1483 }
1475 1484
1476 // STEP 4: Take action. 1485 // STEP 4: Take action.
1477 if (operation != DO_NOTHING) { 1486 if (operation != DO_NOTHING) {
1478 // Get the path to the quick-enable-cf command for the binaries. 1487 // Get the path to the quick-enable-cf command for the binaries.
1479 BrowserDistribution* binaries = 1488 BrowserDistribution* binaries =
1480 BrowserDistribution::GetSpecificDistribution( 1489 BrowserDistribution::GetSpecificDistribution(
1481 BrowserDistribution::CHROME_BINARIES); 1490 BrowserDistribution::CHROME_BINARIES);
1482 std::wstring cmd_key(binaries->GetVersionKey()); 1491 string16 cmd_key(binaries->GetVersionKey());
1483 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey) 1492 cmd_key.append(1, L'\\').append(google_update::kRegCommandsKey)
1484 .append(1, L'\\').append(command_id); 1493 .append(1, L'\\').append(command_id);
1485 1494
1486 if (operation == ADD_COMMAND) { 1495 if (operation == ADD_COMMAND) {
1487 DCHECK(!binaries_setup_path.empty()); 1496 DCHECK(!binaries_setup_path.empty());
1488 CommandLine cmd_line(binaries_setup_path); 1497 CommandLine cmd_line(binaries_setup_path);
1489 cmd_line.AppendArguments(child_product_switches, 1498 cmd_line.AppendArguments(child_product_switches,
1490 false); // include_program 1499 false); // include_program
1491 if (installer_state.verbose_logging()) 1500 if (installer_state.verbose_logging())
1492 cmd_line.AppendSwitch(switches::kVerboseLogging); 1501 cmd_line.AppendSwitch(switches::kVerboseLogging);
1493 AppCommand cmd(cmd_line.GetCommandLineString(), true, true); 1502 AppCommand cmd(cmd_line.GetCommandLineString());
1503 cmd.set_sends_pings(true);
1504 cmd.set_is_web_accessible(true);
1494 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list); 1505 cmd.AddWorkItems(installer_state.root_key(), cmd_key, work_item_list);
1495 } else { 1506 } else {
1496 DCHECK(operation == REMOVE_COMMAND); 1507 DCHECK(operation == REMOVE_COMMAND);
1497 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(), 1508 work_item_list->AddDeleteRegKeyWorkItem(installer_state.root_key(),
1498 cmd_key)->set_log_message( 1509 cmd_key)->set_log_message(
1499 "removing " + WideToASCII(command_id) + " command"); 1510 "removing " + WideToASCII(command_id) + " command");
1500 } 1511 }
1501 } 1512 }
1502 } 1513 }
1503 1514
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 AddGenericQuickEnableWorkItems(installer_state, 1597 AddGenericQuickEnableWorkItems(installer_state,
1587 machine_state, 1598 machine_state,
1588 setup_path, 1599 setup_path,
1589 new_version, 1600 new_version,
1590 work_item_list, 1601 work_item_list,
1591 false, // have_child_product 1602 false, // have_child_product
1592 cmd_line, 1603 cmd_line,
1593 kCmdQuickEnableApplicationHost); 1604 kCmdQuickEnableApplicationHost);
1594 } 1605 }
1595 1606
1607 void AddOsUpgradeWorkItems(const InstallerState& installer_state,
1608 const FilePath* setup_path,
1609 const Version* new_version,
1610 const Product& product,
1611 WorkItemList* install_list) {
1612 const HKEY root_key = installer_state.root_key();
1613 string16 cmd_key(product.distribution()->GetVersionKey());
gab 2012/08/30 14:24:32 Why initialize and then use append? I would prefer
huangs 2012/08/30 17:13:07 Per our discussion, not changing.
1614 cmd_key.append(1, FilePath::kSeparators[0])
1615 .append(google_update::kRegCommandsKey)
1616 .append(1, FilePath::kSeparators[0]).append(kCmdOnOsUpgrade);
grt (UTC plus 2) 2012/08/30 04:15:25 nit: move this last append to its own line
huangs 2012/08/30 17:13:07 Done.
1617
1618 if (installer_state.operation() != InstallerState::UNINSTALL) {
1619 CommandLine cmd_line(installer_state
1620 .GetInstallerDirectory(*new_version).Append(setup_path->BaseName()));
gab 2012/08/30 14:24:32 s/setup_path->BaseName()/installer::kSetupExe and
grt (UTC plus 2) 2012/08/30 17:06:08 Please don't. BaseName() of the exe is what's use
huangs 2012/08/30 17:13:07 Done.
gab 2012/08/30 17:15:50 Changing the name in the future would be the crazi
1621 // Add the main option to indicate OS upgrade flow.
1622 cmd_line.AppendSwitch(installer::switches::kOnOsUpgrade);
1623 // Add product-specific options.
1624 product.AppendProductFlags(&cmd_line);
1625 if (installer_state.system_install())
1626 cmd_line.AppendSwitch(installer::switches::kSystemLevel);
1627 if (installer_state.verbose_logging())
1628 cmd_line.AppendSwitch(installer::switches::kVerboseLogging);
grt (UTC plus 2) 2012/08/30 04:15:25 i think this should be added unconditionally, at l
huangs 2012/08/30 17:13:07 Done.
1629
1630 install_list->set_log_message("Adding OS upgrade command");
1631 AppCommand cmd(cmd_line.GetCommandLineString());
1632 cmd.set_is_auto_run_on_os_upgrade(true);
1633 cmd.AddWorkItems(installer_state.root_key(), cmd_key, install_list);
1634 } else {
1635 install_list->set_log_message("Removing OS upgrade command");
grt (UTC plus 2) 2012/08/30 04:15:25 i think you want to set the message for the item a
huangs 2012/08/30 17:13:07 Done.
1636 install_list->AddDeleteRegKeyWorkItem(root_key, cmd_key);
1637 }
1638 }
1639
1596 } // namespace installer 1640 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698