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 @@ ...@@ -3846,7 +3846,7 @@
<!-- Platform verification UI --> <!-- Platform verification UI -->
<message name="IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE" desc="The label to describe what the dialog wants to confirm."> <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> </message>
<!-- First-run tutorial --> <!-- First-run tutorial -->
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "components/constrained_window/constrained_window_views.h" #include "components/constrained_window/constrained_window_views.h"
#include "components/strings/grit/components_strings.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 "components/web_modal/web_contents_modal_dialog_manager.h"
#include "content/public/browser/navigation_handle.h" #include "content/public/browser/navigation_handle.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
...@@ -27,7 +28,8 @@ ...@@ -27,7 +28,8 @@
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#include "ui/views/border.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/layout/fill_layout.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_delegate.h" #include "ui/views/window/dialog_delegate.h"
...@@ -35,12 +37,6 @@ ...@@ -35,12 +37,6 @@
namespace chromeos { namespace chromeos {
namespace attestation { namespace attestation {
namespace {
const int kDialogMaxWidthInPixel = 400;
} // namespace
// static // static
views::Widget* PlatformVerificationDialog::ShowDialog( views::Widget* PlatformVerificationDialog::ShowDialog(
content::WebContents* web_contents, content::WebContents* web_contents,
...@@ -63,7 +59,7 @@ views::Widget* PlatformVerificationDialog::ShowDialog( ...@@ -63,7 +59,7 @@ views::Widget* PlatformVerificationDialog::ShowDialog(
->enabled_extensions() ->enabled_extensions()
.GetExtensionOrAppByURL(web_contents->GetLastCommittedURL()); .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 // extension's true frame. See http://crbug.com/455821
std::string origin = extension ? extension->name() : requesting_origin.spec(); std::string origin = extension ? extension->name() : requesting_origin.spec();
...@@ -84,25 +80,32 @@ PlatformVerificationDialog::PlatformVerificationDialog( ...@@ -84,25 +80,32 @@ PlatformVerificationDialog::PlatformVerificationDialog(
const ConsentCallback& callback) const ConsentCallback& callback)
: content::WebContentsObserver(web_contents), : content::WebContentsObserver(web_contents),
domain_(domain), domain_(domain),
callback_(callback) { callback_(callback),
learn_more_button_(nullptr) {
SetLayoutManager(std::make_unique<views::FillLayout>()); SetLayoutManager(std::make_unique<views::FillLayout>());
SetBorder(views::CreateEmptyBorder(
gfx::Insets dialog_insets = views::LayoutProvider::Get()->GetDialogInsetsForContentType(
ChromeLayoutProvider::Get()->GetInsetsMetric(views::INSETS_DIALOG); views::TEXT, views::TEXT)));
SetBorder(views::CreateEmptyBorder(0, dialog_insets.left(), 0,
dialog_insets.right())); // Explanation string.
const base::string16 learn_more = l10n_util::GetStringUTF16(IDS_LEARN_MORE); views::Label* label = new views::Label(l10n_util::GetStringFUTF16(
std::vector<size_t> offsets; IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_));
base::string16 headline = l10n_util::GetStringFUTF16( label->SetMultiLine(true);
IDS_PLATFORM_VERIFICATION_DIALOG_HEADLINE, domain_, learn_more, &offsets); label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
views::StyledLabel* headline_label = new views::StyledLabel(headline, this); AddChildView(label);
headline_label->AddStyleRange(
gfx::Range(offsets[1], offsets[1] + learn_more.size()),
views::StyledLabel::RangeStyleInfo::CreateForLink());
AddChildView(headline_label);
chrome::RecordDialogCreation(chrome::DialogIdentifier::PLATFORM_VERIFICATION); 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() { bool PlatformVerificationDialog::Cancel() {
// This method is called when user clicked "Block" button. // This method is called when user clicked "Block" button.
callback_.Run(CONSENT_RESPONSE_DENY); callback_.Run(CONSENT_RESPONSE_DENY);
...@@ -141,14 +144,18 @@ ui::ModalType PlatformVerificationDialog::GetModalType() const { ...@@ -141,14 +144,18 @@ ui::ModalType PlatformVerificationDialog::GetModalType() const {
} }
gfx::Size PlatformVerificationDialog::CalculatePreferredSize() const { gfx::Size PlatformVerificationDialog::CalculatePreferredSize() const {
return gfx::Size(kDialogMaxWidthInPixel, const int default_width = views::LayoutProvider::Get()->GetDistanceMetric(
GetHeightForWidth(kDialogMaxWidthInPixel)); DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
return gfx::Size(
default_width,
GetLayoutManager()->GetPreferredHeightForWidth(this, default_width));
} }
void PlatformVerificationDialog::StyledLabelLinkClicked( void PlatformVerificationDialog::ButtonPressed(views::Button* sender,
views::StyledLabel* label, const ui::Event& event) {
const gfx::Range& range, if (sender != learn_more_button_)
int event_flags) { return;
Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
const GURL learn_more_url(chrome::kEnhancedPlaybackNotificationLearnMoreURL); const GURL learn_more_url(chrome::kEnhancedPlaybackNotificationLearnMoreURL);
......
...@@ -10,7 +10,7 @@ ...@@ -10,7 +10,7 @@
#include "base/strings/string16.h" #include "base/strings/string16.h"
#include "content/public/browser/reload_type.h" #include "content/public/browser/reload_type.h"
#include "content/public/browser/web_contents_observer.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" #include "ui/views/window/dialog_delegate.h"
namespace content { namespace content {
...@@ -22,7 +22,7 @@ namespace attestation { ...@@ -22,7 +22,7 @@ namespace attestation {
// A tab-modal dialog UI to ask the user for PlatformVerificationFlow. // A tab-modal dialog UI to ask the user for PlatformVerificationFlow.
class PlatformVerificationDialog : public views::DialogDelegateView, class PlatformVerificationDialog : public views::DialogDelegateView,
public views::StyledLabelListener, public views::ButtonListener,
public content::WebContentsObserver { public content::WebContentsObserver {
public: public:
enum ConsentResponse { enum ConsentResponse {
...@@ -50,6 +50,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView, ...@@ -50,6 +50,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
const ConsentCallback& callback); const ConsentCallback& callback);
// views::DialogDelegate: // views::DialogDelegate:
View* CreateExtraView() override;
bool Cancel() override; bool Cancel() override;
bool Accept() override; bool Accept() override;
bool Close() override; bool Close() override;
...@@ -61,10 +62,8 @@ class PlatformVerificationDialog : public views::DialogDelegateView, ...@@ -61,10 +62,8 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
// views::View: // views::View:
gfx::Size CalculatePreferredSize() const override; gfx::Size CalculatePreferredSize() const override;
// views::StyledLabelListener: // views::ButtonListener:
void StyledLabelLinkClicked(views::StyledLabel* label, void ButtonPressed(views::Button* sender, const ui::Event& event) override;
const gfx::Range& range,
int event_flags) override;
// content::WebContentsObserver: // content::WebContentsObserver:
void DidStartNavigation( void DidStartNavigation(
...@@ -72,6 +71,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView, ...@@ -72,6 +71,7 @@ class PlatformVerificationDialog : public views::DialogDelegateView,
base::string16 domain_; base::string16 domain_;
ConsentCallback callback_; ConsentCallback callback_;
views::ImageButton* learn_more_button_;
DISALLOW_COPY_AND_ASSIGN(PlatformVerificationDialog); 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