Commit c90c14a6 authored by melandory's avatar melandory Committed by Commit bot

[Smart Lock] Smart Lock branding in save password infobar should available...

[Smart Lock] Smart Lock branding in save password infobar should available only for signed in users and guarded by Finch.

Restrict new title for the smart lock infobar only to the signed in users, who belongs to experiment.

BUG=454815

Review URL: https://codereview.chromium.org/1134863002

Cr-Commit-Position: refs/heads/master@{#329387}
parent 8956bcd3
...@@ -6,6 +6,8 @@ ...@@ -6,6 +6,8 @@
#include "base/metrics/histogram.h" #include "base/metrics/histogram.h"
#include "chrome/browser/infobars/infobar_service.h" #include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/passwords/password_bubble_experiment.h"
#include "chrome/grit/chromium_strings.h" #include "chrome/grit/chromium_strings.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/infobars/core/infobar.h" #include "components/infobars/core/infobar.h"
...@@ -37,9 +39,12 @@ void SavePasswordInfoBarDelegate::Create( ...@@ -37,9 +39,12 @@ void SavePasswordInfoBarDelegate::Create(
password_manager::CredentialSourceType source_type) { password_manager::CredentialSourceType source_type) {
InfoBarService* infobar_service = InfoBarService* infobar_service =
InfoBarService::FromWebContents(web_contents); InfoBarService::FromWebContents(web_contents);
Profile* profile =
Profile::FromBrowserContext(web_contents->GetBrowserContext());
SavePasswordInfoBarDelegate* infobar_delegate = SavePasswordInfoBarDelegate* infobar_delegate =
new SavePasswordInfoBarDelegate( new SavePasswordInfoBarDelegate(
form_to_save.Pass(), uma_histogram_suffix, source_type); form_to_save.Pass(), uma_histogram_suffix, source_type,
password_bubble_experiment::IsEnabledSmartLockBranding(profile));
#if defined(OS_ANDROID) #if defined(OS_ANDROID)
// For Android in case of smart lock we need different appearance of infobar. // For Android in case of smart lock we need different appearance of infobar.
scoped_ptr<infobars::InfoBar> infobar = scoped_ptr<infobars::InfoBar> infobar =
...@@ -81,7 +86,8 @@ SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() { ...@@ -81,7 +86,8 @@ SavePasswordInfoBarDelegate::~SavePasswordInfoBarDelegate() {
SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
scoped_ptr<password_manager::PasswordFormManager> form_to_save, scoped_ptr<password_manager::PasswordFormManager> form_to_save,
const std::string& uma_histogram_suffix, const std::string& uma_histogram_suffix,
password_manager::CredentialSourceType source_type) password_manager::CredentialSourceType source_type,
bool is_smartlock_branding_enabled)
: ConfirmInfoBarDelegate(), : ConfirmInfoBarDelegate(),
form_to_save_(form_to_save.Pass()), form_to_save_(form_to_save.Pass()),
infobar_response_(password_manager::metrics_util::NO_RESPONSE), infobar_response_(password_manager::metrics_util::NO_RESPONSE),
...@@ -92,6 +98,11 @@ SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate( ...@@ -92,6 +98,11 @@ SavePasswordInfoBarDelegate::SavePasswordInfoBarDelegate(
"PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_, "PasswordManager.SavePasswordPromptDisplayed_" + uma_histogram_suffix_,
true); true);
} }
int brand_string_id = is_smartlock_branding_enabled
? IDS_PASSWORD_MANAGER_SMART_LOCK
: IDS_SAVE_PASSWORD_TITLE_BRAND;
title_ = l10n_util::GetStringFUTF16(
IDS_SAVE_PASSWORD, l10n_util::GetStringUTF16(brand_string_id));
} }
bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() { bool SavePasswordInfoBarDelegate::ShouldShowMoreButton() {
...@@ -125,13 +136,7 @@ void SavePasswordInfoBarDelegate::InfoBarDismissed() { ...@@ -125,13 +136,7 @@ void SavePasswordInfoBarDelegate::InfoBarDismissed() {
} }
base::string16 SavePasswordInfoBarDelegate::GetMessageText() const { base::string16 SavePasswordInfoBarDelegate::GetMessageText() const {
int brand_string_id = return title_;
(source_type_ ==
password_manager::CredentialSourceType::CREDENTIAL_SOURCE_API)
? IDS_PASSWORD_MANAGER_SMART_LOCK
: IDS_SAVE_PASSWORD_TITLE_BRAND;
return l10n_util::GetStringFUTF16(IDS_SAVE_PASSWORD,
l10n_util::GetStringUTF16(brand_string_id));
} }
base::string16 SavePasswordInfoBarDelegate::GetButtonLabel( base::string16 SavePasswordInfoBarDelegate::GetButtonLabel(
......
...@@ -62,7 +62,8 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { ...@@ -62,7 +62,8 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
SavePasswordInfoBarDelegate( SavePasswordInfoBarDelegate(
scoped_ptr<password_manager::PasswordFormManager> form_to_save, scoped_ptr<password_manager::PasswordFormManager> form_to_save,
const std::string& uma_histogram_suffix, const std::string& uma_histogram_suffix,
password_manager::CredentialSourceType source_type); password_manager::CredentialSourceType source_type,
bool is_smartlock_branding_enabled);
private: private:
// The PasswordFormManager managing the form we're asking the user about, // The PasswordFormManager managing the form we're asking the user about,
...@@ -84,6 +85,10 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate { ...@@ -84,6 +85,10 @@ class SavePasswordInfoBarDelegate : public ConfirmInfoBarDelegate {
// Infobar appearance (title, buttons) depends on value of this parameter. // Infobar appearance (title, buttons) depends on value of this parameter.
password_manager::CredentialSourceType source_type_; password_manager::CredentialSourceType source_type_;
// Title for the infobar: branded as a part of Google Smart Lock for signed
// users.
base::string16 title_;
DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate); DISALLOW_COPY_AND_ASSIGN(SavePasswordInfoBarDelegate);
}; };
......
...@@ -39,7 +39,8 @@ class TestSavePasswordInfobarDelegate : public SavePasswordInfoBarDelegate { ...@@ -39,7 +39,8 @@ class TestSavePasswordInfobarDelegate : public SavePasswordInfoBarDelegate {
password_manager::CredentialSourceType source_type) password_manager::CredentialSourceType source_type)
: SavePasswordInfoBarDelegate(form_to_save.Pass(), : SavePasswordInfoBarDelegate(form_to_save.Pass(),
std::string(), std::string(),
source_type) {} source_type,
true /* is_smartlock_branding_enabled */) {}
~TestSavePasswordInfobarDelegate() override {} ~TestSavePasswordInfobarDelegate() override {}
}; };
......
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