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

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

Issue 10836247: Refactor ShellUtil shortcut code -- single multi-purpose methods as opposed to many slighlty diffe… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: brand new shell_util shortcut API + TESTS :)! Created 8 years, 2 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 #include "chrome/installer/setup/install.h" 5 #include "chrome/installer/setup/install.h"
6 6
7 #include <shlobj.h> 7 #include <shlobj.h>
8 #include <time.h> 8 #include <time.h>
9 #include <winuser.h> 9 #include <winuser.h>
10 10
11 #include <string>
12
11 #include "base/command_line.h" 13 #include "base/command_line.h"
12 #include "base/file_path.h" 14 #include "base/file_path.h"
13 #include "base/file_util.h" 15 #include "base/file_util.h"
14 #include "base/logging.h" 16 #include "base/logging.h"
15 #include "base/memory/scoped_ptr.h" 17 #include "base/memory/scoped_ptr.h"
16 #include "base/path_service.h" 18 #include "base/path_service.h"
17 #include "base/string_util.h" 19 #include "base/string_util.h"
18 #include "base/stringprintf.h" 20 #include "base/stringprintf.h"
19 #include "base/utf_string_conversions.h" 21 #include "base/utf_string_conversions.h"
20 #include "base/win/shortcut.h" 22 #include "base/win/shortcut.h"
21 #include "base/win/windows_version.h" 23 #include "base/win/windows_version.h"
22 #include "chrome/common/chrome_constants.h" 24 #include "chrome/common/chrome_constants.h"
23 #include "chrome/installer/setup/setup_constants.h" 25 #include "chrome/installer/setup/setup_constants.h"
24 #include "chrome/installer/setup/install_worker.h" 26 #include "chrome/installer/setup/install_worker.h"
25 #include "chrome/installer/util/auto_launch_util.h" 27 #include "chrome/installer/util/auto_launch_util.h"
26 #include "chrome/installer/util/browser_distribution.h" 28 #include "chrome/installer/util/browser_distribution.h"
27 #include "chrome/installer/util/create_reg_key_work_item.h" 29 #include "chrome/installer/util/create_reg_key_work_item.h"
28 #include "chrome/installer/util/delete_after_reboot_helper.h" 30 #include "chrome/installer/util/delete_after_reboot_helper.h"
29 #include "chrome/installer/util/google_update_constants.h" 31 #include "chrome/installer/util/google_update_constants.h"
30 #include "chrome/installer/util/helper.h" 32 #include "chrome/installer/util/helper.h"
31 #include "chrome/installer/util/install_util.h" 33 #include "chrome/installer/util/install_util.h"
34 #include "chrome/installer/util/master_preferences.h"
32 #include "chrome/installer/util/master_preferences_constants.h" 35 #include "chrome/installer/util/master_preferences_constants.h"
33 #include "chrome/installer/util/set_reg_value_work_item.h" 36 #include "chrome/installer/util/set_reg_value_work_item.h"
34 #include "chrome/installer/util/shell_util.h" 37 #include "chrome/installer/util/shell_util.h"
38 #include "chrome/installer/util/util_constants.h"
35 #include "chrome/installer/util/work_item_list.h" 39 #include "chrome/installer/util/work_item_list.h"
36 40
37 // Build-time generated include file. 41 // Build-time generated include file.
38 #include "registered_dlls.h" // NOLINT 42 #include "registered_dlls.h" // NOLINT
39 43
40 using installer::InstallerState; 44 using installer::InstallerState;
41 using installer::InstallationState; 45 using installer::InstallationState;
42 using installer::Product; 46 using installer::Product;
43 47
44 namespace { 48 namespace {
45 49
50 void LogShortcutOperation(ShellUtil::ChromeShortcutLocation location,
51 BrowserDistribution* dist,
52 const ShellUtil::ChromeShortcutProperties& properties,
53 ShellUtil::ChromeShortcutOperation operation,
54 bool failed) {
55 // SHORTCUT_UPDATE_EXISTING should not be used at install and thus this method
56 // does not handle logging a message for it.
57 DCHECK(operation != ShellUtil::SHORTCUT_UPDATE_EXISTING);
58 std::string message;
59 if (failed)
60 message.append("Failed: ");
61 message.append(operation == ShellUtil::SHORTCUT_CREATE_ALWAYS ?
62 "Creating " : "Overwriting ");
63 if (failed && operation == ShellUtil::SHORTCUT_REPLACE_EXISTING)
64 message.append("(maybe the shortcut doesn't exist?) ");
65 message.append(properties.system_level ? "all-users " : "per-user ");
66 switch (location) {
67 case ShellUtil::SHORTCUT_DESKTOP:
68 message.append("Desktop ");
69 break;
70 case ShellUtil::SHORTCUT_QUICK_LAUNCH:
71 message.append("Quick Launch ");
72 break;
73 case ShellUtil::SHORTCUT_START_MENU:
74 message.append("Start menu ");
75 break;
76 default:
77 NOTREACHED();
78 }
79
80 message.push_back('"');
81 if (properties.options &
82 ShellUtil::ChromeShortcutProperties::PROPERTIES_SHORTCUT_NAME) {
83 message.append(UTF16ToUTF8(properties.shortcut_name));
84 } else {
85 message.append(UTF16ToUTF8(dist->GetAppShortCutName()));
86 }
87 message.push_back('"');
88
89 message.append(" shortcut to ");
90 message.append(UTF16ToUTF8(properties.target.value()));
91 if (properties.options &
92 ShellUtil::ChromeShortcutProperties::PROPERTIES_ARGUMENTS) {
93 message.append(UTF16ToUTF8(properties.arguments));
94 }
95
96 if (properties.pin_to_taskbar &&
97 base::win::GetVersion() >= base::win::VERSION_WIN7) {
98 message.append(" and pinning to the taskbar.");
99 } else {
100 message.push_back('.');
101 }
102
103 if (failed)
104 LOG(WARNING) << message;
105 else
106 VLOG(1) << message;
107 }
108
109 void ExecuteAndLogShortcutOperation(
110 ShellUtil::ChromeShortcutLocation location,
111 BrowserDistribution* dist,
112 const ShellUtil::ChromeShortcutProperties& properties,
113 ShellUtil::ChromeShortcutOperation operation) {
114 LogShortcutOperation(location, dist, properties, operation, false);
115 if (!ShellUtil::CreateOrUpdateChromeShortcut(location, dist, properties,
116 operation)) {
117 LogShortcutOperation(location, dist, properties, operation, true);
118 }
119 }
120
46 void AddChromeToMediaPlayerList() { 121 void AddChromeToMediaPlayerList() {
47 string16 reg_path(installer::kMediaPlayerRegPath); 122 string16 reg_path(installer::kMediaPlayerRegPath);
48 // registry paths can also be appended like file system path 123 // registry paths can also be appended like file system path
49 reg_path.push_back(FilePath::kSeparators[0]); 124 reg_path.push_back(FilePath::kSeparators[0]);
50 reg_path.append(installer::kChromeExe); 125 reg_path.append(installer::kChromeExe);
51 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; 126 VLOG(1) << "Adding Chrome to Media player list at " << reg_path;
52 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( 127 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem(
53 HKEY_LOCAL_MACHINE, reg_path)); 128 HKEY_LOCAL_MACHINE, reg_path));
54 129
55 // if the operation fails we log the error but still continue 130 // if the operation fails we log the error but still continue
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 << " to " << src_path.value(); 325 << " to " << src_path.value();
251 return true; 326 return true;
252 } else { 327 } else {
253 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest 328 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest
254 << " to " << src_path.value(); 329 << " to " << src_path.value();
255 return false; 330 return false;
256 } 331 }
257 } 332 }
258 } 333 }
259 334
260 void CreateOrUpdateStartMenuAndTaskbarShortcuts( 335 void CreateOrUpdateShortcuts(const InstallerState& installer_state,
261 const InstallerState& installer_state, 336 const FilePath& setup_exe,
262 const FilePath& setup_exe, 337 const Product& product,
263 const Product& product, 338 InstallShortcutOperation install_operation,
264 uint32 options) { 339 bool alternate_desktop_shortcut) {
265 // TODO(tommi): Change this function to use WorkItemList. 340 // TODO(tommi): Change this function to use WorkItemList.
266 DCHECK(product.is_chrome()); 341 DCHECK(product.is_chrome());
267 342
268 // Information used for all shortcut types 343 BrowserDistribution* dist = product.distribution();
269 BrowserDistribution* browser_dist = product.distribution(); 344 const FilePath chrome_exe(
270 const string16 product_name(browser_dist->GetAppShortCutName());
271 const string16 product_desc(browser_dist->GetAppDescription());
272 // Chrome link target
273 FilePath chrome_exe(
274 installer_state.target_path().Append(installer::kChromeExe)); 345 installer_state.target_path().Append(installer::kChromeExe));
275 346
276 bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); 347 // The default operation on update is to overwrite shortcuts with the
277 const char* operation = create_always ? "Creating" : "Updating"; 348 // currently desired properties, but do so only for shortcuts that still
349 // exist.
350 ShellUtil::ChromeShortcutOperation operation =
351 ShellUtil::SHORTCUT_REPLACE_EXISTING;
352 // |base_properties|: The basic properties to set on every shortcut installed
353 // (to be refined on a per-shortcut basis).
354 ShellUtil::ChromeShortcutProperties base_properties;
355 base_properties.set_target(chrome_exe);
356 // The DUAL_MODE property is technically only needed on the Start Screen
357 // shortcut on Win8, but we set it on all shortcuts so that pinning any of the
358 // shortcuts to the Start Screen results in a shortcut with Metro properties.
359 base_properties.set_dual_mode(true);
360 base_properties.set_system_level(installer_state.system_install());
361 // Handle Desktop and Quick Launch shortcuts creation.
362 // If |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, create optional
363 // shortcuts immediately; otherwise delay their creation until first run (if
364 // they already exist, (i.e. on update) update them).
365 if (install_operation == INSTALL_SHORTCUT_CREATE_ALL)
366 operation = ShellUtil::SHORTCUT_CREATE_ALWAYS;
367 ShellUtil::ChromeShortcutProperties desktop_properties(base_properties);
368 // Use the alternate name for the Desktop shortcut if indicated.
369 if (alternate_desktop_shortcut)
370 desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName());
371 ExecuteAndLogShortcutOperation(
372 ShellUtil::SHORTCUT_DESKTOP, dist, desktop_properties, operation);
278 373
279 // Create Start Menu shortcuts. 374 // |base_properties| are sufficient for the Quick Launch shortcut.
280 // The location of Start->Programs->Google Chrome folder 375 ExecuteAndLogShortcutOperation(
281 FilePath start_menu_folder_path; 376 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, base_properties, operation);
282 int dir_enum = installer_state.system_install() ? 377 if (base_properties.system_level &&
283 base::DIR_COMMON_START_MENU : base::DIR_START_MENU; 378 operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) {
284 if (!PathService::Get(dir_enum, &start_menu_folder_path)) { 379 // On system-level installs, also create the quick launch shortcut for this
285 LOG(ERROR) << "Failed to get start menu path."; 380 // user (as the all-users shortcut created is in "Default User" and only
286 return; 381 // affects new users).
382 ShellUtil::ChromeShortcutProperties user_ql_properties(base_properties);
383 user_ql_properties.set_system_level(false);
384 ExecuteAndLogShortcutOperation(
385 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, user_ql_properties, operation);
287 } 386 }
288 387
289 start_menu_folder_path = start_menu_folder_path.Append(product_name); 388 // |operation| could already have been set to SHORTCUT_CREATE_ALWAYS above if
389 // |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, but make sure it is set
390 // at this point even if |install_operation| is
391 // INSTALL_SHORTCUT_CREATE_MANDATORY.
392 if (install_operation == INSTALL_SHORTCUT_CREATE_MANDATORY)
393 operation = ShellUtil::SHORTCUT_CREATE_ALWAYS;
290 394
291 // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link 395 ShellUtil::ChromeShortcutProperties start_menu_properties(base_properties);
292 // (which points to setup.exe) under |start_menu_folder_path|. 396 if (operation == ShellUtil::SHORTCUT_CREATE_ALWAYS)
397 start_menu_properties.set_pin_to_taskbar(true);
398 ExecuteAndLogShortcutOperation(
399 ShellUtil::SHORTCUT_START_MENU, dist, start_menu_properties, operation);
293 400
294 // Chrome link (launches Chrome) 401 // Create/update uninstall link in the Start menu if we are not an MSI
295 FilePath chrome_link(start_menu_folder_path.Append(product_name + L".lnk")); 402 // install. MSI installations are, for the time being, managed only through
296 403 // the Add/Remove Programs dialog.
297 if (create_always && !file_util::PathExists(start_menu_folder_path))
298 file_util::CreateDirectoryW(start_menu_folder_path);
299
300 VLOG(1) << operation << " shortcut to " << chrome_exe.value() << " at "
301 << chrome_link.value();
302 if (!ShellUtil::UpdateChromeShortcut(browser_dist, chrome_exe.value(),
303 chrome_link.value(), string16(), product_desc, chrome_exe.value(),
304 browser_dist->GetIconIndex(), options)) {
305 LOG(WARNING) << operation << " shortcut at " << chrome_link.value()
306 << " failed.";
307 } else if (create_always &&
308 base::win::GetVersion() >= base::win::VERSION_WIN7) {
309 // If the Start Menu shortcut was successfully created and |create_always|,
310 // proceed to pin the Start Menu shortcut to the taskbar on Win7+.
311 VLOG(1) << "Pinning new shortcut at " << chrome_link.value()
312 << " to taskbar";
313 if (!base::win::TaskbarPinShortcutLink(chrome_link.value().c_str())) {
314 LOG(ERROR) << "Failed to pin shortcut to taskbar: "
315 << chrome_link.value();
316 }
317 }
318
319 // Create/update uninstall link if we are not an MSI install. MSI
320 // installations are, for the time being, managed only through the
321 // Add/Remove Programs dialog.
322 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. 404 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here.
323 if (!installer_state.is_msi()) { 405 if (!installer_state.is_msi()) {
324 // Uninstall Chrome link
325 FilePath uninstall_link(start_menu_folder_path.Append(
326 browser_dist->GetUninstallLinkName() + L".lnk"));
327
328 CommandLine arguments(CommandLine::NO_PROGRAM); 406 CommandLine arguments(CommandLine::NO_PROGRAM);
329 AppendUninstallCommandLineFlags(installer_state, product, &arguments); 407 AppendUninstallCommandLineFlags(installer_state, product, &arguments);
330 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); 408 ShellUtil::ChromeShortcutProperties uninstall_properties;
331 base::win::ShortcutProperties shortcut_properties; 409 uninstall_properties.set_target(setup_exe);
332 shortcut_properties.set_target(setup_exe); 410 uninstall_properties.set_arguments(arguments.GetCommandLineString());
333 shortcut_properties.set_arguments(arguments.GetCommandLineString()); 411 uninstall_properties.set_shortcut_name(dist->GetUninstallLinkName());
334 shortcut_properties.set_icon(setup_exe, 0); 412 uninstall_properties.set_system_level(installer_state.system_install());
335 if (!base::win::CreateOrUpdateShortcutLink( 413 ExecuteAndLogShortcutOperation(
336 uninstall_link, shortcut_properties, 414 ShellUtil::SHORTCUT_START_MENU, dist, uninstall_properties, operation);
337 create_always ? base::win::SHORTCUT_CREATE_ALWAYS :
338 base::win::SHORTCUT_UPDATE_EXISTING)) {
339 LOG(WARNING) << operation << " uninstall link at "
340 << uninstall_link.value() << " failed.";
341 }
342 } 415 }
343 } 416 }
344 417
345 void CreateOrUpdateDesktopAndQuickLaunchShortcuts(
346 const InstallerState& installer_state,
347 const Product& product,
348 uint32 options) {
349 // TODO(tommi): Change this function to use WorkItemList.
350 DCHECK(product.is_chrome());
351
352 // Information used for all shortcut types
353 BrowserDistribution* browser_dist = product.distribution();
354 const string16 product_name(browser_dist->GetAppShortCutName());
355 const string16 product_desc(browser_dist->GetAppDescription());
356 // Chrome link target
357 FilePath chrome_exe(
358 installer_state.target_path().Append(installer::kChromeExe));
359
360 bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0);
361 const char* operation = create_always ? "Creating" : "Updating";
362
363 ShellUtil::ShellChange desktop_level = ShellUtil::CURRENT_USER;
364 int quick_launch_levels = ShellUtil::CURRENT_USER;
365 if (installer_state.system_install()) {
366 desktop_level = ShellUtil::SYSTEM_LEVEL;
367 quick_launch_levels |= ShellUtil::SYSTEM_LEVEL;
368 }
369
370 VLOG(1) << operation << " desktop shortcut for " << chrome_exe.value();
371 if (!ShellUtil::CreateChromeDesktopShortcut(
372 browser_dist, chrome_exe.value(), product_desc, string16(),
373 string16(), chrome_exe.value(), browser_dist->GetIconIndex(),
374 desktop_level, options)) {
375 LOG(WARNING) << operation << " desktop shortcut for " << chrome_exe.value()
376 << " failed.";
377 }
378
379 VLOG(1) << operation << " quick launch shortcut for " << chrome_exe.value();
380 if (!ShellUtil::CreateChromeQuickLaunchShortcut(
381 browser_dist, chrome_exe.value(), quick_launch_levels, options)) {
382 LOG(WARNING) << operation << " quick launch shortcut for "
383 << chrome_exe.value() << " failed.";
384 }
385 }
386
387 void RegisterChromeOnMachine(const InstallerState& installer_state, 418 void RegisterChromeOnMachine(const InstallerState& installer_state,
388 const Product& product, 419 const Product& product,
389 bool make_chrome_default) { 420 bool make_chrome_default) {
390 DCHECK(product.is_chrome()); 421 DCHECK(product.is_chrome());
391 422
392 // Try to add Chrome to Media Player shim inclusion list. We don't do any 423 // Try to add Chrome to Media Player shim inclusion list. We don't do any
393 // error checking here because this operation will fail if user doesn't 424 // error checking here because this operation will fail if user doesn't
394 // have admin rights and we want to ignore the error. 425 // have admin rights and we want to ignore the error.
395 AddChromeToMediaPlayerList(); 426 AddChromeToMediaPlayerList();
396 427
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
472 const Product* chrome_install = 503 const Product* chrome_install =
473 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); 504 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER);
474 if (chrome_install) { 505 if (chrome_install) {
475 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); 506 installer_state.UpdateStage(installer::CREATING_SHORTCUTS);
476 507
477 bool create_all_shortcuts = false; 508 bool create_all_shortcuts = false;
478 prefs.GetBool(master_preferences::kCreateAllShortcuts, 509 prefs.GetBool(master_preferences::kCreateAllShortcuts,
479 &create_all_shortcuts); 510 &create_all_shortcuts);
480 bool alt_shortcut = false; 511 bool alt_shortcut = false;
481 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); 512 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut);
482 // The DUAL_MODE property is technically only needed on the Start Screen
483 // shortcut on Win8, but we set it on all shortcuts so that pinning any
484 // of the shortcuts to the Start Screen results in a shortcut with
485 // Metro properties.
486 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE;
487 // Handle Desktop and Quick Launch shortcuts creation.
488 // If --create-all-shortcuts is specified, create them immediately;
489 // otherwise delay their creation until first run (if they already exist,
490 // (i.e. on update) update them).
491 if (create_all_shortcuts)
492 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS;
493 // Use the alternate name for the Desktop shortcut if indicated.
494 if (alt_shortcut)
495 shortcut_options |= ShellUtil::SHORTCUT_ALTERNATE;
496 CreateOrUpdateDesktopAndQuickLaunchShortcuts(
497 installer_state, *chrome_install, shortcut_options);
498 513
499 if (result == installer::FIRST_INSTALL_SUCCESS || 514 InstallShortcutOperation install_operation =
500 result == installer::INSTALL_REPAIRED) { 515 INSTALL_SHORTCUT_REPLACE_EXISTING;
501 // On new installs and repaired installs, always create Start Menu 516 if (create_all_shortcuts) {
502 // and taskbar shortcuts (i.e. even if they were previously deleted by 517 install_operation = INSTALL_SHORTCUT_CREATE_ALL;
503 // the user). 518 } else if (result == installer::FIRST_INSTALL_SUCCESS ||
504 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; 519 result == installer::INSTALL_REPAIRED) {
520 // On new and repaired installs, always create Start Menu, taskbar, and
521 // uninstall shortcuts (i.e. even if they were previously deleted by the
522 // user).
523 install_operation = INSTALL_SHORTCUT_CREATE_MANDATORY;
505 } 524 }
525
506 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) 526 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version)
507 .Append(setup_path.BaseName())); 527 .Append(setup_path.BaseName()));
508 CreateOrUpdateStartMenuAndTaskbarShortcuts( 528 CreateOrUpdateShortcuts(installer_state, setup_exe, *chrome_install,
509 installer_state, setup_exe, *chrome_install, shortcut_options); 529 install_operation, alt_shortcut);
510 530
511 bool make_chrome_default = false; 531 bool make_chrome_default = false;
512 prefs.GetBool(master_preferences::kMakeChromeDefault, 532 prefs.GetBool(master_preferences::kMakeChromeDefault,
513 &make_chrome_default); 533 &make_chrome_default);
514 534
515 // If this is not the user's first Chrome install, but they have chosen 535 // If this is not the user's first Chrome install, but they have chosen
516 // Chrome to become their default browser on the download page, we must 536 // Chrome to become their default browser on the download page, we must
517 // force it here because the master_preferences file will not get copied 537 // force it here because the master_preferences file will not get copied
518 // into the build. 538 // into the build.
519 bool force_chrome_default_for_user = false; 539 bool force_chrome_default_for_user = false;
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
556 } 576 }
557 577
558 void HandleOsUpgradeForBrowser(const InstallerState& installer_state, 578 void HandleOsUpgradeForBrowser(const InstallerState& installer_state,
559 const Product& chrome, 579 const Product& chrome,
560 const FilePath& setup_exe) { 580 const FilePath& setup_exe) {
561 DCHECK(chrome.is_chrome()); 581 DCHECK(chrome.is_chrome());
562 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register 582 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register
563 // Chrome, so that Metro Chrome would work if Chrome is the default browser. 583 // Chrome, so that Metro Chrome would work if Chrome is the default browser.
564 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { 584 if (base::win::GetVersion() >= base::win::VERSION_WIN8) {
565 VLOG(1) << "Updating and registering shortcuts."; 585 VLOG(1) << "Updating and registering shortcuts.";
566 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; 586 // Simulate an update (i.e. |status| = NEW_VERSION_UPDATED) to trigger an
567 CreateOrUpdateDesktopAndQuickLaunchShortcuts( 587 // immediate update of the shortcuts.
568 installer_state, chrome, shortcut_options); 588 CreateOrUpdateShortcuts(
569 CreateOrUpdateStartMenuAndTaskbarShortcuts( 589 installer_state, setup_exe, chrome, INSTALL_SHORTCUT_REPLACE_EXISTING,
570 installer_state, setup_exe, chrome, shortcut_options); 590 false);
571 RegisterChromeOnMachine(installer_state, chrome, false); 591 RegisterChromeOnMachine(installer_state, chrome, false);
572 } 592 }
573 } 593 }
574 594
575 } // namespace installer 595 } // namespace installer
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698