Commit 376b1551 authored by Tatiana Gornak's avatar Tatiana Gornak Committed by Commit Bot

Record metrics when "Show all saved passwords" is triggered from Context Menu.

BUG=739343, 775825

Change-Id: Ib0f997a0228fcf02b117d769644a31cd4b3352d0
Reviewed-on: https://chromium-review.googlesource.com/725342Reviewed-by: default avatarMaxim Kolosovskiy <kolos@chromium.org>
Reviewed-by: default avatarAvi Drissman <avi@chromium.org>
Commit-Queue: Tatiana Gornak <melandory@chromium.org>
Cr-Commit-Position: refs/heads/master@{#510036}
parent 1d17db84
......@@ -1541,7 +1541,7 @@ void RenderViewContextMenu::AppendPasswordItems() {
IDS_CONTENT_CONTEXT_GENERATEPASSWORD);
add_separator = true;
}
if (password_manager::ShowAllSavedPasswordsContextMenuEnabled()) {
if (password_manager_util::ShowAllSavedPasswordsContextMenuEnabled()) {
menu_model_.AddItemWithStringId(IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS,
IDS_AUTOFILL_SHOW_ALL_SAVED_FALLBACK);
add_separator = true;
......@@ -2029,8 +2029,9 @@ void RenderViewContextMenu::ExecuteCommand(int id, int event_flags) {
break;
case IDC_CONTENT_CONTEXT_SHOWALLSAVEDPASSWORDS:
autofill::ChromeAutofillClient::FromWebContents(source_web_contents_)
->ExecuteCommand(autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
password_manager_util::UserTriggeredShowAllSavedPasswordsFromContextMenu(
autofill::ChromeAutofillClient::FromWebContents(
source_web_contents_));
break;
case IDC_CONTENT_CONTENT_PICTUREINPICTURE:
......
......@@ -453,6 +453,7 @@ void PasswordAutofillManager::DidAcceptSuggestion(const base::string16& value,
password_client_->GetMetricsRecorder().RecordPageLevelUserAction(
UserAction::kShowAllPasswordsWhileNoneAreSuggested);
break;
case metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU:
case metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_NONE:
case metrics_util::SHOW_ALL_SAVED_PASSWORDS_CONTEXT_COUNT:
NOTREACHED();
......
......@@ -257,6 +257,8 @@ enum ShowAllSavedPasswordsContext {
// passwords can be suggested to the user, e.g. because none are saved or
// because of technical issues.
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_MANUAL_FALLBACK,
// The "Show all saved passwords..." fallback is shown in context menu.
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU,
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_COUNT
};
......
......@@ -7,8 +7,11 @@
#include <algorithm>
#include "base/stl_util.h"
#include "components/autofill/core/browser/autofill_client.h"
#include "components/autofill/core/browser/popup_item_ids.h"
#include "components/autofill/core/common/password_form.h"
#include "components/password_manager/core/browser/log_manager.h"
#include "components/password_manager/core/browser/password_manager_metrics_util.h"
#include "components/password_manager/core/common/password_manager_features.h"
#include "components/sync/driver/sync_service.h"
#include "crypto/openssl_util.h"
......@@ -126,4 +129,25 @@ bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service) {
password_manager::SYNCING_NORMAL_ENCRYPTION));
}
bool ShowAllSavedPasswordsContextMenuEnabled() {
if (!base::FeatureList::IsEnabled(
password_manager::features::
kEnableShowAllSavedPasswordsContextMenu)) {
return false;
}
LogContextOfShowAllSavedPasswordsShown(
password_manager::metrics_util::
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU);
return true;
}
void UserTriggeredShowAllSavedPasswordsFromContextMenu(
autofill::AutofillClient* autofill_client) {
autofill_client->ExecuteCommand(
autofill::POPUP_ITEM_ID_ALL_SAVED_PASSWORDS_ENTRY);
password_manager::metrics_util::LogContextOfShowAllSavedPasswordsAccepted(
password_manager::metrics_util::
SHOW_ALL_SAVED_PASSWORDS_CONTEXT_CONTEXT_MENU);
}
} // namespace password_manager_util
......@@ -14,6 +14,7 @@
namespace autofill {
struct PasswordForm;
class AutofillClient;
}
namespace syncer {
......@@ -58,6 +59,15 @@ uint64_t CalculateSyncPasswordHash(const base::StringPiece16& text,
// without custom passphrase.
bool ManualPasswordGenerationEnabled(syncer::SyncService* sync_service);
// Returns true iff the "Show all saved passwords" option should be shown in
// Context Menu. Also records metric, that the Context Menu will have "Show all
// saved passwords" option.
bool ShowAllSavedPasswordsContextMenuEnabled();
// Opens Password Manager setting page and records the metrics.
void UserTriggeredShowAllSavedPasswordsFromContextMenu(
autofill::AutofillClient* autofill_client);
} // namespace password_manager_util
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_PASSWORD_MANAGER_UTIL_H_
......@@ -13,9 +13,4 @@ bool ForceSavingExperimentEnabled() {
password_manager::features::kEnablePasswordForceSaving);
}
bool ShowAllSavedPasswordsContextMenuEnabled() {
return base::FeatureList::IsEnabled(
password_manager::features::kEnableShowAllSavedPasswordsContextMenu);
}
} // namespace password_manager
......@@ -10,10 +10,6 @@ namespace password_manager {
// True iff the force-saving of passwords is enabled.
bool ForceSavingExperimentEnabled();
// True iff the "Show all saved passwords" option should be shown in Context
// Menu.
bool ShowAllSavedPasswordsContextMenuEnabled();
} // namespace password_manager
#endif // COMPONENTS_PASSWORD_MANAGER_CORE_COMMON_EXPERIMENTS_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment