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

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: moar better fo' sho' 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..7c926f424cb676794b4c15ebcbf11f606bef3828 100644
--- a/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
+++ b/chrome/browser/ui/cocoa/profiles/user_manager_mac.mm
@@ -6,6 +6,7 @@
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/browser_process.h"
+#include "chrome/browser/global_keyboard_shortcuts_mac.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/browser_dialogs.h"
#import "chrome/browser/ui/cocoa/browser_window_utils.h"
@@ -14,7 +15,9 @@
#include "content/public/browser/native_web_keyboard_event.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_delegate.h"
+#include "third_party/WebKit/public/web/WebInputEvent.h"
groby-ooo-7-16 2014/09/18 20:59:56 nit: transitively included by native_web_keyboard_
noms (inactive) 2014/09/18 21:11:50 Done.
#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 +47,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 +57,22 @@ 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];
+ // Also interested in 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 +123,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