From 8dbb6e338f5fad52e1006634bd3d2fe56ac7dadc Mon Sep 17 00:00:00 2001 From: jdoerrie Date: Wed, 5 Dec 2018 01:27:30 +0000 Subject: [PATCH] [Passwords] Record ManagePasswordsReferrer in UMA Histogram MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This change adds a new UMA Histogram that logs the referrer of a navigation to the manage passwords page. Logging is added in both native and Web UI. TBR=jdoerrie@chromium.org (cherry picked from commit 08d626700f4a934db2c54486300485d7da263be5) Bug: 904821 Change-Id: I727b0ace112f407121868d79181f523efecab511 Reviewed-on: https://chromium-review.googlesource.com/c/1355604 Commit-Queue: Jan Wilken Dörrie Reviewed-by: Vasilii Sukhanov Reviewed-by: Steven Bennetts Reviewed-by: Demetrios Papadopoulos Reviewed-by: Ilya Sherman Cr-Original-Commit-Position: refs/heads/master@{#613150} Reviewed-on: https://chromium-review.googlesource.com/c/1361706 Reviewed-by: Jan Wilken Dörrie Cr-Commit-Position: refs/branch-heads/3626@{#62} Cr-Branched-From: d897fb137fbaaa9355c0c93124cc048824eb1e65-refs/heads/master@{#612437} --- .../passwords_private_api.cc | 16 ++++++++++++++++ .../passwords_private/passwords_private_api.h | 19 +++++++++++++++++++ .../settings/autofill_page/autofill_page.js | 1 + .../autofill_page/password_manager_proxy.js | 10 ++++++++++ .../passwords/manage_passwords_view_utils.cc | 7 +++++-- .../password_save_confirmation_view.cc | 3 ++- .../extensions/api/passwords_private.idl | 4 ++++ .../core/browser/manage_passwords_referrer.h | 13 +++++++------ .../extension_function_histogram_value.h | 2 ++ .../externs/passwords_private.js | 6 ++++++ tools/metrics/histograms/enums.xml | 12 ++++++++++++ tools/metrics/histograms/histograms.xml | 11 +++++++++++ 12 files changed, 95 insertions(+), 9 deletions(-) diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc index a490e27cfeef..bbed53266375 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.cc @@ -9,15 +9,31 @@ #include "base/bind.h" #include "base/bind_helpers.h" #include "base/location.h" +#include "base/metrics/histogram_macros.h" #include "base/threading/thread_task_runner_handle.h" #include "base/values.h" #include "chrome/browser/extensions/api/passwords_private/passwords_private_delegate_factory.h" #include "chrome/common/extensions/api/passwords_private.h" +#include "components/password_manager/core/browser/manage_passwords_referrer.h" #include "content/public/browser/web_contents.h" #include "extensions/browser/extension_function_registry.h" namespace extensions { +//////////////////////////////////////////////////////////////////////////////// +// PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction + +PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction:: + ~PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction() {} + +ExtensionFunction::ResponseAction +PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction::Run() { + UMA_HISTOGRAM_ENUMERATION( + "PasswordManager.ManagePasswordsReferrer", + password_manager::ManagePasswordsReferrer::kChromeSettings); + return RespondNow(NoArguments()); +} + //////////////////////////////////////////////////////////////////////////////// // PasswordsPrivateRemoveSavedPasswordFunction diff --git a/chrome/browser/extensions/api/passwords_private/passwords_private_api.h b/chrome/browser/extensions/api/passwords_private/passwords_private_api.h index f541487c4f45..120a9967e7e2 100644 --- a/chrome/browser/extensions/api/passwords_private/passwords_private_api.h +++ b/chrome/browser/extensions/api/passwords_private/passwords_private_api.h @@ -14,6 +14,25 @@ namespace extensions { +class PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction + : public UIThreadExtensionFunction { + public: + PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction() {} + DECLARE_EXTENSION_FUNCTION( + "passwordsPrivate.recordPasswordsPageAccessInSettings", + PASSWORDSPRIVATE_RECORDPASSWORDSPAGEACCESSINSETTINGS); + + protected: + ~PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction() override; + + // ExtensionFunction overrides. + ResponseAction Run() override; + + private: + DISALLOW_COPY_AND_ASSIGN( + PasswordsPrivateRecordPasswordsPageAccessInSettingsFunction); +}; + class PasswordsPrivateRemoveSavedPasswordFunction : public UIThreadExtensionFunction { public: diff --git a/chrome/browser/resources/settings/autofill_page/autofill_page.js b/chrome/browser/resources/settings/autofill_page/autofill_page.js index 8777ecac8add..4e9c34370818 100644 --- a/chrome/browser/resources/settings/autofill_page/autofill_page.js +++ b/chrome/browser/resources/settings/autofill_page/autofill_page.js @@ -59,6 +59,7 @@ Polymer({ * @private */ onPasswordsClick_: function() { + PasswordManagerImpl.getInstance().recordPasswordsPageAccessInSettings(); loadTimeData.getBoolean('navigateToGooglePasswordManager') ? settings.OpenWindowProxyImpl.getInstance().openURL( loadTimeData.getString('googlePasswordManagerUrl')) : diff --git a/chrome/browser/resources/settings/autofill_page/password_manager_proxy.js b/chrome/browser/resources/settings/autofill_page/password_manager_proxy.js index 6b108a23968e..7c18929be5ee 100644 --- a/chrome/browser/resources/settings/autofill_page/password_manager_proxy.js +++ b/chrome/browser/resources/settings/autofill_page/password_manager_proxy.js @@ -33,6 +33,11 @@ class PasswordManagerProxy { */ getSavedPasswordList(callback) {} + /** + * Log that the Passwords page was accessed from the Chrome Settings WebUI. + */ + recordPasswordsPageAccessInSettings() {} + /** * Should remove the saved password and notify that the list has changed. * @param {number} id The id for the password entry being removed. @@ -162,6 +167,11 @@ class PasswordManagerImpl { chrome.passwordsPrivate.getSavedPasswordList(callback); } + /** @override */ + recordPasswordsPageAccessInSettings() { + chrome.passwordsPrivate.recordPasswordsPageAccessInSettings(); + } + /** @override */ removeSavedPassword(id) { chrome.passwordsPrivate.removeSavedPassword(id); diff --git a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc index 9ebd1d333677..0a600f3da316 100644 --- a/chrome/browser/ui/passwords/manage_passwords_view_utils.cc +++ b/chrome/browser/ui/passwords/manage_passwords_view_utils.cc @@ -9,6 +9,7 @@ #include #include "base/feature_list.h" +#include "base/metrics/histogram_macros.h" #include "base/strings/utf_string_conversions.h" #include "build/build_config.h" #include "chrome/browser/profiles/profile.h" @@ -177,8 +178,8 @@ GURL GetGooglePasswordManagerURL(ManagePasswordsReferrer referrer) { return "password_context_menu"; case ManagePasswordsReferrer::kPasswordDropdown: return "password_dropdown"; - case ManagePasswordsReferrer::kPasswordSaveConfirmation: - return "password_save_confirmation"; + case ManagePasswordsReferrer::kPasswordGenerationConfirmation: + return "password_generation_confirmation"; case ManagePasswordsReferrer::kProfileChooser: return "profile_chooser"; } @@ -210,6 +211,8 @@ void NavigateToGooglePasswordManager(Profile* profile, void NavigateToManagePasswordsPage(Browser* browser, ManagePasswordsReferrer referrer) { + UMA_HISTOGRAM_ENUMERATION("PasswordManager.ManagePasswordsReferrer", + referrer); if (ShouldManagePasswordsinGooglePasswordManager(browser->profile())) { NavigateToGooglePasswordManager(browser->profile(), referrer); } else { diff --git a/chrome/browser/ui/views/passwords/password_save_confirmation_view.cc b/chrome/browser/ui/views/passwords/password_save_confirmation_view.cc index d35bcd34a42a..e319957d538c 100644 --- a/chrome/browser/ui/views/passwords/password_save_confirmation_view.cc +++ b/chrome/browser/ui/views/passwords/password_save_confirmation_view.cc @@ -48,7 +48,8 @@ void PasswordSaveConfirmationView::StyledLabelLinkClicked( int event_flags) { DCHECK_EQ(range, model()->save_confirmation_link_range()); model()->OnNavigateToPasswordManagerAccountDashboardLinkClicked( - password_manager::ManagePasswordsReferrer::kPasswordSaveConfirmation); + password_manager::ManagePasswordsReferrer:: + kPasswordGenerationConfirmation); CloseBubble(); } diff --git a/chrome/common/extensions/api/passwords_private.idl b/chrome/common/extensions/api/passwords_private.idl index a8e1085e53c1..716d95a658f0 100644 --- a/chrome/common/extensions/api/passwords_private.idl +++ b/chrome/common/extensions/api/passwords_private.idl @@ -84,6 +84,10 @@ namespace passwordsPrivate { callback EmptyCallback = void(); interface Functions { + // Function that logs that the Passwords page was accessed from the Chrome + // Settings WebUI. + static void recordPasswordsPageAccessInSettings(); + // Removes the saved password corresponding to |loginPair|. If no saved // password for this pair exists, this function is a no-op. // diff --git a/components/password_manager/core/browser/manage_passwords_referrer.h b/components/password_manager/core/browser/manage_passwords_referrer.h index c4fbad503189..7ab3edfc9066 100644 --- a/components/password_manager/core/browser/manage_passwords_referrer.h +++ b/components/password_manager/core/browser/manage_passwords_referrer.h @@ -11,20 +11,21 @@ namespace password_manager { // page. enum class ManagePasswordsReferrer { // Corresponds to Chrome's settings page. - kChromeSettings, + kChromeSettings = 0, // Corresponds to the manage passwords bubble when clicking the key icon. - kManagePasswordsBubble, + kManagePasswordsBubble = 1, // Corresponds to the context menu following a right click into a password // field. - kPasswordContextMenu, + kPasswordContextMenu = 2, // Corresponds to the password dropdown shown when clicking into a password // field. - kPasswordDropdown, + kPasswordDropdown = 3, // Corresponds to the bubble shown when clicking the key icon after a password // was generated. - kPasswordSaveConfirmation, + kPasswordGenerationConfirmation = 4, // Corresponds to the profile chooser next to the omnibar ("Autofill Home"). - kProfileChooser, + kProfileChooser = 5, + kMaxValue = kProfileChooser, }; } // namespace password_manager diff --git a/extensions/browser/extension_function_histogram_value.h b/extensions/browser/extension_function_histogram_value.h index d6caba79d0c4..541dace81d2c 100644 --- a/extensions/browser/extension_function_histogram_value.h +++ b/extensions/browser/extension_function_histogram_value.h @@ -1357,6 +1357,8 @@ enum HistogramValue { CRYPTOTOKENPRIVATE_CANPROXYTOWEBAUTHN = 1294, INPUTMETHODPRIVATE_GETSETTING = 1295, INPUTMETHODPRIVATE_SETSETTING = 1296, + FILEMANAGERPRIVATEINTERNAL_UNSHAREPATHWITHCROSTINI = 1297, + PASSWORDSPRIVATE_RECORDPASSWORDSPAGEACCESSINSETTINGS = 1298, // Last entry: Add new entries above, then run: // python tools/metrics/histograms/update_extension_histograms.py ENUM_BOUNDARY diff --git a/third_party/closure_compiler/externs/passwords_private.js b/third_party/closure_compiler/externs/passwords_private.js index bbbbb003ba12..72059978de25 100644 --- a/third_party/closure_compiler/externs/passwords_private.js +++ b/third_party/closure_compiler/externs/passwords_private.js @@ -78,6 +78,12 @@ chrome.passwordsPrivate.ExceptionEntry; */ chrome.passwordsPrivate.PasswordExportProgress; +/** + * Function that logs that the Passwords page was accessed from the Chrome + * Settings WebUI. + */ +chrome.passwordsPrivate.recordPasswordsPageAccessInSettings = function() {}; + /** * Removes the saved password corresponding to |loginPair|. If no saved password * for this pair exists, this function is a no-op. diff --git a/tools/metrics/histograms/enums.xml b/tools/metrics/histograms/enums.xml index 1abd8f248b13..1a4a1ede3dfd 100644 --- a/tools/metrics/histograms/enums.xml +++ b/tools/metrics/histograms/enums.xml @@ -17377,6 +17377,9 @@ Called by update_net_error_codes.py.--> + + @@ -32226,6 +32229,15 @@ from previous Chrome versions. + + + + + + + + + diff --git a/tools/metrics/histograms/histograms.xml b/tools/metrics/histograms/histograms.xml index 2c6a1a178aed..e14bd990aea6 100644 --- a/tools/metrics/histograms/histograms.xml +++ b/tools/metrics/histograms/histograms.xml @@ -77632,6 +77632,17 @@ uploading your change for review. An error on LoginDatabase initialization. + + jdoerrie@chromium.org + vasilii@chromium.org + + Referrer of a navigation to the "Manage Passwords" page. Recorded + when the user attempts to see their list of passwords, either via native or + Web UI. + + + jdoerrie@chromium.org