Commit 0f68f2f3 authored by Henrique Grandinetti's avatar Henrique Grandinetti Committed by Commit Bot

Make parent access widget a system modal

The parent access widget should have a semi-transparent mask behind it
when it is created. This is automatically added when its modal type is
overridden to set modal type system, and taking effect on the signed in
and signed out session.

Bug: 921145
Change-Id: I3eaf9beede0c5ca7f15ca472e4f5b8aac2c7af54
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1653255
Commit-Queue: Henrique Grandinetti <hgrandinetti@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarAga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#668605}
parent 6cb7577a
......@@ -12,6 +12,7 @@
#include "ash/login/ui/arrow_button_view.h"
#include "ash/login/ui/login_button.h"
#include "ash/login/ui/login_pin_view.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/public/cpp/login_types.h"
#include "ash/resources/vector_icons/vector_icons.h"
#include "ash/session/session_controller_impl.h"
......@@ -48,8 +49,6 @@ namespace ash {
namespace {
constexpr const char kParentAccessViewClassName[] = "ParentAccessView";
// Identifier of parent access input views group used for focus traversal.
constexpr int kParentAccessInputGroup = 1;
......@@ -422,9 +421,7 @@ ParentAccessView::Callbacks::~Callbacks() = default;
ParentAccessView::ParentAccessView(const AccountId& account_id,
const Callbacks& callbacks,
ParentAccessRequestReason reason)
: NonAccessibleView(kParentAccessViewClassName),
callbacks_(callbacks),
account_id_(account_id) {
: callbacks_(callbacks), account_id_(account_id) {
DCHECK(callbacks.on_finished);
// Main view contains all other views aligned vertically and centered.
......@@ -623,6 +620,18 @@ gfx::Size ParentAccessView::CalculatePreferredSize() const {
return GetParentAccessViewSize();
}
ui::ModalType ParentAccessView::GetModalType() const {
// MODAL_TYPE_SYSTEM is used to get a semi-transparent background behind the
// parent access view, when it is used directly on a widget. The overlay
// consumes all the inputs from the user, so that they can only interact with
// the parent access view while it is visible.
return ui::MODAL_TYPE_SYSTEM;
}
views::View* ParentAccessView::GetInitiallyFocusedView() {
return access_code_view_;
}
void ParentAccessView::ButtonPressed(views::Button* sender,
const ui::Event& event) {
if (sender == back_button_) {
......
......@@ -8,7 +8,6 @@
#include <string>
#include "ash/ash_export.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/wm/tablet_mode/tablet_mode_controller.h"
#include "ash/wm/tablet_mode/tablet_mode_observer.h"
#include "base/callback.h"
......@@ -17,6 +16,7 @@
#include "base/scoped_observer.h"
#include "components/account_id/account_id.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/window/dialog_delegate.h"
namespace views {
class Label;
......@@ -27,12 +27,13 @@ namespace ash {
class ArrowButtonView;
class LoginButton;
class LoginPinView;
class NonAccessibleView;
enum class ParentAccessRequestReason;
// The view that allows for input of parent access code to authorize certain
// actions on child's device.
class ASH_EXPORT ParentAccessView : public NonAccessibleView,
class ASH_EXPORT ParentAccessView : public views::DialogDelegateView,
public views::ButtonListener,
public TabletModeObserver {
public:
......@@ -94,6 +95,10 @@ class ASH_EXPORT ParentAccessView : public NonAccessibleView,
gfx::Size CalculatePreferredSize() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
// views::DialogDelegateView:
ui::ModalType GetModalType() const override;
views::View* GetInitiallyFocusedView() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
......@@ -36,18 +36,15 @@ ParentAccessWidget::ParentAccessWidget(const AccountId& account_id,
widget_params.parent =
ash::Shell::GetPrimaryRootWindow()->GetChildById(parent_window_id);
widget_ = std::make_unique<views::Widget>();
widget_->set_focus_on_creation(true);
widget_->Init(widget_params);
ParentAccessView::Callbacks callbacks;
callbacks.on_finished = base::BindRepeating(&ParentAccessWidget::OnExit,
weak_factory_.GetWeakPtr());
widget_params.delegate = new ParentAccessView(account_id, callbacks, reason);
widget_->SetContentsView(new ParentAccessView(account_id, callbacks, reason));
widget_ = std::make_unique<views::Widget>();
widget_->Init(widget_params);
widget_->CenterWindow(widget_->GetContentsView()->GetPreferredSize());
widget_->Show();
widget_->GetContentsView()->RequestFocus();
}
ParentAccessWidget::~ParentAccessWidget() = default;
......
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