Commit 3d981f46 authored by Rouslan Solomakhin's avatar Rouslan Solomakhin Committed by Commit Bot

[Payment Handler][Desktop] De-jank title

Before this patch, Chrome momentarily showed the URL of the payment
handler page before showing its title when initially loading the page.
This information is redundant because of the payment handler origin
displayed underneath its title.

This patch hides the title whenever the page title starts with
"https://", which covers the use cases that we care about.

After this patch, Chrome momentarily shows no title for the payment
handler page before showing it when initially loading the page. The
origin display underneath the title is not affected by this patch.

Bug: 926297
Change-Id: I6fb26fed3d1968fd27493f4f39625b47b55baccb
Reviewed-on: https://chromium-review.googlesource.com/c/1446870Reviewed-by: default avatarDanyao Wang <danyao@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#627946}
parent ca5f959e
......@@ -34,8 +34,22 @@
#include "ui/views/controls/webview/webview.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/grid_layout.h"
#include "url/url_constants.h"
namespace payments {
namespace {
base::string16 GetPaymentHandlerDialogTitle(
content::WebContents* web_contents,
const base::string16& https_prefix) {
return web_contents == nullptr ||
base::StartsWith(web_contents->GetTitle(), https_prefix,
base::CompareCase::SENSITIVE)
? base::string16()
: web_contents->GetTitle();
}
} // namespace
class ReadOnlyOriginView : public views::View {
public:
......@@ -144,7 +158,9 @@ PaymentHandlerWebFlowViewController::PaymentHandlerWebFlowViewController(
std::make_unique<views::ProgressBar>(/*preferred_height=*/2)),
separator_(std::make_unique<views::Separator>()),
first_navigation_complete_callback_(
std::move(first_navigation_complete_callback)) {
std::move(first_navigation_complete_callback)),
https_prefix_(base::UTF8ToUTF16(url::kHttpsScheme) +
base::UTF8ToUTF16(url::kStandardSchemeSeparator)) {
progress_bar_->set_owned_by_client();
progress_bar_->set_foreground_color(gfx::kGoogleBlue500);
progress_bar_->set_background_color(SK_ColorTRANSPARENT);
......@@ -156,10 +172,7 @@ PaymentHandlerWebFlowViewController::PaymentHandlerWebFlowViewController(
PaymentHandlerWebFlowViewController::~PaymentHandlerWebFlowViewController() {}
base::string16 PaymentHandlerWebFlowViewController::GetSheetTitle() {
if (web_contents())
return web_contents()->GetTitle();
return l10n_util::GetStringUTF16(IDS_TAB_LOADING_TITLE);
return GetPaymentHandlerDialogTitle(web_contents(), https_prefix_);
}
void PaymentHandlerWebFlowViewController::FillContentView(
......@@ -191,8 +204,8 @@ PaymentHandlerWebFlowViewController::CreateHeaderContentView() {
: target_.GetOrigin();
std::unique_ptr<views::Background> background = GetHeaderBackground();
return std::make_unique<ReadOnlyOriginView>(
web_contents() == nullptr ? base::string16() : web_contents()->GetTitle(),
origin, state()->selected_instrument()->icon_image_skia(),
GetPaymentHandlerDialogTitle(web_contents(), https_prefix_), origin,
state()->selected_instrument()->icon_image_skia(),
background->get_color(), this);
}
......
......@@ -87,6 +87,7 @@ class PaymentHandlerWebFlowViewController
std::unique_ptr<views::ProgressBar> progress_bar_;
std::unique_ptr<views::Separator> separator_;
PaymentHandlerOpenWindowCallback first_navigation_complete_callback_;
base::string16 https_prefix_;
};
} // namespace payments
......
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