Commit 6cb0fba8 authored by Jaeyong Bae's avatar Jaeyong Bae Committed by Commit Bot

[Web Payment] Show lock icon in desktop payment handler's URL bar

This patch means showing the lock icon on the desktop payment handler's
URL bar. It's only for URL has https scheme and a visual indicator
for the fact that only secure content is allowed inside the payment
handler. And, this would also match the new expandable payment handler
window on Android.

Bug: 1052493
Change-Id: I29608e3871a74f9c0bb2da17ff3a0b7b308bf431
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2257090Reviewed-by: default avatarRouslan Solomakhin <rouslan@chromium.org>
Commit-Queue: Rouslan Solomakhin <rouslan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#789002}
parent 421af59c
......@@ -16,8 +16,11 @@
#include "chrome/browser/ui/views/payments/payment_request_views_util.h"
#include "chrome/grit/generated_resources.h"
#include "components/payments/content/icon/icon_size.h"
#include "components/payments/core/features.h"
#include "components/payments/core/native_error_strings.h"
#include "components/payments/core/payments_experimental_features.h"
#include "components/payments/core/url_util.h"
#include "components/vector_icons/vector_icons.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
#include "content/public/browser/navigation_handle.h"
......@@ -29,6 +32,7 @@
#include "ui/gfx/color_palette.h"
#include "ui/gfx/color_utils.h"
#include "ui/gfx/image/image_skia.h"
#include "ui/gfx/paint_vector_icon.h"
#include "ui/views/background.h"
#include "ui/views/border.h"
#include "ui/views/controls/image_view.h"
......@@ -90,8 +94,28 @@ class ReadOnlyOriginView : public views::View {
title_label->SetEnabledColor(foreground);
}
title_origin_layout->StartRow(views::GridLayout::kFixedSize, 0);
auto* origin_label = title_origin_layout->AddView(
auto origin_container = std::make_unique<views::View>();
views::GridLayout* origin_layout = origin_container->SetLayoutManager(
std::make_unique<views::GridLayout>());
columns = origin_layout->AddColumnSet(0);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::CENTER,
1.0, views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
columns->AddColumn(views::GridLayout::LEADING, views::GridLayout::LEADING,
1.0, views::GridLayout::ColumnSize::kUsePreferred, 0, 0);
origin_layout->StartRow(views::GridLayout::kFixedSize, 0);
if (PaymentsExperimentalFeatures::IsEnabled(
features::kPaymentHandlerLockIcon) &&
origin.SchemeIs(url::kHttpsScheme)) {
// TODO(https://crbug.com/1052493):
// Selecting the correct icon based on the SSL certificate state
// and adding test coverage for this code path.
auto lock_icon = std::make_unique<views::ImageView>();
lock_icon->SetImage(gfx::CreateVectorIcon(vector_icons::kLockIcon, 16,
gfx::kChromeIconGrey));
origin_layout->AddView(std::move(lock_icon));
}
auto* origin_label = origin_layout->AddView(
std::make_unique<views::Label>(base::UTF8ToUTF16(origin.host())));
origin_label->SetElideBehavior(gfx::ELIDE_HEAD);
if (!title_is_valid) {
......@@ -108,6 +132,8 @@ class ReadOnlyOriginView : public views::View {
origin_label->SetAutoColorReadabilityEnabled(false);
origin_label->SetEnabledColor(foreground);
origin_label->SetBackgroundColor(background_color);
title_origin_layout->StartRow(views::GridLayout::kFixedSize, 0);
title_origin_layout->AddView(std::move(origin_container));
views::GridLayout* top_level_layout =
SetLayoutManager(std::make_unique<views::GridLayout>());
......
......@@ -66,5 +66,8 @@ const base::Feature kAllowJITInstallationWhenAppIconIsMissing{
"AllowJITInstallationWhenAppIconIsMissing",
base::FEATURE_DISABLED_BY_DEFAULT};
const base::Feature kPaymentHandlerLockIcon{"PaymentHandlerLockIcon",
base::FEATURE_DISABLED_BY_DEFAULT};
} // namespace features
} // namespace payments
......@@ -75,6 +75,11 @@ extern const base::Feature kPaymentHandlerPopUpSizeWindow;
// Used to test icon refetch for JIT installed apps with missing icons.
extern const base::Feature kAllowJITInstallationWhenAppIconIsMissing;
// Desktop only, if enabled the lock icon would be showed next to the
// payment handler's URL bar. It indicate that only secure content is
// allowed inside the payment handler.
extern const base::Feature kPaymentHandlerLockIcon;
} // namespace features
} // 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