Commit b10a7b7f authored by Ioana Pandele's avatar Ioana Pandele Committed by Commit Bot

Split string in the generation infobar

This change separates the current text of the infobar into title and
body. The latter contains a link pointing to where the
user can find the saved generated password.

Screenshot on the bug.
Bug: 903257

Change-Id: Iadbfb68298b338d990c4be0b0ab3d11007b4b125
Reviewed-on: https://chromium-review.googlesource.com/c/1156586Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Ioana Pandele <ioanap@chromium.org>
Cr-Commit-Position: refs/heads/master@{#609223}
parent 99994b05
...@@ -4,24 +4,34 @@ ...@@ -4,24 +4,34 @@
package org.chromium.chrome.browser.infobar; package org.chromium.chrome.browser.infobar;
import android.text.SpannableString;
import android.text.Spanned;
import org.chromium.ui.text.NoUnderlineClickableSpan;
/** /**
* An infobar to notify that the generated password was saved. * An infobar to notify that the generated password was saved.
*/ */
public class GeneratedPasswordSavedInfoBar extends ConfirmInfoBar { public class GeneratedPasswordSavedInfoBar extends ConfirmInfoBar {
private final int mInlineLinkRangeStart; private final int mInlineLinkRangeStart;
private final int mInlineLinkRangeEnd; private final int mInlineLinkRangeEnd;
private final String mDetailsMessage;
/** /**
* Creates and shows the infobar to notify that the generated password was saved. * Creates and shows the infobar to notify that the generated password was saved.
* @param iconDrawableId Drawable ID corresponding to the icon that the infobar will show. * @param iconDrawableId Drawable ID corresponding to the icon that the infobar will show.
* @param messageText Message to display in the infobar. * @param messageText Message to display in the infobar.
* @param detailsMessageText Message containing additional details to be displayed in the
* infobar.
* @param inlineLinkRangeStart The start of the range of the messageText that should be a link. * @param inlineLinkRangeStart The start of the range of the messageText that should be a link.
* @param inlineLinkRangeEnd The end of the range of the messageText that should be a link. * @param inlineLinkRangeEnd The end of the range of the messageText that should be a link.
* @param buttonLabel String to display on the button. * @param buttonLabel String to display on the button.
*/ */
public GeneratedPasswordSavedInfoBar(int iconDrawableId, String messageText, public GeneratedPasswordSavedInfoBar(int iconDrawableId, String messageText,
int inlineLinkRangeStart, int inlineLinkRangeEnd, String buttonLabel) { String detailsMessageText, int inlineLinkRangeStart, int inlineLinkRangeEnd,
String buttonLabel) {
super(iconDrawableId, null, messageText, null, buttonLabel, null); super(iconDrawableId, null, messageText, null, buttonLabel, null);
mDetailsMessage = detailsMessageText;
mInlineLinkRangeStart = inlineLinkRangeStart; mInlineLinkRangeStart = inlineLinkRangeStart;
mInlineLinkRangeEnd = inlineLinkRangeEnd; mInlineLinkRangeEnd = inlineLinkRangeEnd;
} }
...@@ -34,6 +44,10 @@ public class GeneratedPasswordSavedInfoBar extends ConfirmInfoBar { ...@@ -34,6 +44,10 @@ public class GeneratedPasswordSavedInfoBar extends ConfirmInfoBar {
@Override @Override
public void createContent(InfoBarLayout layout) { public void createContent(InfoBarLayout layout) {
super.createContent(layout); super.createContent(layout);
layout.setInlineMessageLink(mInlineLinkRangeStart, mInlineLinkRangeEnd); InfoBarControlLayout detailsMessageLayout = layout.addControlLayout();
SpannableString detailsMessageWithLink = new SpannableString(mDetailsMessage);
detailsMessageWithLink.setSpan(new NoUnderlineClickableSpan((view) -> onLinkClicked()),
mInlineLinkRangeStart, mInlineLinkRangeEnd, Spanned.SPAN_INCLUSIVE_INCLUSIVE);
detailsMessageLayout.addDescription(detailsMessageWithLink);
} }
} }
...@@ -15,14 +15,17 @@ public class GeneratedPasswordSavedInfoBarDelegate { ...@@ -15,14 +15,17 @@ public class GeneratedPasswordSavedInfoBarDelegate {
* Creates and shows the infobar to notify that the generated password was saved. * Creates and shows the infobar to notify that the generated password was saved.
* @param enumeratedIconId Enum ID corresponding to the icon that the infobar will show. * @param enumeratedIconId Enum ID corresponding to the icon that the infobar will show.
* @param messageText Message to display in the infobar. * @param messageText Message to display in the infobar.
* @param detailsMessageText Message containing additional details to be displayed in the
* infobar.
* @param inlineLinkRangeStart The start of the range of the messageText that should be a link. * @param inlineLinkRangeStart The start of the range of the messageText that should be a link.
* @param inlineLinkRangeEnd The end of the range of the messageText that should be a link. * @param inlineLinkRangeEnd The end of the range of the messageText that should be a link.
* @param buttonLabel String to display on the button. * @param buttonLabel String to display on the button.
*/ */
@CalledByNative @CalledByNative
private static InfoBar show(int enumeratedIconId, String messageText, int inlineLinkRangeStart, private static InfoBar show(int enumeratedIconId, String messageText, String detailsMessageText,
int inlineLinkRangeEnd, String buttonLabel) { int inlineLinkRangeStart, int inlineLinkRangeEnd, String buttonLabel) {
return new GeneratedPasswordSavedInfoBar(ResourceId.mapToDrawableId(enumeratedIconId), return new GeneratedPasswordSavedInfoBar(ResourceId.mapToDrawableId(enumeratedIconId),
messageText, inlineLinkRangeStart, inlineLinkRangeEnd, buttonLabel); messageText, detailsMessageText, inlineLinkRangeStart, inlineLinkRangeEnd,
buttonLabel);
} }
} }
...@@ -32,8 +32,10 @@ GeneratedPasswordSavedInfoBarDelegateAndroid:: ...@@ -32,8 +32,10 @@ GeneratedPasswordSavedInfoBarDelegateAndroid::
base::string16 link = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_LINK); base::string16 link = l10n_util::GetStringUTF16(IDS_MANAGE_PASSWORDS_LINK);
size_t offset = 0; size_t offset = 0;
message_text_ = l10n_util::GetStringFUTF16( message_text_ =
IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT_INFOBAR, link, &offset); l10n_util::GetStringUTF16(IDS_PASSWORD_MANAGER_CONFIRM_SAVED_TITLE);
details_message_text_ = l10n_util::GetStringFUTF16(
IDS_MANAGE_PASSWORDS_CONFIRM_GENERATED_TEXT, link, &offset);
inline_link_range_ = gfx::Range(offset, offset + link.length()); inline_link_range_ = gfx::Range(offset, offset + link.length());
} }
......
...@@ -27,7 +27,12 @@ class GeneratedPasswordSavedInfoBarDelegateAndroid ...@@ -27,7 +27,12 @@ class GeneratedPasswordSavedInfoBarDelegateAndroid
// Returns the translated text of the message to display. // Returns the translated text of the message to display.
const base::string16& message_text() const { return message_text_; } const base::string16& message_text() const { return message_text_; }
// Returns the range of the message text that should be a link. // Returns the translated text of the details message to display. T
const base::string16& details_message_text() const {
return details_message_text_;
}
// Returns the range of the details message text that should be a link.
const gfx::Range& inline_link_range() const { return inline_link_range_; } const gfx::Range& inline_link_range() const { return inline_link_range_; }
// Returns the translated label of the button. // Returns the translated label of the button.
...@@ -46,7 +51,11 @@ class GeneratedPasswordSavedInfoBarDelegateAndroid ...@@ -46,7 +51,11 @@ class GeneratedPasswordSavedInfoBarDelegateAndroid
// The translated text of the message to display. // The translated text of the message to display.
base::string16 message_text_; base::string16 message_text_;
// The range of the message that should be a link. // The translated text of the details message to display. This message
// explains where the generated password is saved.
base::string16 details_message_text_;
// The range of the details message that should be a link.
gfx::Range inline_link_range_; gfx::Range inline_link_range_;
// The translated label of the button. // The translated label of the button.
......
...@@ -38,8 +38,11 @@ GeneratedPasswordSavedInfoBar::CreateRenderInfoBar(JNIEnv* env) { ...@@ -38,8 +38,11 @@ GeneratedPasswordSavedInfoBar::CreateRenderInfoBar(JNIEnv* env) {
static_cast<GeneratedPasswordSavedInfoBarDelegateAndroid*>(delegate()); static_cast<GeneratedPasswordSavedInfoBarDelegateAndroid*>(delegate());
return Java_GeneratedPasswordSavedInfoBarDelegate_show( return Java_GeneratedPasswordSavedInfoBarDelegate_show(
env, GetEnumeratedIconId(), base::android::ConvertUTF16ToJavaString( env, GetEnumeratedIconId(),
env, infobar_delegate->message_text()), base::android::ConvertUTF16ToJavaString(env,
infobar_delegate->message_text()),
base::android::ConvertUTF16ToJavaString(
env, infobar_delegate->details_message_text()),
infobar_delegate->inline_link_range().start(), infobar_delegate->inline_link_range().start(),
infobar_delegate->inline_link_range().end(), infobar_delegate->inline_link_range().end(),
base::android::ConvertUTF16ToJavaString( base::android::ConvertUTF16ToJavaString(
......
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