Commit 1372e881 authored by glevin's avatar glevin Committed by Commit Bot

Harmonize PlatformVerificationDialog

As per crbug.com/788025 and various other discussions:
- Replace "Learn more" link with (?) button
  - Button has a11y text and is Tab stop
- Update text to match crbug.com/721969
- Width = 448px
- At present, NOT removing X (Close) button
- Clean up code

Bug: 788025
Test: Try to play HD content that requires device id / verification.
Verify Harmoniousness of resultant dialog.

Change-Id: Ibcc300a97b6f2edd49d822171467162500d9e859
Reviewed-on: https://chromium-review.googlesource.com/946907Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Greg Levin <glevin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#561560}
parent 9ee93376
......@@ -3846,7 +3846,7 @@
<!-- Platform verification UI -->
<message name="IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE" desc="The label to describe what the dialog wants to confirm.">
<ph name="DOMAIN">$1<ex>example.com</ex></ph> wants your device's identity to be verified, by Google, to determine eligibility for enhanced playback of protected content. <ph name="LEARN_MORE">$2<ex>Learn more</ex></ph>.
<ph name="DOMAIN">$1<ex>example.com</ex></ph> wants to play protected content. Your device’s identity will be verified by Google.
</message>
<!-- First-run tutorial -->
......
......@@ -18,6 +18,7 @@
#include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h"
#include "components/strings/grit/components_strings.h"
#include "components/vector_icons/vector_icons.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h"
......@@ -27,7 +28,8 @@
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h"
#include "ui/views/border.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/button/image_button_factory.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h"
......@@ -35,12 +37,6 @@
namespace chromeos {
namespace attestation {
namespace {
const int kDialogMaxWidthInPixel = 400;
} // namespace
// static
views::Widget* PlatformVerificationDialog::ShowDialog(
content::WebContents* web_contents,
......@@ -63,7 +59,7 @@ views::Widget* PlatformVerificationDialog::ShowDialog(
->enabled_extensions()
.GetExtensionOrAppByURL(web_contents->GetLastCommittedURL());
// TODO(xhwang): We should only show the name if the request if from the
// TODO(xhwang): We should only show the name if the request is from the
// extension's true frame. See http://crbug.com/455821
std::string origin = extension ? extension->name() : requesting_origin.spec();
......@@ -84,25 +80,32 @@ PlatformVerificationDialog::PlatformVerificationDialog(
const ConsentCallback& callback)
: content::WebContentsObserver(web_contents),
domain_(domain),
callback_(callback) {
callback_(callback),
learn_more_button_(nullptr) {
SetLayoutManager(std::make_unique<views::FillLayout>());
gfx::Insets dialog_insets =
ChromeLayoutProvider::Get()->GetInsetsMetric(views::INSETS_DIALOG);
SetBorder(views::CreateEmptyBorder(0, dialog_insets.left(), 0,
dialog_insets.right()));
const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE);
std::vector<size_t> offsets;
base::string16 headline = l10n_util::GetStringFUTF16(
IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets);
views::StyledLabel* headline_label = new views::StyledLabel(headline, this);
headline_label->AddStyleRange(
gfx::Range(offsets[1], offsets[1] + learn_more.size()),
views::StyledLabel::RangeStyleInfo::CreateForLink());
AddChildView(headline_label);
SetBorder(views::CreateEmptyBorder(
views::LayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)));
// Explanation string.
views::Label* label = new views::Label(l10n_util::GetStringFUTF16(
IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_));
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
AddChildView(label);
chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION);
}
views::View* PlatformVerificationDialog::CreateExtraView() {
learn_more_button_ = views::CreateVectorImageButton(this);
views::SetImageFromVectorIcon(learn_more_button_,
vector_icons::kHelpOutlineIcon);
learn_more_button_->SetAccessibleName(
l10n_util::GetStringUTF16(IDS_CHROMEOS_ACC_LEARN_MORE));
learn_more_button_->SetFocusForPlatform();
return learn_more_button_;
}
bool PlatformVerificationDialog::Cancel() {
// This method is called when user clicked "Block" button.
callback_.Run(CONSENT_RESPONSE_DENY);
......@@ -141,14 +144,18 @@ ui::ModalType PlatformVerificationDialog::GetModalType() const {
}
gfx::Size PlatformVerificationDialog::CalculatePreferredSize() const {
return gfx::Size(kDialogMaxWidthInPixel,
GetHeightForWidth(kDialogMaxWidthInPixel));
const int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(
default_width,
GetLayoutManager()->GetPreferredHeightForWidth(this, default_width));
}
void PlatformVerificationDialog::StyledLabelLinkClicked(
views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
void PlatformVerificationDialog::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender != learn_more_button_)
return;
Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
const GURL learn_more_url(chrome::kEnhancedPlaybackNotificationLearnMoreURL);
......
......@@ -10,7 +10,7 @@
#include "base/strings/string16.h"
#include "content/public/browser/reload_type.h"
#include "content/public/browser/web_contents_observer.h"
#include "ui/views/controls/styled_label_listener.h"
#include "ui/views/controls/button/image_button.h"
#include "ui/views/window/dialog_delegate.h"
namespace content {
......@@ -22,7 +22,7 @@ namespace attestation {
// A tab-modal dialog UI to ask the user for PlatformVerificationFlow.
class PlatformVerificationDialog : public views::DialogDelegateView,
public views::StyledLabelListener,
public views::ButtonListener,
public content::WebContentsObserver {
public:
enum ConsentResponse {
......@@ -50,6 +50,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
const ConsentCallback& callback);
// views::DialogDelegate:
View* CreateExtraView() override;
bool Cancel() override;
bool Accept() override;
bool Close() override;
......@@ -61,10 +62,8 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
// views::View:
gfx::Size CalculatePreferredSize() const override;
// views::StyledLabelListener:
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// content::WebContentsObserver:
void DidStartNavigation(
......@@ -72,6 +71,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
base::string16 domain_;
ConsentCallback callback_;
views::ImageButton* learn_more_button_;
DISALLOW_COPY_AND_ASSIGN(PlatformVerificationDialog);
};
......
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