Commit 5df2779d authored by Sarah Hu's avatar Sarah Hu Committed by Commit Bot

cros: Add warning dialog in public account view

Bug: 864549
Change-Id: If79c0100067c62a9fedb3119f43813a87d5bd6c6
Reviewed-on: https://chromium-review.googlesource.com/1145864
Commit-Queue: Xiaoyin Hu <xiaoyinh@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarMichael Wasserman <msw@chromium.org>
Cr-Commit-Position: refs/heads/master@{#580012}
parent 97148818
......@@ -397,6 +397,8 @@ component("ash") {
"login/ui/note_action_launch_button.h",
"login/ui/pin_keyboard_animation.cc",
"login/ui/pin_keyboard_animation.h",
"login/ui/public_account_warning_dialog.cc",
"login/ui/public_account_warning_dialog.h",
"login/ui/scrollable_users_list_view.cc",
"login/ui/scrollable_users_list_view.h",
"login/ui/user_switch_flip_animation.cc",
......
......@@ -1513,6 +1513,21 @@ This file contains the strings for ash.
<message name="IDS_ASH_LOGIN_COME_BACK_MESSAGE" desc="Message shown to user indicating a future time when the user is allowed to use the device again.">
Come back at <ph name="COME_BACK_TIME">$1<ex>7:30 AM</ex></ph>.
</message>
<message name="IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO" desc="Text shown in the warning dialog after user clicks on the learn more link, notifying the user of potential security and privacy implications of using the device">
The device admin may monitor the following:
</message>
<message name="IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_1" desc="Text shown in the warning dialog after user clicks on the learn more link, notifying the user of potential security and privacy implications of using the device">
Access your browsing activity
</message>
<message name="IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_2" desc="Text shown in the warning dialog after user clicks on the learn more link, notifying the user of potential security and privacy implications of using the device">
Manipulate settings that specify whether websites can use features such as geolocation, microphone, camera, etc.
</message>
<message name="IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_3" desc="Text shown in the warning dialog after user clicks on the learn more link, notifying the user of potential security and privacy implications of using the device">
Manage your apps, extensions, and themes
</message>
<message name="IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_4" desc="Text shown in the warning dialog after user clicks on the learn more link, notifying the user of potential security and privacy implications of using the device">
Manipulate privacy-related settings
</message>
<!-- Multi-profiles intro dialog -->
<message name="IDS_ASH_MULTIPROFILES_INTRO_HEADLINE" desc="Describes which feature multi-profiles intro dialog presents.">
......
b57a43652610329c02562ec19ced8c3591ca42c6
\ No newline at end of file
b57a43652610329c02562ec19ced8c3591ca42c6
\ No newline at end of file
b57a43652610329c02562ec19ced8c3591ca42c6
\ No newline at end of file
b57a43652610329c02562ec19ced8c3591ca42c6
\ No newline at end of file
b57a43652610329c02562ec19ced8c3591ca42c6
\ No newline at end of file
......@@ -14,6 +14,7 @@
#include "ash/login/ui/login_button.h"
#include "ash/login/ui/login_menu_view.h"
#include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/public_account_warning_dialog.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
......@@ -25,7 +26,6 @@
#include "ui/views/border.h"
#include "ui/views/controls/image_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/controls/styled_label_listener.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/layout/fill_layout.h"
......@@ -217,9 +217,10 @@ class RightPaneView : public NonAccessibleView,
public views::ButtonListener,
public views::StyledLabelListener {
public:
RightPaneView()
explicit RightPaneView(const base::RepeatingClosure& on_learn_more_tapped)
: language_menu_(std::make_unique<LoginBubble>()),
keyboard_menu_(std::make_unique<LoginBubble>()),
on_learn_more_tapped_(on_learn_more_tapped),
weak_factory_(this) {
SetPreferredSize(
gfx::Size(kExpandedViewWidthDp / 2, kExpandedViewHeightDp));
......@@ -238,21 +239,22 @@ class RightPaneView : public NonAccessibleView,
size_t offset;
const base::string16 text = l10n_util::GetStringFUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_SIGNOUT_REMINDER, link, &offset);
views::StyledLabel* bottom_label = new views::StyledLabel(text, this);
learn_more_label_ = new views::StyledLabel(text, this);
views::StyledLabel::RangeStyleInfo style;
style.custom_font = bottom_label->GetDefaultFontList().Derive(
style.custom_font = learn_more_label_->GetDefaultFontList().Derive(
0, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::NORMAL);
style.override_color = SK_ColorWHITE;
bottom_label->AddStyleRange(gfx::Range(0, offset), style);
learn_more_label_->AddStyleRange(gfx::Range(0, offset), style);
views::StyledLabel::RangeStyleInfo link_style =
views::StyledLabel::RangeStyleInfo::CreateForLink();
link_style.override_color = kPublicSessionBlueColor;
bottom_label->AddStyleRange(gfx::Range(offset, offset + link.length()),
link_style);
bottom_label->set_auto_color_readability_enabled(false);
labels_view_->AddChildView(bottom_label);
learn_more_label_->AddStyleRange(gfx::Range(offset, offset + link.length()),
link_style);
learn_more_label_->set_auto_color_readability_enabled(false);
labels_view_->AddChildView(learn_more_label_);
// Create button to show/hide advanced view.
advanced_view_button_ = new SelectionButtonView(
......@@ -394,7 +396,7 @@ class RightPaneView : public NonAccessibleView,
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override {
NOTIMPLEMENTED();
on_learn_more_tapped_.Run();
}
void UpdateForUser(const mojom::LoginUserInfoPtr& user) {
......@@ -494,11 +496,9 @@ class RightPaneView : public NonAccessibleView,
language_changed_by_user_ = false;
}
SelectionButtonView* advanced_view_button() { return advanced_view_button_; }
ArrowButtonView* submit_button() { return submit_button_; }
views::View* advanced_view() { return advanced_view_; }
private:
friend class LoginExpandedPublicAccountView::TestApi;
bool show_advanced_view_ = false;
mojom::LoginUserInfoPtr current_user_;
......@@ -508,6 +508,7 @@ class RightPaneView : public NonAccessibleView,
SelectionButtonView* language_selection_ = nullptr;
SelectionButtonView* keyboard_selection_ = nullptr;
ArrowButtonView* submit_button_ = nullptr;
views::StyledLabel* learn_more_label_ = nullptr;
std::unique_ptr<LoginBubble> language_menu_;
std::unique_ptr<LoginBubble> keyboard_menu_;
......@@ -525,6 +526,8 @@ class RightPaneView : public NonAccessibleView,
bool show_advanced_changed_by_user_ = false;
bool language_changed_by_user_ = false;
base::RepeatingClosure on_learn_more_tapped_;
base::WeakPtrFactory<RightPaneView> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(RightPaneView);
......@@ -537,21 +540,32 @@ LoginExpandedPublicAccountView::TestApi::TestApi(
LoginExpandedPublicAccountView::TestApi::~TestApi() = default;
views::View* LoginExpandedPublicAccountView::TestApi::advanced_view_button() {
return view_->right_pane_->advanced_view_button();
return view_->right_pane_->advanced_view_button_;
}
ArrowButtonView* LoginExpandedPublicAccountView::TestApi::submit_button() {
return view_->right_pane_->submit_button();
return view_->right_pane_->submit_button_;
}
views::View* LoginExpandedPublicAccountView::TestApi::advanced_view() {
return view_->right_pane_->advanced_view();
return view_->right_pane_->advanced_view_;
}
PublicAccountWarningDialog*
LoginExpandedPublicAccountView::TestApi::warning_dialog() {
return view_->warning_dialog_;
}
views::StyledLabel*
LoginExpandedPublicAccountView::TestApi::learn_more_label() {
return view_->right_pane_->learn_more_label_;
}
LoginExpandedPublicAccountView::LoginExpandedPublicAccountView(
const OnPublicSessionViewDismissed& on_dismissed)
: NonAccessibleView(kLoginExpandedPublicAccountViewClassName),
on_dismissed_(on_dismissed) {
on_dismissed_(on_dismissed),
weak_factory_(this) {
Shell::Get()->AddPreTargetHandler(this);
SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
......@@ -578,7 +592,9 @@ LoginExpandedPublicAccountView::LoginExpandedPublicAccountView(
left_pane->SetBorder(
views::CreateSolidSidedBorder(0, 0, 0, kBorderThicknessDp, kBorderColor));
right_pane_ = new RightPaneView();
right_pane_ = new RightPaneView(
base::BindRepeating(&LoginExpandedPublicAccountView::ShowWarningDialog,
base::Unretained(this)));
AddChildView(right_pane_);
}
......@@ -591,6 +607,10 @@ void LoginExpandedPublicAccountView::ProcessPressedEvent(
if (!visible())
return;
// Keep this view to be visible until warning dialog is dismissed.
if (warning_dialog_ && warning_dialog_->IsVisible())
return;
if (GetBoundsInScreen().Contains(event->root_location()))
return;
......@@ -631,6 +651,16 @@ void LoginExpandedPublicAccountView::Hide() {
on_dismissed_.Run();
}
void LoginExpandedPublicAccountView::ShowWarningDialog() {
DCHECK(!warning_dialog_);
warning_dialog_ = new PublicAccountWarningDialog(weak_factory_.GetWeakPtr());
warning_dialog_->Show();
}
void LoginExpandedPublicAccountView::OnWarningDialogClosed() {
warning_dialog_ = nullptr;
}
void LoginExpandedPublicAccountView::OnPaint(gfx::Canvas* canvas) {
views::View::OnPaint(canvas);
......@@ -657,6 +687,10 @@ void LoginExpandedPublicAccountView::OnKeyEvent(ui::KeyEvent* event) {
if (!visible() || event->type() != ui::ET_KEY_PRESSED)
return;
// Give warning dialog a chance to handle key event.
if (warning_dialog_ && warning_dialog_->IsVisible())
return;
if (event->key_code() == ui::KeyboardCode::VKEY_ESCAPE) {
Hide();
}
......
......@@ -9,6 +9,7 @@
#include "ash/login/ui/non_accessible_view.h"
#include "ash/public/interfaces/login_user_info.mojom.h"
#include "ui/events/event_handler.h"
#include "ui/views/controls/styled_label.h"
#include "ui/views/view.h"
namespace ash {
......@@ -16,6 +17,7 @@ namespace ash {
class ArrowButtonView;
class LoginUserView;
class RightPaneView;
class PublicAccountWarningDialog;
// Implements an expanded view for the public acount user to select language
// and keyboard options.
......@@ -30,6 +32,8 @@ class ASH_EXPORT LoginExpandedPublicAccountView : public NonAccessibleView {
views::View* advanced_view_button();
ArrowButtonView* submit_button();
views::View* advanced_view();
PublicAccountWarningDialog* warning_dialog();
views::StyledLabel* learn_more_label();
private:
LoginExpandedPublicAccountView* const view_;
......@@ -44,6 +48,8 @@ class ASH_EXPORT LoginExpandedPublicAccountView : public NonAccessibleView {
void UpdateForUser(const mojom::LoginUserInfoPtr& user);
const mojom::LoginUserInfoPtr& current_user() const;
void Hide();
void ShowWarningDialog();
void OnWarningDialogClosed();
// views::View:
void OnPaint(gfx::Canvas* canvas) override;
......@@ -57,6 +63,9 @@ class ASH_EXPORT LoginExpandedPublicAccountView : public NonAccessibleView {
LoginUserView* user_view_ = nullptr;
RightPaneView* right_pane_ = nullptr;
OnPublicSessionViewDismissed on_dismissed_;
PublicAccountWarningDialog* warning_dialog_ = nullptr;
base::WeakPtrFactory<LoginExpandedPublicAccountView> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(LoginExpandedPublicAccountView);
};
......
......@@ -5,6 +5,7 @@
#include "ash/login/ui/login_expanded_public_account_view.h"
#include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/login_test_utils.h"
#include "ash/login/ui/public_account_warning_dialog.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/test/event_generator.h"
#include "ui/views/layout/box_layout.h"
......@@ -29,21 +30,25 @@ class LoginExpandedPublicAccountViewTest : public LoginTestBase {
LoginTestBase::SetUp();
user_ = CreatePublicAccountUser("user@domain.com");
view_ = new LoginExpandedPublicAccountView(base::DoNothing());
view_->UpdateForUser(user_);
public_account_ = new LoginExpandedPublicAccountView(base::DoNothing());
public_account_->UpdateForUser(user_);
other_view_ = new views::View();
container_ = new views::View();
container_->SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
container_->AddChildView(view_);
container_->AddChildView(public_account_);
container_->AddChildView(other_view_);
SetWidget(CreateWidgetWithContent(container_));
}
mojom::LoginUserInfoPtr user_;
// Owned by test widget view hierarchy.
views::View* container_ = nullptr;
// Owned by test widget view hierarchy
LoginExpandedPublicAccountView* view_ = nullptr;
LoginExpandedPublicAccountView* public_account_ = nullptr;
views::View* other_view_ = nullptr;
private:
DISALLOW_COPY_AND_ASSIGN(LoginExpandedPublicAccountViewTest);
......@@ -53,22 +58,22 @@ class LoginExpandedPublicAccountViewTest : public LoginTestBase {
// Verifies toggle advanced view will update the layout correctly.
TEST_F(LoginExpandedPublicAccountViewTest, ToggleAdvancedView) {
view_->SizeToPreferredSize();
EXPECT_EQ(view_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(view_->height(), kBubbleTotalHeightDp);
public_account_->SizeToPreferredSize();
EXPECT_EQ(public_account_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(public_account_->height(), kBubbleTotalHeightDp);
LoginExpandedPublicAccountView::TestApi test_api(view_);
LoginExpandedPublicAccountView::TestApi test_api(public_account_);
EXPECT_FALSE(user_->public_account_info->show_advanced_view);
EXPECT_FALSE(test_api.advanced_view()->visible());
// Toggle show_advanced_view.
user_->public_account_info->show_advanced_view = true;
view_->UpdateForUser(user_);
public_account_->UpdateForUser(user_);
// Advanced view is shown and the overall size does not change.
EXPECT_TRUE(test_api.advanced_view()->visible());
EXPECT_EQ(view_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(view_->height(), kBubbleTotalHeightDp);
EXPECT_EQ(public_account_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(public_account_->height(), kBubbleTotalHeightDp);
// Click on the show advanced button.
ui::test::EventGenerator* generator = GetEventGenerator();
......@@ -78,8 +83,44 @@ TEST_F(LoginExpandedPublicAccountViewTest, ToggleAdvancedView) {
// Advanced view is hidden and the overall size does not change.
EXPECT_FALSE(test_api.advanced_view()->visible());
EXPECT_EQ(view_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(view_->height(), kBubbleTotalHeightDp);
EXPECT_EQ(public_account_->width(), kBubbleTotalWidthDp);
EXPECT_EQ(public_account_->height(), kBubbleTotalHeightDp);
}
// Verifies warning dialog shows up correctly.
TEST_F(LoginExpandedPublicAccountViewTest, ShowWarningDialog) {
LoginExpandedPublicAccountView::TestApi test_api(public_account_);
views::StyledLabel::TestApi styled_label_test(test_api.learn_more_label());
EXPECT_EQ(test_api.warning_dialog(), nullptr);
EXPECT_EQ(styled_label_test.link_targets().size(), 1U);
// Tap on the learn more link.
views::View* link_view = styled_label_test.link_targets().begin()->first;
GetEventGenerator()->MoveMouseTo(
link_view->GetBoundsInScreen().CenterPoint());
GetEventGenerator()->ClickLeftButton();
EXPECT_NE(test_api.warning_dialog(), nullptr);
EXPECT_TRUE(test_api.warning_dialog()->IsVisible());
// When warning dialog is shown, tap outside of public account expanded view
// should not hide it.
GetEventGenerator()->MoveMouseTo(
other_view_->GetBoundsInScreen().CenterPoint());
GetEventGenerator()->ClickLeftButton();
EXPECT_TRUE(public_account_->visible());
EXPECT_NE(test_api.warning_dialog(), nullptr);
EXPECT_TRUE(test_api.warning_dialog()->IsVisible());
// If the warning dialog is shown, escape key should close the waring dialog,
// but not the public account view.
GetEventGenerator()->PressKey(ui::KeyboardCode::VKEY_ESCAPE, 0);
base::RunLoop().RunUntilIdle();
EXPECT_EQ(test_api.warning_dialog(), nullptr);
EXPECT_TRUE(public_account_->visible());
// Press escape again should hide the public account expanded view.
GetEventGenerator()->PressKey(ui::KeyboardCode::VKEY_ESCAPE, 0);
EXPECT_FALSE(public_account_->visible());
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/login/ui/public_account_warning_dialog.h"
#include "ash/login/ui/login_expanded_public_account_view.h"
#include "ash/strings/grit/ash_strings.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/gfx/canvas.h"
#include "ui/views/border.h"
#include "ui/views/bubble/bubble_frame_view.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h"
namespace ash {
namespace {
constexpr int kDialogWidthDp = 400;
constexpr int kDialogHeightDp = 145;
constexpr int kDialogContentMarginDp = 13;
constexpr int kBulletRadiusDp = 2;
constexpr int kBulletContainerSizeDp = 22;
constexpr int kLineHeightDp = 15;
constexpr int kBetweenLabelPaddingDp = 4;
class BulletView : public views::View {
public:
explicit BulletView(SkColor color, int radius)
: color_(color), radius_(radius) {}
~BulletView() override = default;
// views::View:
void OnPaint(gfx::Canvas* canvas) override {
View::OnPaint(canvas);
SkPath path;
path.addCircle(GetLocalBounds().CenterPoint().x(),
GetLocalBounds().CenterPoint().y(), radius_);
cc::PaintFlags flags;
flags.setStyle(cc::PaintFlags::kStrokeAndFill_Style);
flags.setColor(color_);
flags.setAntiAlias(true);
canvas->DrawPath(path, flags);
}
private:
SkColor color_;
int radius_;
DISALLOW_COPY_AND_ASSIGN(BulletView);
};
} // namespace
PublicAccountWarningDialog::PublicAccountWarningDialog(
base::WeakPtr<LoginExpandedPublicAccountView> controller)
: controller_(controller) {
SetLayoutManager(std::make_unique<views::BoxLayout>(
views::BoxLayout::kVertical, gfx::Insets(), kBetweenLabelPaddingDp));
SetBorder(views::CreateEmptyBorder(gfx::Insets(kDialogContentMarginDp)));
auto add_bulleted_label = [&](const base::string16& text) {
auto* container = new views::View();
container->SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kHorizontal));
auto* label = new views::Label(text);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
label->SetLineHeight(kLineHeightDp);
label->SetFontList(views::Label::GetDefaultFontList().Derive(
1, gfx::Font::FontStyle::NORMAL, gfx::Font::Weight::NORMAL));
label->SetEnabledColor(SK_ColorGRAY);
auto* bullet_view = new BulletView(label->enabled_color(), kBulletRadiusDp);
bullet_view->SetPreferredSize(
gfx::Size(kBulletContainerSizeDp, kBulletContainerSizeDp));
container->AddChildView(bullet_view);
container->AddChildView(label);
AddChildView(container);
};
add_bulleted_label(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_1));
add_bulleted_label(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_2));
add_bulleted_label(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_3));
add_bulleted_label(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO_ITEM_4));
// Widget will take the owership of this view.
views::DialogDelegate::CreateDialogWidget(
this, nullptr, controller->GetWidget()->GetNativeView());
}
PublicAccountWarningDialog::~PublicAccountWarningDialog() {
if (controller_)
controller_->OnWarningDialogClosed();
}
bool PublicAccountWarningDialog::IsVisible() {
return GetWidget() && GetWidget()->IsVisible();
}
void PublicAccountWarningDialog::Show() {
if (GetWidget())
GetWidget()->Show();
}
int PublicAccountWarningDialog::GetDialogButtons() const {
return ui::DIALOG_BUTTON_NONE;
}
void PublicAccountWarningDialog::AddedToWidget() {
std::unique_ptr<views::Label> title_label =
views::BubbleFrameView::CreateDefaultTitleLabel(l10n_util::GetStringUTF16(
IDS_ASH_LOGIN_PUBLIC_ACCOUNT_MONITORING_INFO));
title_label->SetFontList(title_label->font_list().Derive(
1, gfx::Font::NORMAL, gfx::Font::Weight::BOLD));
auto* frame_view = static_cast<views::BubbleFrameView*>(
GetWidget()->non_client_view()->frame_view());
frame_view->SetTitleView(std::move(title_label));
}
ui::ModalType PublicAccountWarningDialog::GetModalType() const {
return ui::MODAL_TYPE_SYSTEM;
}
gfx::Size PublicAccountWarningDialog::CalculatePreferredSize() const {
return gfx::Size(kDialogWidthDp, kDialogHeightDp);
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_
#define ASH_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_
#include "base/memory/weak_ptr.h"
#include "ui/views/window/dialog_delegate.h"
namespace ash {
class LoginExpandedPublicAccountView;
// Dialog for displaying public session warning. This is shown when a user
// clicks on the learn more link on the pubic account expanded view.
class PublicAccountWarningDialog : public views::DialogDelegateView {
public:
PublicAccountWarningDialog(
base::WeakPtr<LoginExpandedPublicAccountView> controller);
~PublicAccountWarningDialog() override;
bool IsVisible();
void Show();
// views::DialogDelegate:
int GetDialogButtons() const override;
void AddedToWidget() override;
// views::WidgetDelegate:
ui::ModalType GetModalType() const override;
// views::View:
gfx::Size CalculatePreferredSize() const override;
private:
base::WeakPtr<LoginExpandedPublicAccountView> controller_;
DISALLOW_COPY_AND_ASSIGN(PublicAccountWarningDialog);
};
} // namespace ash
#endif // ASH_LOGIN_UI_PUBLIC_ACCOUNT_WARNING_DIALOG_H_
......@@ -82,6 +82,16 @@ int HorizontalAdjustment(int used_width,
} // namespace
// StyledLabel::TestApi ------------------------------------------------
StyledLabel::TestApi::TestApi(StyledLabel* view) : view_(view) {}
StyledLabel::TestApi::~TestApi() = default;
const std::map<View*, gfx::Range>& StyledLabel::TestApi::link_targets() {
return view_->link_targets_;
}
// StyledLabel::RangeStyleInfo ------------------------------------------------
StyledLabel::RangeStyleInfo::RangeStyleInfo() = default;
......
......@@ -37,6 +37,20 @@ class VIEWS_EXPORT StyledLabel : public View, public LinkListener {
// Internal class name.
static const char kViewClassName[];
// TestApi is used for tests to get internal implementation details.
class VIEWS_EXPORT TestApi {
public:
explicit TestApi(StyledLabel* view);
~TestApi();
const std::map<View*, gfx::Range>& link_targets();
private:
StyledLabel* const view_;
DISALLOW_COPY_AND_ASSIGN(TestApi);
};
// Parameters that define label style for a styled label's text range.
struct VIEWS_EXPORT RangeStyleInfo {
RangeStyleInfo();
......
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