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

Unified Diff: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm

Issue 553133002: [Mac] Add text-editing accelerators to the User Manager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix include Created 6 years, 3 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
diff --git a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
index 957d95ba57bb6b8b04cab3e077f8fa47836a668c..6762cd426429056d340b2f647796c567a01a422e 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
@@ -15,6 +15,7 @@
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
#include "ui/base/l10n/l10n_util_mac.h"
+#include "ui/events/keycodes/keyboard_codes.h"
// Default window size. Taken from the views implementation in
// chrome/browser/ui/views/user_manager_view.cc.
@@ -44,8 +45,7 @@ void HideUserManager() {
// Custom WebContentsDelegate that allows handling of hotkeys.
class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
public:
- UserManagerWebContentsDelegate(ChromeEventProcessingWindow* window)
- : window_(window) {}
+ UserManagerWebContentsDelegate() {}
// WebContentsDelegate implementation. Forwards all unhandled keyboard events
// to the current window.
@@ -55,19 +55,21 @@ class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
if (![BrowserWindowUtils shouldHandleKeyboardEvent:event])
return;
- int commandId = [BrowserWindowUtils getCommandId:event];
+ // -getCommandId returns -1 if the event isn't a chrome accelerator.
+ int chromeCommandId = [BrowserWindowUtils getCommandId:event];
- // Since the User Manager is a "top level" window, only handle close events.
- if (commandId == IDC_CLOSE_WINDOW || commandId == IDC_EXIT) {
- // Not invoking +[BrowserWindowUtils handleKeyboardEvent here], since the
- // window in question is a ConstrainedWindowCustomWindow, not a
- // BrowserWindow.
- [window_ redispatchKeyEvent:event.os_event];
+ // Check for Cmd+A and Cmd+V events that could come from a password field.
+ bool isTextEditingCommand =
+ (event.modifiers & blink::WebInputEvent::MetaKey) &&
+ (event.windowsKeyCode == ui::VKEY_A ||
+ event.windowsKeyCode == ui::VKEY_V);
+
+ // Only handle close window Chrome accelerators and text editing ones.
+ if (chromeCommandId == IDC_CLOSE_WINDOW || chromeCommandId == IDC_EXIT ||
+ isTextEditingCommand) {
+ [[NSApp mainMenu] performKeyEquivalent:event.os_event];
}
}
-
- private:
- ChromeEventProcessingWindow* window_; // Used to redispatch key events.
};
// Window controller for the User Manager view.
@@ -118,7 +120,7 @@ class UserManagerWebContentsDelegate : public content::WebContentsDelegate {
webContents_.reset(content::WebContents::Create(
content::WebContents::CreateParams(profile)));
window.contentView = webContents_->GetNativeView();
- webContentsDelegate_.reset(new UserManagerWebContentsDelegate(window));
+ webContentsDelegate_.reset(new UserManagerWebContentsDelegate());
webContents_->SetDelegate(webContentsDelegate_.get());
DCHECK(window.contentView);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698