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

Unified Diff: chrome/browser/shell_integration_win.cc

Issue 2079233004: Add the Windows.IsPinnedToTaskbar metric. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Constexpr TimeDelta Created 4 years, 5 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/shell_integration_win.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/shell_integration_win.cc
diff --git a/chrome/browser/shell_integration_win.cc b/chrome/browser/shell_integration_win.cc
index 87954bbf20853122cf2dbe7c68a0ef83659fe98c..b2bcf2997b54e28cff61ef8a37fd84f39a9699c8 100644
--- a/chrome/browser/shell_integration_win.cc
+++ b/chrome/browser/shell_integration_win.cc
@@ -43,6 +43,8 @@
#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths_internal.h"
#include "chrome/common/chrome_switches.h"
+#include "chrome/common/shell_handler_win.mojom.h"
+#include "chrome/grit/generated_resources.h"
#include "chrome/installer/setup/setup_util.h"
#include "chrome/installer/util/browser_distribution.h"
#include "chrome/installer/util/create_reg_key_work_item.h"
@@ -55,6 +57,8 @@
#include "chrome/installer/util/work_item_list.h"
#include "components/variations/variations_associated_data.h"
#include "content/public/browser/browser_thread.h"
+#include "content/public/browser/utility_process_mojo_client.h"
+#include "ui/base/l10n/l10n_util.h"
using content::BrowserThread;
@@ -421,6 +425,41 @@ class OpenSystemSettingsHelper {
OpenSystemSettingsHelper* OpenSystemSettingsHelper::instance_ = nullptr;
+void RecordPinnedToTaskbarProcessError(bool error) {
+ UMA_HISTOGRAM_BOOLEAN("Windows.IsPinnedToTaskbar.ProcessError", error);
+}
+
+// Record the UMA histogram when a response is received. The callback that binds
+// to this function holds a reference to the ShellHandlerClient to keep it alive
+// until invokation.
+void OnIsPinnedToTaskbarResult(
+ content::UtilityProcessMojoClient<mojom::ShellHandler>* client,
+ bool succeeded,
+ bool is_pinned_to_taskbar) {
+ // Clean up the utility process.
+ delete client;
+
+ RecordPinnedToTaskbarProcessError(false);
+
+ enum Result { NOT_PINNED, PINNED, FAILURE, NUM_RESULTS };
+
+ Result result = FAILURE;
+ if (succeeded)
+ result = is_pinned_to_taskbar ? PINNED : NOT_PINNED;
+ UMA_HISTOGRAM_ENUMERATION("Windows.IsPinnedToTaskbar", result, NUM_RESULTS);
+}
+
+// Called when a connection error happen with the shell handler process. A call
+// to this function is mutially exclusive with a call to
+// OnIsPinnedToTaskbarResult().
+void OnShellHandlerConnectionError(
+ content::UtilityProcessMojoClient<mojom::ShellHandler>* client) {
+ // Clean up the utility process.
+ delete client;
+
+ RecordPinnedToTaskbarProcessError(true);
+}
+
} // namespace
bool SetAsDefaultBrowser() {
@@ -659,6 +698,25 @@ void MigrateTaskbarPins() {
base::TimeDelta::FromSeconds(kMigrateTaskbarPinsDelaySeconds));
}
+void RecordIsPinnedToTaskbarHistogram() {
+ DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
+
+ // The code to check if Chrome is pinned to the taskbar brings in shell
+ // extensions which can hinder stability so it is executed in a utility
+ // process.
+ content::UtilityProcessMojoClient<mojom::ShellHandler>* client =
+ new content::UtilityProcessMojoClient<mojom::ShellHandler>(
+ l10n_util::GetStringUTF16(IDS_UTILITY_PROCESS_SHELL_HANDLER_NAME));
+
+ client->set_error_callback(
+ base::Bind(&OnShellHandlerConnectionError, client));
+ client->set_disable_sandbox();
+ client->Start();
+
+ client->service()->IsPinnedToTaskbar(
+ base::Bind(&OnIsPinnedToTaskbarResult, client));
+}
+
int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe,
const base::FilePath& path) {
DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7);
« no previous file with comments | « chrome/browser/shell_integration_win.h ('k') | chrome/chrome_common.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698