Chromium Code Reviews| 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..bec746e1719133859b9ade612f2fc1589bbbb199 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/chromium_strings.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,47 @@ class OpenSystemSettingsHelper { |
| OpenSystemSettingsHelper* OpenSystemSettingsHelper::instance_ = nullptr; |
| +// 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 is_pinned_to_taskbar) { |
| + // Clean up the utility process. |
| + delete client; |
| + |
| + UMA_HISTOGRAM_BOOLEAN("Windows.IsPinnedToTaskbar", is_pinned_to_taskbar); |
| +} |
| + |
| +// 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; |
| + |
| + UMA_HISTOGRAM_COUNTS("Windows.ShellHandlerProcessError", 1); |
|
grt (UTC plus 2)
2016/06/22 13:58:50
is it always the case that Chrome will either reco
Patrick Monette
2016/06/23 22:58:52
I can easily imagine that we'll add an histogram w
|
| +} |
| + |
| +void RecordIsPinnedToTaskbarHistogramOnIOThread() { |
| + DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| + |
| + // The code to check if Chrome is pinned to the taskbar is crashy so it is |
| + // executed on a utility process. |
|
grt (UTC plus 2)
2016/06/22 13:58:50
nit: on -> in
Patrick Monette
2016/06/23 22:58:52
Done.
|
| + 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)); |
| +} |
| + |
| } // namespace |
| bool SetAsDefaultBrowser() { |
| @@ -659,6 +704,12 @@ void MigrateTaskbarPins() { |
| base::TimeDelta::FromSeconds(kMigrateTaskbarPinsDelaySeconds)); |
| } |
| +void RecordIsPinnedToTaskbarHistogram() { |
| + content::BrowserThread::PostTask( |
| + content::BrowserThread::IO, FROM_HERE, |
| + base::Bind(&RecordIsPinnedToTaskbarHistogramOnIOThread)); |
| +} |
| + |
| int MigrateShortcutsInPathInternal(const base::FilePath& chrome_exe, |
| const base::FilePath& path) { |
| DCHECK(base::win::GetVersion() >= base::win::VERSION_WIN7); |