forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaccelerator_confirmation_dialog.cc
68 lines (57 loc) · 2.39 KB
/
accelerator_confirmation_dialog.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
// Copyright (c) 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/accelerators/accelerator_confirmation_dialog.h"
#include <memory>
#include <utility>
#include "ash/public/cpp/shell_window_ids.h"
#include "ash/session/session_controller_impl.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h"
#include "base/bind.h"
#include "ui/base/l10n/l10n_util.h"
#include "ui/base/ui_base_types.h"
#include "ui/views/border.h"
#include "ui/views/controls/label.h"
#include "ui/views/layout/fill_layout.h"
#include "ui/views/layout/layout_provider.h"
#include "ui/views/widget/widget.h"
namespace ash {
AcceleratorConfirmationDialog::AcceleratorConfirmationDialog(
int window_title_text_id,
int dialog_text_id,
base::OnceClosure on_accept_callback,
base::OnceClosure on_cancel_callback) {
SetModalType(ui::MODAL_TYPE_SYSTEM);
SetTitle(l10n_util::GetStringUTF16(window_title_text_id));
SetButtonLabel(ui::DIALOG_BUTTON_OK,
l10n_util::GetStringUTF16(IDS_ASH_CONTINUE_BUTTON));
SetAcceptCallback(std::move(on_accept_callback));
SetCancelCallback(std::move(on_cancel_callback));
SetLayoutManager(std::make_unique<views::FillLayout>());
SetBorder(views::CreateEmptyBorder(
views::LayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT)));
AddChildView(std::make_unique<views::Label>(
l10n_util::GetStringUTF16(dialog_text_id)));
// Parent the dialog widget to the LockSystemModalContainer to ensure that it
// will get displayed on respective lock/signin or OOBE screen.
SessionControllerImpl* session_controller =
Shell::Get()->session_controller();
int container_id = kShellWindowId_SystemModalContainer;
if (session_controller->IsUserSessionBlocked() ||
session_controller->GetSessionState() ==
session_manager::SessionState::OOBE) {
container_id = kShellWindowId_LockSystemModalContainer;
}
views::Widget* widget = CreateDialogWidget(
this, nullptr,
Shell::GetContainer(Shell::GetPrimaryRootWindow(), container_id));
widget->Show();
}
AcceleratorConfirmationDialog::~AcceleratorConfirmationDialog() = default;
base::WeakPtr<AcceleratorConfirmationDialog>
AcceleratorConfirmationDialog::GetWeakPtr() {
return weak_ptr_factory_.GetWeakPtr();
}
} // namespace ash