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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 reg_path.append(installer::kChromeExe); | 135 reg_path.append(installer::kChromeExe); |
| 136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; | 136 VLOG(1) << "Adding Chrome to Media player list at " << reg_path; |
| 137 std::unique_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | 137 std::unique_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( |
| 138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); | 138 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); |
| 139 | 139 |
| 140 // if the operation fails we log the error but still continue | 140 // if the operation fails we log the error but still continue |
| 141 if (!work_item.get()->Do()) | 141 if (!work_item.get()->Do()) |
| 142 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; | 142 LOG(ERROR) << "Could not add Chrome to media player inclusion list."; |
| 143 } | 143 } |
| 144 | 144 |
| 145 void RegisterChromesEventlogProvider(const base::FilePath& chrome_exe) { | |
|
grt (UTC plus 2)
2016/11/16 15:04:44
nit: RegisterChromeEventLogProvider or maybe just
grt (UTC plus 2)
2016/11/16 15:04:44
i think it makes sense to move this into setup_uti
pastarmovj
2016/11/17 15:34:42
Done.
pastarmovj
2016/11/17 15:34:43
Done.
| |
| 146 base::string16 reg_path(installer::kEventlogProvidersRegPath); | |
| 147 // registry paths can also be appended like file system path | |
| 148 reg_path.push_back(base::FilePath::kSeparators[0]); | |
| 149 reg_path.append(installer::kChromeEventLogProviderName); | |
| 150 VLOG(1) << "Registering Chrome's event log provider at " << reg_path; | |
|
grt (UTC plus 2)
2016/11/16 15:04:44
nit: remove extra space in log message
pastarmovj
2016/11/17 15:34:42
Done.
| |
| 151 std::unique_ptr<WorkItem> work_item(WorkItem::CreateCreateRegKeyWorkItem( | |
|
grt (UTC plus 2)
2016/11/16 15:04:44
rather than creating and using individual items li
pastarmovj
2016/11/17 15:34:43
Done. You are right that those make sense only as
| |
| 152 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default)); | |
| 153 | |
| 154 // if the operation fails we log the error but still continue because none of | |
| 155 // these are critical for the proper operation of the browser. | |
| 156 if (!work_item.get()->Do()) { | |
| 157 LOG(ERROR) << "Could not register Chrome's event log provider. " | |
| 158 << "Failed to create registry key: " << reg_path << "."; | |
| 159 return; | |
| 160 } | |
| 161 | |
| 162 work_item.reset(WorkItem::CreateSetRegValueWorkItem( | |
| 163 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, | |
| 164 installer::kCategoryCount, static_cast<DWORD>(1), true)); | |
| 165 if (!work_item.get()->Do()) { | |
| 166 LOG(ERROR) << "Could not register Chrome's event log provider. " | |
| 167 << "Failed to set registry value: " << installer::kCategoryCount | |
| 168 << "."; | |
| 169 } | |
| 170 work_item.reset(WorkItem::CreateSetRegValueWorkItem( | |
| 171 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, | |
| 172 installer::kTypesSupported, static_cast<DWORD>(7), true)); | |
| 173 if (!work_item.get()->Do()) { | |
| 174 LOG(ERROR) << "Could not register Chrome's event log provider. " | |
| 175 << "Failed to set registry value: " << installer::kTypesSupported | |
| 176 << "."; | |
| 177 } | |
| 178 | |
| 179 const wchar_t* const file_keys[] = { | |
|
grt (UTC plus 2)
2016/11/16 15:04:44
nit: static constexpr const wchar_t* kFileKeys[] =
pastarmovj
2016/11/17 15:34:43
Done.
| |
| 180 installer::kCategoryMessageFile, | |
| 181 installer::kEventMessageFile, | |
| 182 installer::kParameterMessageFile, | |
| 183 }; | |
| 184 for (int i = 0; i < arraysize(file_keys); ++i) { | |
|
grt (UTC plus 2)
2016/11/16 15:04:44
nit: for (const wchar_t* file_key : file_keys) {
pastarmovj
2016/11/17 15:34:43
Done.
| |
| 185 work_item.reset(WorkItem::CreateSetRegValueWorkItem( | |
| 186 HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, | |
| 187 file_keys[i], chrome_exe.value(), true)); | |
| 188 if (!work_item.get()->Do()) { | |
| 189 LOG(ERROR) << "Could not register Chrome's event log provider. " | |
| 190 << "Failed to set registry value: " << file_keys[i] << "."; | |
| 191 } | |
| 192 } | |
| 193 } | |
| 194 | |
| 145 // Copy master_preferences file provided to installer, in the same folder | 195 // Copy master_preferences file provided to installer, in the same folder |
| 146 // as chrome.exe so Chrome first run can find it. This function will be called | 196 // as chrome.exe so Chrome first run can find it. This function will be called |
| 147 // only on the first install of Chrome. | 197 // only on the first install of Chrome. |
| 148 void CopyPreferenceFileForFirstRun( | 198 void CopyPreferenceFileForFirstRun( |
| 149 const installer::InstallerState& installer_state, | 199 const installer::InstallerState& installer_state, |
| 150 const base::FilePath& prefs_source_path) { | 200 const base::FilePath& prefs_source_path) { |
| 151 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII( | 201 base::FilePath prefs_dest_path(installer_state.target_path().AppendASCII( |
| 152 installer::kDefaultMasterPrefs)); | 202 installer::kDefaultMasterPrefs)); |
| 153 if (!base::CopyFile(prefs_source_path, prefs_dest_path)) { | 203 if (!base::CopyFile(prefs_source_path, prefs_dest_path)) { |
| 154 VLOG(1) << "Failed to copy master preferences from:" | 204 VLOG(1) << "Failed to copy master preferences from:" |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 436 ExecuteAndLogShortcutOperation( | 486 ExecuteAndLogShortcutOperation( |
| 437 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, | 487 ShellUtil::SHORTCUT_LOCATION_START_MENU_ROOT, dist, |
| 438 start_menu_properties, shortcut_operation); | 488 start_menu_properties, shortcut_operation); |
| 439 } | 489 } |
| 440 | 490 |
| 441 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, | 491 void RegisterChromeOnMachine(const installer::InstallerState& installer_state, |
| 442 const installer::Product& product, | 492 const installer::Product& product, |
| 443 bool make_chrome_default) { | 493 bool make_chrome_default) { |
| 444 DCHECK(product.is_chrome()); | 494 DCHECK(product.is_chrome()); |
| 445 | 495 |
| 496 const base::FilePath chrome_exe( | |
| 497 installer_state.target_path().Append(installer::kChromeExe)); | |
| 498 | |
| 446 // Try to add Chrome to Media Player shim inclusion list. We don't do any | 499 // Try to add Chrome to Media Player shim inclusion list. We don't do any |
| 447 // error checking here because this operation will fail if user doesn't | 500 // error checking here because this operation will fail if user doesn't |
| 448 // have admin rights and we want to ignore the error. | 501 // have admin rights and we want to ignore the error. |
| 449 AddChromeToMediaPlayerList(); | 502 AddChromeToMediaPlayerList(); |
| 450 | 503 |
| 504 // Try to register the event log provider for Chrome, but only if it is a | |
| 505 // system profile because this step admin privileges. | |
| 506 if (installer_state.system_install()) | |
| 507 RegisterChromesEventlogProvider(chrome_exe); | |
| 508 | |
| 451 // Make Chrome the default browser if desired when possible. Otherwise, only | 509 // Make Chrome the default browser if desired when possible. Otherwise, only |
| 452 // register it with Windows. | 510 // register it with Windows. |
| 453 BrowserDistribution* dist = product.distribution(); | 511 BrowserDistribution* dist = product.distribution(); |
| 454 const base::FilePath chrome_exe( | |
| 455 installer_state.target_path().Append(installer::kChromeExe)); | |
| 456 VLOG(1) << "Registering Chrome as browser: " << chrome_exe.value(); | 512 VLOG(1) << "Registering Chrome as browser: " << chrome_exe.value(); |
| 457 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) { | 513 if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) { |
| 458 int level = ShellUtil::CURRENT_USER; | 514 int level = ShellUtil::CURRENT_USER; |
| 459 if (installer_state.system_install()) | 515 if (installer_state.system_install()) |
| 460 level = level | ShellUtil::SYSTEM_LEVEL; | 516 level = level | ShellUtil::SYSTEM_LEVEL; |
| 461 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); | 517 ShellUtil::MakeChromeDefault(dist, level, chrome_exe, true); |
| 462 } else { | 518 } else { |
| 463 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, base::string16(), false); | 519 ShellUtil::RegisterChromeBrowser(dist, chrome_exe, base::string16(), false); |
| 464 } | 520 } |
| 465 } | 521 } |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 717 // Read master_preferences copied beside chrome.exe at install. | 773 // Read master_preferences copied beside chrome.exe at install. |
| 718 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); | 774 MasterPreferences prefs(installation_root.AppendASCII(kDefaultMasterPrefs)); |
| 719 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); | 775 base::FilePath chrome_exe(installation_root.Append(kChromeExe)); |
| 720 CreateOrUpdateShortcuts( | 776 CreateOrUpdateShortcuts( |
| 721 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); | 777 chrome_exe, chrome, prefs, CURRENT_USER, install_operation); |
| 722 | 778 |
| 723 UpdateDefaultBrowserBeaconForPath(chrome_exe); | 779 UpdateDefaultBrowserBeaconForPath(chrome_exe); |
| 724 } | 780 } |
| 725 | 781 |
| 726 } // namespace installer | 782 } // namespace installer |
| OLD | NEW |