Chromium Code Reviews| 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 <windows.h> | 7 #include <windows.h> |
| 8 #include <shlobj.h> | 8 #include <shlobj.h> |
| 9 #include <time.h> | 9 #include <time.h> |
| 10 | 10 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 63 message.append("(maybe the shortcut doesn't exist?) "); | 63 message.append("(maybe the shortcut doesn't exist?) "); |
| 64 message.append((properties.level == ShellUtil::CURRENT_USER) ? "per-user " : | 64 message.append((properties.level == ShellUtil::CURRENT_USER) ? "per-user " : |
| 65 "all-users "); | 65 "all-users "); |
| 66 switch (location) { | 66 switch (location) { |
| 67 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: | 67 case ShellUtil::SHORTCUT_LOCATION_DESKTOP: |
| 68 message.append("Desktop "); | 68 message.append("Desktop "); |
| 69 break; | 69 break; |
| 70 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: | 70 case ShellUtil::SHORTCUT_LOCATION_QUICK_LAUNCH: |
| 71 message.append("Quick Launch "); | 71 message.append("Quick Launch "); |
| 72 break; | 72 break; |
| 73 case ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT: | |
| 74 message.append("Start menu "); | |
| 75 break; | |
| 73 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR: | 76 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR: |
| 74 message.append("Start menu/" + | 77 message.append("Start menu/" + |
| 75 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( | 78 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( |
| 76 BrowserDistribution::SUBFOLDER_CHROME)) + | 79 BrowserDistribution::SUBFOLDER_CHROME)) + |
| 77 " "); | 80 " "); |
| 78 break; | 81 break; |
| 79 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR: | 82 case ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_APPS_DIR: |
| 80 message.append("Start menu/" + | 83 message.append("Start menu/" + |
| 81 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( | 84 base::UTF16ToUTF8(dist->GetStartMenuShortcutSubfolder( |
| 82 BrowserDistribution::SUBFOLDER_APPS)) + | 85 BrowserDistribution::SUBFOLDER_APPS)) + |
| (...skipping 26 matching lines...) Expand all Loading... | |
| 109 } | 112 } |
| 110 | 113 |
| 111 message.push_back('.'); | 114 message.push_back('.'); |
| 112 | 115 |
| 113 if (failed) | 116 if (failed) |
| 114 LOG(WARNING) << message; | 117 LOG(WARNING) << message; |
| 115 else | 118 else |
| 116 VLOG(1) << message; | 119 VLOG(1) << message; |
| 117 } | 120 } |
| 118 | 121 |
| 119 void ExecuteAndLogShortcutOperation( | 122 bool ExecuteAndLogShortcutOperation( |
| 120 ShellUtil::ShortcutLocation location, | 123 ShellUtil::ShortcutLocation location, |
| 121 BrowserDistribution* dist, | 124 BrowserDistribution* dist, |
| 122 const ShellUtil::ShortcutProperties& properties, | 125 const ShellUtil::ShortcutProperties& properties, |
| 123 ShellUtil::ShortcutOperation operation) { | 126 ShellUtil::ShortcutOperation operation) { |
| 124 LogShortcutOperation(location, dist, properties, operation, false); | 127 LogShortcutOperation(location, dist, properties, operation, false); |
| 125 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, | 128 if (!ShellUtil::CreateOrUpdateShortcut(location, dist, properties, |
| 126 operation)) { | 129 operation)) { |
| 127 LogShortcutOperation(location, dist, properties, operation, true); | 130 LogShortcutOperation(location, dist, properties, operation, true); |
| 131 return false; | |
| 128 } | 132 } |
| 133 return true; | |
| 129 } | 134 } |
| 130 | 135 |
| 131 void AddChromeToMediaPlayerList() { | 136 void AddChromeToMediaPlayerList() { |
| 132 base::string16 reg_path(installer::kMediaPlayerRegPath); | 137 base::string16 reg_path(installer::kMediaPlayerRegPath); |
| 133 // registry paths can also be appended like file system path | 138 // registry paths can also be appended like file system path |
| 134 reg_path.push_back(base::FilePath::kSeparators[0]); | 139 reg_path.push_back(base::FilePath::kSeparators[0]); |
| 135 reg_path.append(installer::kChromeExe); | 140 reg_path.append(installer::kChromeExe); |
| 136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 141 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
| 137 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 142 scoped_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
| 138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); | 143 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); |
| (...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 427 if (InstallUtil::ShouldInstallMetroProperties()) | 432 if (InstallUtil::ShouldInstallMetroProperties()) |
| 428 start_menu_properties.set_dual_mode(true); | 433 start_menu_properties.set_dual_mode(true); |
| 429 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || | 434 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS || |
| 430 shortcut_operation == | 435 shortcut_operation == |
| 431 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { | 436 ShellUtil::SHELL_SHORTCUT_CREATE_IF_NO_SYSTEM_LEVEL) { |
| 432 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut); | 437 start_menu_properties.set_pin_to_taskbar(!do_not_create_taskbar_shortcut); |
| 433 // Disabled for now. TODO(gab): Remove this and the associated code if it | 438 // Disabled for now. TODO(gab): Remove this and the associated code if it |
| 434 // remains disabled long term. | 439 // remains disabled long term. |
| 435 start_menu_properties.set_pin_to_start(false); | 440 start_menu_properties.set_pin_to_start(false); |
| 436 } | 441 } |
| 437 ExecuteAndLogShortcutOperation( | 442 if (!ExecuteAndLogShortcutOperation( |
|
grt (UTC plus 2)
2015/09/22 20:28:53
how does this interact with pins in the start scre
gab
2015/09/28 15:44:51
Taskbar pinning creates a copy of the pinned short
| |
| 438 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist, | 443 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, |
| 439 start_menu_properties, shortcut_operation); | 444 start_menu_properties, shortcut_operation)) { |
|
gab
2015/09/28 15:44:51
If someone runs an over-install (re-install when e
| |
| 445 // We're migrating from shortcuts in a subdirectory to being directly in | |
| 446 // the list of "All Programs" which means the update may fail because it's | |
| 447 // not currently in the location we want it to go. In this case, we have | |
| 448 // to explicitly remove the old one and force-create the new one. | |
| 449 base::FilePath shortcut_path; | |
| 450 ShellUtil::GetShortcutPath( | |
| 451 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist, | |
| 452 shortcut_level, &shortcut_path); | |
| 453 if (shortcut_operation == ShellUtil::SHELL_SHORTCUT_REPLACE_EXISTING && | |
| 454 base::PathExists(shortcut_path)) { | |
| 455 ShellUtil::RemoveShortcuts( | |
| 456 ShellUtil::SHORTCUT_LOCATION_START_MENU_CHROME_DIR, dist, | |
| 457 shortcut_level, start_menu_properties.target); | |
| 458 ExecuteAndLogShortcutOperation( | |
| 459 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, | |
| 460 start_menu_properties, ShellUtil::SHELL_SHORTCUT_CREATE_ALWAYS); | |
| 461 } | |
| 462 } | |
| 440 } | 463 } |
| 441 | 464 |
| 442 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, | 465 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, |
| 443 const installer::Product& product, | 466 const installer::Product& product, |
| 444 bool make_chrome_default) { | 467 bool make_chrome_default) { |
| 445 DCHECK(product.is_chrome()); | 468 DCHECK(product.is_chrome()); |
| 446 | 469 |
| 447 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 470 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| 448 // error checking here because this operation will fail if user doesn't | 471 // error checking here because this operation will fail if user doesn't |
| 449 // have admin rights and we want to ignore the error. | 472 // have admin rights and we want to ignore the error. |
| (...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 683 // Read master_preferences copied beside chrome.exe at install. | 706 // Read master_preferences copied beside chrome.exe at install. |
| 684 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 707 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 685 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 708 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 686 CreateOrUpdateShortcuts( | 709 CreateOrUpdateShortcuts( |
| 687 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 710 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 688 | 711 |
| 689 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 712 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 690 } | 713 } |
| 691 | 714 |
| 692 } // namespace installer | 715 } // namespace installer |
| OLD | NEW |