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

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

Issue 2507753002: Install the chrome event log provider together with the browser. (Closed)
Patch Set: Make the provider registry key track the product branding. Created 4 years 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
« no previous file with comments | « chrome/installer/setup/setup_util.h ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/installer/setup/setup_util.cc
diff --git a/chrome/installer/setup/setup_util.cc b/chrome/installer/setup/setup_util.cc
index 233287bf519375396cf4082baa66791711886c63..31e1dbba2115cf0212d959689aa6b389c508bb59 100644
--- a/chrome/installer/setup/setup_util.cc
+++ b/chrome/installer/setup/setup_util.cc
@@ -11,6 +11,8 @@
#include <algorithm>
#include <iterator>
+#include <limits>
+#include <memory>
#include <set>
#include <string>
@@ -31,11 +33,13 @@
#include "base/version.h"
#include "base/win/registry.h"
#include "base/win/windows_version.h"
+#include "chrome/install_static/install_details.h"
grt (UTC plus 2) 2016/12/13 13:21:52 remove this for now
pastarmovj 2016/12/16 12:44:16 Done.
#include "chrome/installer/setup/installer_state.h"
#include "chrome/installer/setup/setup_constants.h"
#include "chrome/installer/setup/user_hive_visitor.h"
#include "chrome/installer/util/app_registration_data.h"
#include "chrome/installer/util/google_update_constants.h"
+#include "chrome/installer/util/install_util.h"
#include "chrome/installer/util/installation_state.h"
#include "chrome/installer/util/master_preferences.h"
#include "chrome/installer/util/master_preferences_constants.h"
@@ -47,6 +51,12 @@ namespace installer {
namespace {
+// Event log provider registry location and value names.
grt (UTC plus 2) 2016/12/13 13:21:52 nit: value names are not defined here
pastarmovj 2016/12/16 12:44:16 Done.
+// TODO(http://crbug.com/668397): Make this string depend on the branding then
grt (UTC plus 2) 2016/12/13 13:21:52 remove this TODO?
pastarmovj 2016/12/16 12:44:16 Done.
+// as well.
+constexpr wchar_t kEventLogProvidersRegPath[] =
+ L"SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\";
+
// Returns true if product |type| cam be meaningfully installed without the
// --multi-install flag.
bool SupportsSingleInstall(BrowserDistribution::Type type) {
@@ -660,6 +670,59 @@ void RecordUnPackMetrics(UnPackStatus unpack_status,
->Add(status);
}
+void RegisterEventLogProvider(const base::FilePath& install_directory,
+ const base::Version& version) {
+ base::string16 reg_path(kEventLogProvidersRegPath);
+ reg_path.append(install_static::InstallDetails::Get().install_full_name());
grt (UTC plus 2) 2016/12/13 13:21:52 this is ultimately the right thing, but it won't w
pastarmovj 2016/12/16 12:44:16 Done.
+ VLOG(1) << "Registering Chrome's event log provider at "
+ << reg_path;
+
+ std::unique_ptr<WorkItemList> work_item_list(WorkItem::CreateWorkItemList());
+ work_item_list->set_log_message("Register event log provider");
+
+ work_item_list->AddCreateRegKeyWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default);
+ // Speicifes the number of event categories defined in the dll.
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, L"CategoryCount",
+ static_cast<DWORD>(1), true);
+ // Specifies the event type emitted by this event source.
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, L"TypesSupported",
+ static_cast<DWORD>(EVENTLOG_ERROR_TYPE | EVENTLOG_INFORMATION_TYPE |
+ EVENTLOG_WARNING_TYPE),
+ true);
+
+ const base::FilePath provider(
+ install_directory.AppendASCII(version.GetString())
+ .Append(FILE_PATH_LITERAL("eventlog_provider.dll")));
+
+ static constexpr const wchar_t* kFileKeys[] = {
+ L"CategoryMessageFile", L"EventMessageFile", L"ParameterMessageFile",
+ };
+ for (const wchar_t* file_key : kFileKeys) {
+ work_item_list->AddSetRegValueWorkItem(
+ HKEY_LOCAL_MACHINE, reg_path, WorkItem::kWow64Default, file_key,
+ provider.value(), true);
+ }
+
+ // 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_list->Do())
+ work_item_list->Rollback();
+}
+
+void DeRegisterEventLogProvider() {
+ base::string16 reg_path(kEventLogProvidersRegPath);
+ reg_path.append(install_static::InstallDetails::Get().install_full_name());
grt (UTC plus 2) 2016/12/13 13:21:52 same as above. maybe put the ugly logic in a helpe
pastarmovj 2016/12/16 12:44:16 Done.
+
+ // TODO(http://crbug.com/668120): If the Event Viewer is open the provider dll
+ // will fail to get deleted. This doesn't fail the uninstallation altogether
+ // but leaves files behind.
+ InstallUtil::DeleteRegistryKey(HKEY_LOCAL_MACHINE, reg_path,
+ WorkItem::kWow64Default);
+}
+
ScopedTokenPrivilege::ScopedTokenPrivilege(const wchar_t* privilege_name)
: is_enabled_(false) {
HANDLE temp_handle;
« no previous file with comments | « chrome/installer/setup/setup_util.h ('k') | chrome/installer/setup/setup_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698