Commit e59bbf24 authored by noms@chromium.org's avatar noms@chromium.org

[Win] Ctrl+W should close the User Manager

BUG=364644
TEST=Start Chrome with --new-profile-management turned on. From the avatar
menu, select "Not <name>". The User Manager should show up. Ctrl+W should
close it, but other accelerators (eg. Ctrl+t) should not work.

Review URL: https://codereview.chromium.org/380763003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282128 0039d316-1c4b-4281-b951-d872f2087c98
parent cea624b2
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
#include "ui/views/layout/fill_layout.h" #include "ui/views/layout/fill_layout.h"
#include "ui/views/view.h" #include "ui/views/view.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
#include "ui/views/window/dialog_client_view.h"
#if defined(OS_WIN) #if defined(OS_WIN)
#include "chrome/browser/shell_integration.h" #include "chrome/browser/shell_integration.h"
...@@ -105,10 +106,17 @@ void UserManagerView::OnGuestProfileCreated( ...@@ -105,10 +106,17 @@ void UserManagerView::OnGuestProfileCreated(
void UserManagerView::Init(Profile* guest_profile, const GURL& url) { void UserManagerView::Init(Profile* guest_profile, const GURL& url) {
web_view_ = new views::WebView(guest_profile); web_view_ = new views::WebView(guest_profile);
SetLayoutManager(new views::FillLayout); web_view_->set_allow_accelerators(true);
AddChildView(web_view_); AddChildView(web_view_);
SetLayoutManager(new views::FillLayout);
AddAccelerator(ui::Accelerator(ui::VKEY_W, ui::EF_CONTROL_DOWN));
DialogDelegate::CreateDialogWidget(this, NULL, NULL); DialogDelegate::CreateDialogWidget(this, NULL, NULL);
// Since the User Manager can be the only top level window, we don't
// want to accidentally quit all of Chrome if the user is just trying to
// unfocus the selected pod in the WebView.
GetDialogClientView()->RemoveAccelerator(
ui::Accelerator(ui::VKEY_ESCAPE, ui::EF_NONE));
#if defined(OS_WIN) #if defined(OS_WIN)
// Set the app id for the task manager to the app id of its parent // Set the app id for the task manager to the app id of its parent
...@@ -123,6 +131,13 @@ void UserManagerView::Init(Profile* guest_profile, const GURL& url) { ...@@ -123,6 +131,13 @@ void UserManagerView::Init(Profile* guest_profile, const GURL& url) {
web_view_->RequestFocus(); web_view_->RequestFocus();
} }
bool UserManagerView::AcceleratorPressed(const ui::Accelerator& accelerator) {
DCHECK_EQ(ui::VKEY_W, accelerator.key_code());
DCHECK_EQ(ui::EF_CONTROL_DOWN, accelerator.modifiers());
GetWidget()->Close();
return true;
}
gfx::Size UserManagerView::GetPreferredSize() const { gfx::Size UserManagerView::GetPreferredSize() const {
return gfx::Size(kWindowWidth, kWindowHeight); return gfx::Size(kWindowWidth, kWindowHeight);
} }
......
...@@ -48,6 +48,7 @@ class UserManagerView : public views::DialogDelegateView { ...@@ -48,6 +48,7 @@ class UserManagerView : public views::DialogDelegateView {
void Init(Profile* guest_profile, const GURL& url); void Init(Profile* guest_profile, const GURL& url);
// views::View: // views::View:
virtual bool AcceleratorPressed(const ui::Accelerator& accelerator) OVERRIDE;
virtual gfx::Size GetPreferredSize() const OVERRIDE; virtual gfx::Size GetPreferredSize() const OVERRIDE;
// views::DialogDelegateView: // views::DialogDelegateView:
......
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