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

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: feedback from xiyuan 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..f13973c3f32f872483898cde0ddccbaa86aad177 100644
--- a/chrome/browser/chromeos/login/ui/login_web_dialog.cc
+++ b/chrome/browser/chromeos/login/ui/login_web_dialog.cc
@@ -53,23 +53,27 @@ 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());
+
+ // Registers 'Shift + Browser Back' accelerator to web dialog, which allows
+ // Chrome OS CFM remote controller using hangup button to close dialog.
+ accelerators_.push_back(
+ ui::Accelerator(ui::VKEY_BROWSER_BACK, ui::EF_SHIFT_DOWN));
xiyuan 2017/05/11 04:48:27 Move this into GetAccelerators and get rid of |acc
Qiang(Joe) Xu 2017/05/12 21:50:45 Done.
}
LoginWebDialog::~LoginWebDialog() {}
void LoginWebDialog::Show() {
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(
sky 2017/05/11 15:04:11 Initialize dialog_window_ to null.
Qiang(Joe) Xu 2017/05/12 21:50:45 Done.
SystemTrayClient::GetDialogParentContainerId(), browser_context_, this);
}
- is_open_ = true;
}
void LoginWebDialog::SetDialogSize(int width, int height) {
@@ -128,7 +132,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 +174,21 @@ bool LoginWebDialog::HandleShouldCreateWebContents() {
return false;
}
+std::vector<ui::Accelerator> LoginWebDialog::GetAccelerators() {
+ return accelerators_;
+}
+
+bool LoginWebDialog::AcceleratorPressed(const ui::Accelerator& accelerator) {
+ if (!dialog_window_)
+ return false;
+
+ if (accelerator.key_code() == ui::VKEY_BROWSER_BACK &&
sky 2017/05/11 15:04:11 Have a function that you use to get the accelerato
Qiang(Joe) Xu 2017/05/12 21:50:45 Done.
+ accelerator.IsShiftDown()) {
+ views::Widget::GetWidgetForNativeWindow(dialog_window_)->Close();
+ return true;
+ }
+
+ return false;
+}
+
} // namespace chromeos

Powered by Google App Engine
This is Rietveld 408576698