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

Unified Diff: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc

Issue 777423004: Skeleton code for experiment setup, which will determine should "Allow to collect URL?" bubble be s… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years 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
Index: chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
diff --git a/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc b/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
index d904e23fe206c64acaa22733c9e444c9fee23f93..9add8fc77da59a714752e7768759cd7058157773 100644
--- a/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
+++ b/chrome/browser/ui/passwords/manage_passwords_bubble_model.cc
@@ -9,6 +9,7 @@
#include "chrome/browser/ui/browser_finder.h"
#include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
#include "chrome/browser/ui/passwords/password_bubble_experiment.h"
+#include "chrome/browser/ui/passwords/password_manager_url_collection_experiment.h"
#include "chrome/grit/generated_resources.h"
#include "components/password_manager/core/browser/password_store.h"
#include "components/password_manager/core/common/password_manager_ui.h"
@@ -34,12 +35,15 @@ int GetFieldWidth(FieldType type) {
: kPasswordFieldSize);
}
+Profile* GetProfileFromWebContents(content::WebContents* web_contents) {
+ if (!web_contents)
+ return nullptr;
+ return Profile::FromBrowserContext(web_contents->GetBrowserContext());
+}
+
void RecordExperimentStatistics(content::WebContents* web_contents,
metrics_util::UIDismissalReason reason) {
- if (!web_contents)
- return;
- Profile* profile =
- Profile::FromBrowserContext(web_contents->GetBrowserContext());
+ Profile* profile = GetProfileFromWebContents(web_contents);
password_bubble_experiment::RecordBubbleClosed(profile->GetPrefs(), reason);
}
@@ -50,6 +54,13 @@ base::string16 PendingStateTitleBasedOnSavePasswordPref(
: IDS_SAVE_PASSWORD);
}
+void RecordURLSCollectionExperimentStatistics(
+ content::WebContents* web_contents) {
+ Profile* profile = GetProfileFromWebContents(web_contents);
+ password_manager::urls_collection_experiment::RecordBubbleClosed(
+ profile->GetPrefs());
+}
+
} // namespace
ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
@@ -80,6 +91,7 @@ ManagePasswordsBubbleModel::ManagePasswordsBubbleModel(
} else if (password_manager::ui::IsCredentialsState(state_)) {
title_ = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_CHOOSE_TITLE);
} else if (password_manager::ui::IsAskSubmitURLState(state_)) {
+ RecordURLSCollectionExperimentStatistics(web_contents);
title_ =
l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_ASK_TO_SUBMIT_URL_TITLE);
} else {
@@ -161,6 +173,9 @@ void ManagePasswordsBubbleModel::OnCollectURLClicked() {
// User interaction with bubble has happened, do not need to show bubble
// in case it was before transition to another page.
state_ = password_manager::ui::ASK_USER_REPORT_URL_BUBBLE_SHOWN_STATE;
+ ManagePasswordsUIController* manage_passwords_ui_controller =
+ ManagePasswordsUIController::FromWebContents(web_contents());
+ manage_passwords_ui_controller->SendURLFeedback();
}
void ManagePasswordsBubbleModel::OnDoNotCollectURLClicked() {

Powered by Google App Engine
This is Rietveld 408576698