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

Unified Diff: chrome/installer/setup/install.cc

Issue 2507753002: Install the chrome event log provider together with the browser. (Closed)
Patch Set: . Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: chrome/installer/setup/install.cc
diff --git a/chrome/installer/setup/install.cc b/chrome/installer/setup/install.cc
index 5ab14e2cde784f09ffb94d5659ac082c31c6aff6..fdde737369ff06d807581fe50a58ff137451e939 100644
--- a/chrome/installer/setup/install.cc
+++ b/chrome/installer/setup/install.cc
@@ -142,6 +142,56 @@ void AddChromeToMediaPlayerList() {
LOG(ERROR) << "Could not add Chrome to media player inclusion list.";
}
+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.
+ base::string16 reg_path(installer::kEventlogProvidersRegPath);
+ // registry paths can also be appended like file system path
+ reg_path.push_back(base::FilePath::kSeparators[0]);
+ reg_path.append(installer::kChromeEventLogProviderName);
+ 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.
+ 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
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default));
+
+ // if the operation fails we log the error but still continue because none of
+ // these are critical for the proper operation of the browser.
+ if (!work_item.get()->Do()) {
+ LOG(ERROR) << "Could not register Chrome's event log provider. "
+ << "Failed to create registry key: " << reg_path << ".";
+ return;
+ }
+
+ work_item.reset(WorkItem::CreateSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default,
+ installer::kCategoryCount, static_cast<DWORD>(1), true));
+ if (!work_item.get()->Do()) {
+ LOG(ERROR) << "Could not register Chrome's event log provider. "
+ << "Failed to set registry value: " << installer::kCategoryCount
+ << ".";
+ }
+ work_item.reset(WorkItem::CreateSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default,
+ installer::kTypesSupported, static_cast<DWORD>(7), true));
+ if (!work_item.get()->Do()) {
+ LOG(ERROR) << "Could not register Chrome's event log provider. "
+ << "Failed to set registry value: " << installer::kTypesSupported
+ << ".";
+ }
+
+ 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.
+ installer::kCategoryMessageFile,
+ installer::kEventMessageFile,
+ installer::kParameterMessageFile,
+ };
+ 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.
+ work_item.reset(WorkItem::CreateSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default,
+ file_keys[i], chrome_exe.value(), true));
+ if (!work_item.get()->Do()) {
+ LOG(ERROR) << "Could not register Chrome's event log provider. "
+ << "Failed to set registry value: " << file_keys[i] << ".";
+ }
+ }
+}
+
// Copy master_preferences file provided to installer, in the same folder
// as chrome.exe so Chrome first run can find it. This function will be called
// only on the first install of Chrome.
@@ -443,16 +493,22 @@ void RegisterChromeOnMachine(const installer::InstallerState& installer_state,
bool make_chrome_default) {
DCHECK(product.is_chrome());
+ const base::FilePath chrome_exe(
+ installer_state.target_path().Append(installer::kChromeExe));
+
// Try to add Chrome to Media Player shim inclusion list. We don't do any
// error checking here because this operation will fail if user doesn't
// have admin rights and we want to ignore the error.
AddChromeToMediaPlayerList();
+ // Try to register the event log provider for Chrome, but only if it is a
+ // system profile because this step admin privileges.
+ if (installer_state.system_install())
+ RegisterChromesEventlogProvider(chrome_exe);
+
// Make Chrome the default browser if desired when possible. Otherwise, only
// register it with Windows.
BrowserDistribution* dist = product.distribution();
- const base::FilePath chrome_exe(
- installer_state.target_path().Append(installer::kChromeExe));
VLOG(1) << "Registering Chrome as browser: " << chrome_exe.value();
if (make_chrome_default && ShellUtil::CanMakeChromeDefaultUnattended()) {
int level = ShellUtil::CURRENT_USER;

Powered by Google App Engine
This is Rietveld 408576698