Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: chrome/browser/chromeos/login/ui/login_web_dialog.cc

Issue 2871073002: cros: Bind hangup red button on remote controller to close web dialog (Closed)
Patch Set: nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/login/ui/login_web_dialog.cc
diff --git a/chrome/browser/chromeos/login/ui/login_web_dialog.cc b/chrome/browser/chromeos/login/ui/login_web_dialog.cc
index fe8506be4ce413baef1317b43c4f2cd6b573a965..f20d1078c0ec1a4f1948327069db11ed1fa4c496 100644
--- a/chrome/browser/chromeos/login/ui/login_web_dialog.cc
+++ b/chrome/browser/chromeos/login/ui/login_web_dialog.cc
@@ -36,6 +36,12 @@ const double kMinimumHeightRatio = 0.25;
base::LazyInstance<std::deque<WebContents*>>::DestructorAtExit
g_web_contents_stack = LAZY_INSTANCE_INITIALIZER;
+// Returns the accelerator which is mapped as hangup button on Chrome OS CFM
+// remote controller to close the dialog.
+ui::Accelerator GetCloseAccelerator() {
+ return ui::Accelerator(ui::VKEY_BROWSER_BACK, ui::EF_SHIFT_DOWN);
+}
+
} // namespace
///////////////////////////////////////////////////////////////////////////////
@@ -53,8 +59,7 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context,
parent_window_(parent_window),
delegate_(delegate),
title_(title),
- url_(url),
- is_open_(false) {
+ url_(url) {
gfx::Rect screen_bounds(CalculateScreenBounds(gfx::Size()));
width_ = static_cast<int>(kDefaultWidthRatio * screen_bounds.width());
height_ = static_cast<int>(kDefaultHeightRatio * screen_bounds.height());
@@ -63,13 +68,14 @@ LoginWebDialog::LoginWebDialog(content::BrowserContext* browser_context,
LoginWebDialog::~LoginWebDialog() {}
void LoginWebDialog::Show() {
+ dialog_window_ = nullptr;
if (parent_window_) {
- chrome::ShowWebDialog(parent_window_, browser_context_, this);
+ dialog_window_ =
+ chrome::ShowWebDialog(parent_window_, browser_context_, this);
} else {
- chrome::ShowWebDialogInContainer(
+ dialog_window_ = chrome::ShowWebDialogInContainer(
SystemTrayClient::GetDialogParentContainerId(), browser_context_, this);
}
- is_open_ = true;
}
void LoginWebDialog::SetDialogSize(int width, int height) {
@@ -128,7 +134,7 @@ void LoginWebDialog::OnDialogShown(content::WebUI* webui,
}
void LoginWebDialog::OnDialogClosed(const std::string& json_retval) {
- is_open_ = false;
+ dialog_window_ = nullptr;
if (delegate_)
delegate_->OnDialogClosed();
delete this;
@@ -170,4 +176,20 @@ bool LoginWebDialog::HandleShouldCreateWebContents() {
return false;
}
+std::vector<ui::Accelerator> LoginWebDialog::GetAccelerators() {
+ return {GetCloseAccelerator()};
+}
+
+bool LoginWebDialog::AcceleratorPressed(const ui::Accelerator& accelerator) {
+ if (!dialog_window_)
+ return false;
+
+ if (GetCloseAccelerator() == accelerator) {
+ views::Widget::GetWidgetForNativeWindow(dialog_window_)->Close();
+ return true;
+ }
+
+ return false;
+}
+
} // namespace chromeos
« no previous file with comments | « chrome/browser/chromeos/login/ui/login_web_dialog.h ('k') | chrome/browser/chromeos/login/ui/login_web_dialog_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698