Commit 1ef2bc16 authored by Richard Knoll's avatar Richard Knoll Committed by Commit Bot

Move origin into footnote view of Click to Call bubble.

After Chrome UI implementation review we decided that the origin looks
better in the footer. This CL moves it there. We can also drop the
scheme from the origin as it does not add value here.

Before: https://imgur.com/EdtdTB3
After: https://imgur.com/PSIfHmz

Bug: 1019323
Change-Id: I8c17372fba5ec6e6eed6aa666bd779aa6b31afde
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1887792Reviewed-by: default avatarHimanshu Jaju <himanshujaju@chromium.org>
Commit-Queue: Richard Knoll <knollr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#710716}
parent 63dbf172
......@@ -100,14 +100,16 @@ std::unique_ptr<views::View> CreateOriginView(const SharingDialogData& data) {
DCHECK(data.initiating_origin);
DCHECK_NE(0, data.origin_text_id);
auto label = std::make_unique<views::Label>(
l10n_util::GetStringFUTF16(data.origin_text_id,
l10n_util::GetStringFUTF16(
data.origin_text_id,
url_formatter::FormatOriginForSecurityDisplay(
*data.initiating_origin)),
*data.initiating_origin,
url_formatter::SchemeDisplay::OMIT_HTTP_AND_HTTPS)),
ChromeTextContext::CONTEXT_BODY_TEXT_SMALL,
views::style::STYLE_SECONDARY);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetElideBehavior(gfx::ELIDE_HEAD);
label->SetMultiLine(false);
label->SetAllowCharacterBreak(true);
label->SetMultiLine(true);
return label;
}
......@@ -144,10 +146,26 @@ int SharingDialogView::GetDialogButtons() const {
}
std::unique_ptr<views::View> SharingDialogView::CreateFootnoteView() {
if (GetDialogType() != SharingDialogType::kDialogWithoutDevicesWithApp)
constexpr int kLabelSpacing = 8;
bool show_help_text =
GetDialogType() == SharingDialogType::kDialogWithoutDevicesWithApp;
bool show_origin =
data_.initiating_origin &&
!data_.initiating_origin->IsSameOriginWith(
web_contents()->GetMainFrame()->GetLastCommittedOrigin());
if (!show_help_text && !show_origin)
return nullptr;
return CreateHelpText(data_, this);
auto footnote_view = std::make_unique<views::View>();
footnote_view->SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kVertical, gfx::Insets(), kLabelSpacing));
if (show_help_text)
footnote_view->AddChildView(CreateHelpText(data_, this));
if (show_origin)
footnote_view->AddChildView(CreateOriginView(data_));
return footnote_view;
}
void SharingDialogView::StyledLabelLinkClicked(views::StyledLabel* label,
......@@ -294,21 +312,6 @@ void SharingDialogView::InitListView() {
dialog_button->SetBorder(views::CreateEmptyBorder(app_border));
dialog_buttons_.push_back(AddChildView(std::move(dialog_button)));
}
// Origin:
if (data_.initiating_origin &&
!data_.initiating_origin->IsSameOriginWith(
web_contents()->GetMainFrame()->GetLastCommittedOrigin())) {
auto* provider = ChromeLayoutProvider::Get();
const gfx::Insets dialog_insets =
provider->GetDialogInsetsForContentType(views::TEXT, views::TEXT);
const gfx::Insets origin_border = gfx::Insets(
kSharingDialogSpacing, dialog_insets.left(), 0, dialog_insets.right());
std::unique_ptr<views::View> origin_view = CreateOriginView(data_);
origin_view->SetBorder(views::CreateEmptyBorder(origin_border));
AddChildView(std::move(origin_view));
}
}
void SharingDialogView::InitEmptyView() {
......
......@@ -216,19 +216,22 @@ TEST_F(SharingDialogViewTest, ThemeChangedEmptyList) {
TEST_F(SharingDialogViewTest, OriginView) {
auto dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
auto dialog = CreateDialogView(std::move(dialog_data));
const int children_without_origin = dialog->children().size();
// No footnote by default if there is no initiating origin set.
EXPECT_EQ(nullptr, dialog->CreateFootnoteView());
dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
dialog_data.initiating_origin =
url::Origin::Create(GURL("https://example.com"));
dialog = CreateDialogView(std::move(dialog_data));
const int children_with_origin = dialog->children().size();
EXPECT_EQ(children_without_origin + 1, children_with_origin);
// Origin should be shown in the footnote if the initiating origin does not
// match the main frame origin.
EXPECT_NE(nullptr, dialog->CreateFootnoteView());
dialog_data = CreateDialogData(/*devices=*/1, /*apps=*/1);
dialog_data.initiating_origin =
url::Origin::Create(GURL("https://google.com"));
dialog = CreateDialogView(std::move(dialog_data));
const int children_with_same_origin = dialog->children().size();
EXPECT_EQ(children_without_origin, children_with_same_origin);
// Origin should not be shown in the footnote if the initiating origin does
// match the main frame origin.
EXPECT_EQ(nullptr, dialog->CreateFootnoteView());
}
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