Skip to content

Commit

Permalink
[Passwords] Record ManagePasswordsReferrer in UMA Histogram
Browse files Browse the repository at this point in the history
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 08d6267)

Bug: 904821
Change-Id: I727b0ace112f407121868d79181f523efecab511
Reviewed-on: https://chromium-review.googlesource.com/c/1355604
Commit-Queue: Jan Wilken Dörrie <jdoerrie@chromium.org>
Reviewed-by: Vasilii Sukhanov <vasilii@chromium.org>
Reviewed-by: Steven Bennetts <stevenjb@chromium.org>
Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org>
Reviewed-by: Ilya Sherman <isherman@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#613150}
Reviewed-on: https://chromium-review.googlesource.com/c/1361706
Reviewed-by: Jan Wilken Dörrie <jdoerrie@chromium.org>
Cr-Commit-Position: refs/branch-heads/3626@{#62}
Cr-Branched-From: d897fb1-refs/heads/master@{#612437}
  • Loading branch information
jdoerrie committed Dec 5, 2018
1 parent b1255a7 commit 8dbb6e3
Show file tree
Hide file tree
Showing 12 changed files with 95 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Polymer({
* @private
*/
onPasswordsClick_: function() {
PasswordManagerImpl.getInstance().recordPasswordsPageAccessInSettings();
loadTimeData.getBoolean('navigateToGooglePasswordManager') ?
settings.OpenWindowProxyImpl.getInstance().openURL(
loadTimeData.getString('googlePasswordManagerUrl')) :
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -162,6 +167,11 @@ class PasswordManagerImpl {
chrome.passwordsPrivate.getSavedPasswordList(callback);
}

/** @override */
recordPasswordsPageAccessInSettings() {
chrome.passwordsPrivate.recordPasswordsPageAccessInSettings();
}

/** @override */
removeSavedPassword(id) {
chrome.passwordsPrivate.removeSavedPassword(id);
Expand Down
7 changes: 5 additions & 2 deletions chrome/browser/ui/passwords/manage_passwords_view_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#include <algorithm>

#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"
Expand Down Expand Up @@ -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";
}
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand Down
4 changes: 4 additions & 0 deletions chrome/common/extensions/api/passwords_private.idl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
//
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions extensions/browser/extension_function_histogram_value.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions third_party/closure_compiler/externs/passwords_private.js
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
12 changes: 12 additions & 0 deletions tools/metrics/histograms/enums.xml
Original file line number Diff line number Diff line change
Expand Up @@ -17377,6 +17377,9 @@ Called by update_net_error_codes.py.-->
<int value="1294" label="CRYPTOTOKENPRIVATE_CANPROXYTOWEBAUTHN"/>
<int value="1295" label="INPUTMETHODPRIVATE_GETSETTING"/>
<int value="1296" label="INPUTMETHODPRIVATE_SETSETTING"/>
<int value="1297" label="FILEMANAGERPRIVATEINTERNAL_UNSHAREPATHWITHCROSTINI"/>
<int value="1298"
label="PASSWORDSPRIVATE_RECORDPASSWORDSPAGEACCESSINSETTINGS"/>
</enum>

<enum name="ExtensionIconState">
Expand Down Expand Up @@ -32226,6 +32229,15 @@ from previous Chrome versions.
</int>
</enum>

<enum name="ManagePasswordsReferrer">
<int value="0" label="Chrome Settings"/>
<int value="1" label="Manage Passwords Bubble"/>
<int value="2" label="Password Context Manu"/>
<int value="3" label="Password Dropdown"/>
<int value="4" label="Password Generation Confirmation"/>
<int value="5" label="Profile Chooser"/>
</enum>

<enum name="ManifestFetchResultType">
<int value="0" label="Fetch succeeded"/>
<int value="1" label="Fetch failed because of empty URL"/>
Expand Down
11 changes: 11 additions & 0 deletions tools/metrics/histograms/histograms.xml
Original file line number Diff line number Diff line change
Expand Up @@ -77632,6 +77632,17 @@ uploading your change for review.
<summary>An error on LoginDatabase initialization.</summary>
</histogram>

<histogram name="PasswordManager.ManagePasswordsReferrer"
enum="ManagePasswordsReferrer">
<owner>jdoerrie@chromium.org</owner>
<owner>vasilii@chromium.org</owner>
<summary>
Referrer of a navigation to the &quot;Manage Passwords&quot; page. Recorded
when the user attempts to see their list of passwords, either via native or
Web UI.
</summary>
</histogram>

<histogram name="PasswordManager.MediationOptional"
enum="CredentialManagerGetResult">
<owner>jdoerrie@chromium.org</owner>
Expand Down

0 comments on commit 8dbb6e3

Please sign in to comment.