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.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.level == ShellUtil::CURRENT_USER) ? "per-user " : | |
66 "all-users "); | |
67 switch (location) { | |
68 case ShellUtil::SHORTCUT_DESKTOP: | |
69 message.append("Desktop "); | |
70 break; | |
71 case ShellUtil::SHORTCUT_QUICK_LAUNCH: | |
72 message.append("Quick Launch "); | |
73 break; | |
74 case ShellUtil::SHORTCUT_START_MENU: | |
75 message.append("Start menu "); | |
76 break; | |
77 default: | |
78 NOTREACHED(); | |
79 } | |
80 | |
81 message.push_back('"'); | |
82 if (properties.options & | |
83 ShellUtil::ChromeShortcutProperties::PROPERTIES_SHORTCUT_NAME) { | |
84 message.append(UTF16ToUTF8(properties.shortcut_name)); | |
85 } else { | |
86 message.append(UTF16ToUTF8(dist->GetAppShortCutName())); | |
87 } | |
88 message.push_back('"'); | |
89 | |
90 message.append(" shortcut to "); | |
robertshield
2012/10/04 00:25:23
shouldn't this line be inside the if below?
gab
2012/10/04 04:10:32
No, there is always a |chrome_exe| (in CREATE and
| |
91 message.append(UTF16ToUTF8(properties.chrome_exe.value())); | |
92 if (properties.options & | |
93 ShellUtil::ChromeShortcutProperties::PROPERTIES_ARGUMENTS) { | |
94 message.append(UTF16ToUTF8(properties.arguments)); | |
95 } | |
96 | |
97 if (properties.pin_to_taskbar && | |
98 base::win::GetVersion() >= base::win::VERSION_WIN7) { | |
99 message.append(" and pinning to the taskbar."); | |
100 } else { | |
101 message.push_back('.'); | |
102 } | |
103 | |
104 if (failed) | |
105 LOG(WARNING) << message; | |
106 else | |
107 VLOG(1) << message; | |
108 } | |
109 | |
110 void ExecuteAndLogShortcutOperation( | |
111 ShellUtil::ChromeShortcutLocation location, | |
112 BrowserDistribution* dist, | |
113 const ShellUtil::ChromeShortcutProperties& properties, | |
114 ShellUtil::ChromeShortcutOperation operation) { | |
115 LogShortcutOperation(location, dist, properties, operation, false); | |
116 if (!ShellUtil::CreateOrUpdateChromeShortcut(location, dist, properties, | |
117 operation)) { | |
118 LogShortcutOperation(location, dist, properties, operation, true); | |
119 } | |
120 } | |
121 | |
46 void AddChromeToMediaPlayerList() { | 122 void AddChromeToMediaPlayerList() { |
47 string16 reg_path(installer::kMediaPlayerRegPath); | 123 string16 reg_path(installer::kMediaPlayerRegPath); |
48 // registry paths can also be appended like file system path | 124 // registry paths can also be appended like file system path |
49 reg_path.push_back(FilePath::kSeparators[0]); | 125 reg_path.push_back(FilePath::kSeparators[0]); |
50 reg_path.append(installer::kChromeExe); | 126 reg_path.append(installer::kChromeExe); |
51 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 127 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
52 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 128 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
53 HKEY_LOCAL_MACHINE, reg_path)); | 129 HKEY_LOCAL_MACHINE, reg_path)); |
54 | 130 |
55 // if the operation fails we log the error but still continue | 131 // if the operation fails we log the error but still continue |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
250 << " to " << src_path.value(); | 326 << " to " << src_path.value(); |
251 return true; | 327 return true; |
252 } else { | 328 } else { |
253 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest | 329 PLOG(ERROR) << "Error writing " << installer::kVisualElementsManifest |
254 << " to " << src_path.value(); | 330 << " to " << src_path.value(); |
255 return false; | 331 return false; |
256 } | 332 } |
257 } | 333 } |
258 } | 334 } |
259 | 335 |
260 void CreateOrUpdateStartMenuAndTaskbarShortcuts( | 336 void CreateOrUpdateShortcuts(const InstallerState& installer_state, |
261 const InstallerState& installer_state, | 337 const FilePath& setup_exe, |
262 const FilePath& setup_exe, | 338 const Product& product, |
263 const Product& product, | 339 InstallShortcutOperation install_operation, |
264 uint32 options) { | 340 bool alternate_desktop_shortcut) { |
265 // TODO(tommi): Change this function to use WorkItemList. | 341 // TODO(tommi): Change this function to use WorkItemList. |
266 DCHECK(product.is_chrome()); | 342 DCHECK(product.is_chrome()); |
267 | 343 |
268 // Information used for all shortcut types | 344 BrowserDistribution* dist = product.distribution(); |
269 BrowserDistribution* browser_dist = product.distribution(); | 345 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)); | 346 installer_state.target_path().Append(installer::kChromeExe)); |
347 ShellUtil::ShellChange install_level = | |
348 installer_state.system_install() ? ShellUtil::SYSTEM_LEVEL : | |
349 ShellUtil::CURRENT_USER; | |
275 | 350 |
276 bool create_always = ((options & ShellUtil::SHORTCUT_CREATE_ALWAYS) != 0); | 351 // The default operation on update is to overwrite shortcuts with the |
277 const char* operation = create_always ? "Creating" : "Updating"; | 352 // currently desired properties, but do so only for shortcuts that still |
353 // exist. | |
354 ShellUtil::ChromeShortcutOperation operation = | |
robertshield
2012/10/04 00:25:23
please call this shortcut_operation instead.
gab
2012/10/04 04:10:32
Done.
| |
355 ShellUtil::SHORTCUT_REPLACE_EXISTING; | |
356 // |base_properties|: The basic properties to set on every shortcut installed | |
357 // (to be refined on a per-shortcut basis). | |
358 ShellUtil::ChromeShortcutProperties base_properties(install_level); | |
359 base_properties.set_chrome_exe(chrome_exe); | |
360 // The DUAL_MODE property is technically only needed on the Start Screen | |
361 // shortcut on Win8, but we set it on all shortcuts so that pinning any of the | |
362 // shortcuts to the Start Screen results in a shortcut with Metro properties. | |
363 base_properties.set_dual_mode(true); | |
robertshield
2012/10/04 00:25:23
imo some lines of whitespace here would make this
gab
2012/10/04 04:10:32
Done.
| |
364 // Handle Desktop and Quick Launch shortcuts creation. | |
365 // If |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, create optional | |
366 // shortcuts immediately; otherwise delay their creation until first run (if | |
367 // they already exist, (i.e. on update) update them). | |
368 if (install_operation == INSTALL_SHORTCUT_CREATE_ALL) | |
369 operation = ShellUtil::SHORTCUT_CREATE_ALWAYS; | |
370 ShellUtil::ChromeShortcutProperties desktop_properties(base_properties); | |
371 // Use the alternate name for the Desktop shortcut if indicated. | |
372 if (alternate_desktop_shortcut) | |
373 desktop_properties.set_shortcut_name(dist->GetAlternateApplicationName()); | |
374 ExecuteAndLogShortcutOperation( | |
375 ShellUtil::SHORTCUT_DESKTOP, dist, desktop_properties, operation); | |
278 | 376 |
279 // Create Start Menu shortcuts. | 377 // |base_properties| are sufficient for the Quick Launch shortcut. |
280 // The location of Start->Programs->Google Chrome folder | 378 ExecuteAndLogShortcutOperation( |
281 FilePath start_menu_folder_path; | 379 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, base_properties, operation); |
282 int dir_enum = installer_state.system_install() ? | 380 if (installer_state.system_install() && |
283 base::DIR_COMMON_START_MENU : base::DIR_START_MENU; | 381 operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) { |
284 if (!PathService::Get(dir_enum, &start_menu_folder_path)) { | 382 // On system-level installs, also create the quick launch shortcut for this |
285 LOG(ERROR) << "Failed to get start menu path."; | 383 // user (as the all-users shortcut created is in "Default User" and only |
286 return; | 384 // affects new users). |
385 ShellUtil::ChromeShortcutProperties user_ql_properties(base_properties); | |
386 user_ql_properties.level = ShellUtil::CURRENT_USER; | |
387 ExecuteAndLogShortcutOperation( | |
388 ShellUtil::SHORTCUT_QUICK_LAUNCH, dist, user_ql_properties, operation); | |
287 } | 389 } |
288 | 390 |
289 start_menu_folder_path = start_menu_folder_path.Append(product_name); | 391 // |operation| could already have been set to SHORTCUT_CREATE_ALWAYS above if |
392 // |install_operation| is INSTALL_SHORTCUT_CREATE_ALL, but make sure it is set | |
393 // at this point even if |install_operation| is | |
394 // INSTALL_SHORTCUT_CREATE_MANDATORY. | |
robertshield
2012/10/04 00:25:23
I find the comment above unclear. Perhaps somethin
gab
2012/10/04 04:10:32
Done and simplified all the other comments, let me
| |
395 if (install_operation == INSTALL_SHORTCUT_CREATE_MANDATORY) | |
396 operation = ShellUtil::SHORTCUT_CREATE_ALWAYS; | |
290 | 397 |
291 // Create/update Chrome link (points to chrome.exe) & Uninstall Chrome link | 398 ShellUtil::ChromeShortcutProperties start_menu_properties(base_properties); |
292 // (which points to setup.exe) under |start_menu_folder_path|. | 399 if (operation == ShellUtil::SHORTCUT_CREATE_ALWAYS) |
400 start_menu_properties.set_pin_to_taskbar(true); | |
401 ExecuteAndLogShortcutOperation( | |
402 ShellUtil::SHORTCUT_START_MENU, dist, start_menu_properties, operation); | |
293 | 403 |
294 // Chrome link (launches Chrome) | 404 // 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")); | 405 // install. MSI installations are, for the time being, managed only through |
296 | 406 // 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. | 407 // TODO(robertshield): We could add a shortcut to msiexec /X {GUID} here. |
323 if (!installer_state.is_msi()) { | 408 if (!installer_state.is_msi()) { |
324 // Uninstall Chrome link | 409 FilePath shortcut_path; |
325 FilePath uninstall_link(start_menu_folder_path.Append( | 410 if (!ShellUtil::GetShortcutPath(ShellUtil::SHORTCUT_START_MENU, dist, |
326 browser_dist->GetUninstallLinkName() + L".lnk")); | 411 install_level, &shortcut_path)) { |
327 | 412 NOTREACHED(); |
413 return; | |
414 } | |
415 shortcut_path = shortcut_path.Append(dist->GetUninstallLinkName() + | |
416 kLnkExt); | |
328 CommandLine arguments(CommandLine::NO_PROGRAM); | 417 CommandLine arguments(CommandLine::NO_PROGRAM); |
329 AppendUninstallCommandLineFlags(installer_state, product, &arguments); | 418 AppendUninstallCommandLineFlags(installer_state, product, &arguments); |
330 VLOG(1) << operation << " uninstall link at " << uninstall_link.value(); | 419 |
331 base::win::ShortcutProperties shortcut_properties; | 420 base::win::ShortcutProperties uninstall_properties; |
332 shortcut_properties.set_target(setup_exe); | 421 uninstall_properties.set_target(setup_exe); |
333 shortcut_properties.set_arguments(arguments.GetCommandLineString()); | 422 uninstall_properties.set_arguments(arguments.GetCommandLineString()); |
334 shortcut_properties.set_icon(setup_exe, 0); | 423 base::win::ShortcutOperation shortcut_operation = |
424 (operation == ShellUtil::SHORTCUT_CREATE_ALWAYS ? | |
425 base::win::SHORTCUT_CREATE_ALWAYS : | |
426 base::win::SHORTCUT_REPLACE_EXISTING); | |
427 const char* operation_str = | |
428 (shortcut_operation == base::win::SHORTCUT_CREATE_ALWAYS ? | |
429 "Creating" : "Updating"); | |
430 VLOG(1) << operation_str << " uninstall link at " << shortcut_path.value(); | |
335 if (!base::win::CreateOrUpdateShortcutLink( | 431 if (!base::win::CreateOrUpdateShortcutLink( |
336 uninstall_link, shortcut_properties, | 432 shortcut_path, uninstall_properties, shortcut_operation)) { |
337 create_always ? base::win::SHORTCUT_CREATE_ALWAYS : | 433 LOG(WARNING) << operation_str << " uninstall link failed."; |
338 base::win::SHORTCUT_UPDATE_EXISTING)) { | |
339 LOG(WARNING) << operation << " uninstall link at " | |
340 << uninstall_link.value() << " failed."; | |
341 } | 434 } |
342 } | 435 } |
343 } | 436 } |
344 | 437 |
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, | 438 void RegisterChromeOnMachine(const InstallerState& installer_state, |
388 const Product& product, | 439 const Product& product, |
389 bool make_chrome_default) { | 440 bool make_chrome_default) { |
390 DCHECK(product.is_chrome()); | 441 DCHECK(product.is_chrome()); |
391 | 442 |
392 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 443 // 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 | 444 // error checking here because this operation will fail if user doesn't |
394 // have admin rights and we want to ignore the error. | 445 // have admin rights and we want to ignore the error. |
395 AddChromeToMediaPlayerList(); | 446 AddChromeToMediaPlayerList(); |
396 | 447 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
472 const Product* chrome_install = | 523 const Product* chrome_install = |
473 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); | 524 installer_state.FindProduct(BrowserDistribution::CHROME_BROWSER); |
474 if (chrome_install) { | 525 if (chrome_install) { |
475 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); | 526 installer_state.UpdateStage(installer::CREATING_SHORTCUTS); |
476 | 527 |
477 bool create_all_shortcuts = false; | 528 bool create_all_shortcuts = false; |
478 prefs.GetBool(master_preferences::kCreateAllShortcuts, | 529 prefs.GetBool(master_preferences::kCreateAllShortcuts, |
479 &create_all_shortcuts); | 530 &create_all_shortcuts); |
480 bool alt_shortcut = false; | 531 bool alt_shortcut = false; |
481 prefs.GetBool(master_preferences::kAltShortcutText, &alt_shortcut); | 532 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 | 533 |
499 if (result == installer::FIRST_INSTALL_SUCCESS || | 534 InstallShortcutOperation install_operation = |
500 result == installer::INSTALL_REPAIRED) { | 535 INSTALL_SHORTCUT_REPLACE_EXISTING; |
501 // On new installs and repaired installs, always create Start Menu | 536 if (create_all_shortcuts) { |
502 // and taskbar shortcuts (i.e. even if they were previously deleted by | 537 install_operation = INSTALL_SHORTCUT_CREATE_ALL; |
503 // the user). | 538 } else if (result == installer::FIRST_INSTALL_SUCCESS || |
504 shortcut_options |= ShellUtil::SHORTCUT_CREATE_ALWAYS; | 539 result == installer::INSTALL_REPAIRED) { |
540 // On new and repaired installs, always create Start Menu, taskbar, and | |
541 // uninstall shortcuts (i.e. even if they were previously deleted by the | |
542 // user). | |
543 install_operation = INSTALL_SHORTCUT_CREATE_MANDATORY; | |
505 } | 544 } |
545 | |
506 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) | 546 FilePath setup_exe(installer_state.GetInstallerDirectory(new_version) |
507 .Append(setup_path.BaseName())); | 547 .Append(setup_path.BaseName())); |
508 CreateOrUpdateStartMenuAndTaskbarShortcuts( | 548 CreateOrUpdateShortcuts(installer_state, setup_exe, *chrome_install, |
509 installer_state, setup_exe, *chrome_install, shortcut_options); | 549 install_operation, alt_shortcut); |
510 | 550 |
511 bool make_chrome_default = false; | 551 bool make_chrome_default = false; |
512 prefs.GetBool(master_preferences::kMakeChromeDefault, | 552 prefs.GetBool(master_preferences::kMakeChromeDefault, |
513 &make_chrome_default); | 553 &make_chrome_default); |
514 | 554 |
515 // If this is not the user's first Chrome install, but they have chosen | 555 // 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 | 556 // 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 | 557 // force it here because the master_preferences file will not get copied |
518 // into the build. | 558 // into the build. |
519 bool force_chrome_default_for_user = false; | 559 bool force_chrome_default_for_user = false; |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
556 } | 596 } |
557 | 597 |
558 void HandleOsUpgradeForBrowser(const InstallerState& installer_state, | 598 void HandleOsUpgradeForBrowser(const InstallerState& installer_state, |
559 const Product& chrome, | 599 const Product& chrome, |
560 const FilePath& setup_exe) { | 600 const FilePath& setup_exe) { |
561 DCHECK(chrome.is_chrome()); | 601 DCHECK(chrome.is_chrome()); |
562 // Upon upgrading to Windows 8, we need to fix Chrome shortcuts and register | 602 // 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. | 603 // Chrome, so that Metro Chrome would work if Chrome is the default browser. |
564 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { | 604 if (base::win::GetVersion() >= base::win::VERSION_WIN8) { |
565 VLOG(1) << "Updating and registering shortcuts."; | 605 VLOG(1) << "Updating and registering shortcuts."; |
566 uint32 shortcut_options = ShellUtil::SHORTCUT_DUAL_MODE; | 606 CreateOrUpdateShortcuts( |
567 CreateOrUpdateDesktopAndQuickLaunchShortcuts( | 607 installer_state, setup_exe, chrome, INSTALL_SHORTCUT_REPLACE_EXISTING, |
568 installer_state, chrome, shortcut_options); | 608 false); |
569 CreateOrUpdateStartMenuAndTaskbarShortcuts( | |
570 installer_state, setup_exe, chrome, shortcut_options); | |
571 RegisterChromeOnMachine(installer_state, chrome, false); | 609 RegisterChromeOnMachine(installer_state, chrome, false); |
572 } | 610 } |
573 } | 611 } |
574 | 612 |
575 } // namespace installer | 613 } // namespace installer |
OLD | NEW |