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

Unified Diff: chrome/browser/conflicts/third_party_metrics_recorder_win.cc

Issue 2854983002: Add the ThirdPartyModules.Uninstallable histogram. (Closed)
Patch Set: Rebase Created 3 years, 7 months 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/browser/conflicts/third_party_metrics_recorder_win.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/conflicts/third_party_metrics_recorder_win.cc
diff --git a/chrome/browser/conflicts/third_party_metrics_recorder_win.cc b/chrome/browser/conflicts/third_party_metrics_recorder_win.cc
new file mode 100644
index 0000000000000000000000000000000000000000..aad8300af245200dd094e549582b3d0cca9431a8
--- /dev/null
+++ b/chrome/browser/conflicts/third_party_metrics_recorder_win.cc
@@ -0,0 +1,61 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/conflicts/third_party_metrics_recorder_win.h"
+
+#include <vector>
+
+#include "base/bind.h"
+#include "base/metrics/histogram_macros.h"
+#include "base/strings/string16.h"
+#include "base/strings/string_util.h"
+#include "chrome/browser/conflicts/module_database_win.h"
+#include "chrome/browser/conflicts/module_info_win.h"
+
+ThirdPartyMetricsRecorder::ThirdPartyMetricsRecorder(
+ ModuleDatabase* module_database) {
+ // base::Unretained() is safe here because ThirdPartyMetricsRecorder owns
+ // |installed_programs_| and the callback won't be invoked if this instance is
+ // destroyed.
+ installed_programs_.Initialize(
+ base::Bind(&ThirdPartyMetricsRecorder::OnInstalledProgramsInitialized,
+ base::Unretained(this), module_database));
+}
+
+ThirdPartyMetricsRecorder::~ThirdPartyMetricsRecorder() = default;
+
+void ThirdPartyMetricsRecorder::OnNewModuleFound(
+ const ModuleInfoKey& module_key,
+ const ModuleInfoData& module_data) {
+ if (!IsThirdPartyModule(module_data))
+ return;
+
+ std::vector<base::string16> program_names;
+ bool uninstallable = installed_programs_.GetInstalledProgramNames(
+ module_key.module_path, &program_names);
+ UMA_HISTOGRAM_BOOLEAN("ThirdPartyModules.Uninstallable", uninstallable);
+}
+
+bool ThirdPartyMetricsRecorder::IsThirdPartyModule(
+ const ModuleInfoData& module_data) {
+ static const wchar_t kMicrosoft[] = L"Microsoft ";
+ static const wchar_t kGoogle[] = L"Google Inc";
+
+ const base::string16& certificate_subject =
+ module_data.inspection_result->certificate_info.subject;
+
+ // Check if the signer name begins with "Microsoft ". Signatures are
+ // typically "Microsoft Corporation" or "Microsoft Windows", but others
+ // may exist.
+ if (base::StartsWith(certificate_subject, kMicrosoft,
+ base::CompareCase::SENSITIVE))
+ return false;
+
+ return certificate_subject != kGoogle;
+}
+
+void ThirdPartyMetricsRecorder::OnInstalledProgramsInitialized(
+ ModuleDatabase* module_database) {
+ module_database->AddObserver(this);
+}
« no previous file with comments | « chrome/browser/conflicts/third_party_metrics_recorder_win.h ('k') | tools/metrics/histograms/enums.xml » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698