OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" | 5 #import "chrome/browser/ui/cocoa/chrome_command_dispatcher_delegate.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 8 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
9 #include "chrome/browser/ui/browser_commands.h" | 9 #include "chrome/browser/ui/browser_commands.h" |
10 #include "chrome/browser/ui/browser_finder.h" | 10 #include "chrome/browser/ui/browser_finder.h" |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 } | 72 } |
73 | 73 |
74 - (BOOL)eventHandledByExtensionCommand:(NSEvent*)event | 74 - (BOOL)eventHandledByExtensionCommand:(NSEvent*)event |
75 isRedispatch:(BOOL)isRedispatch { | 75 isRedispatch:(BOOL)isRedispatch { |
76 // Some extension commands have higher priority than web content, and some | 76 // Some extension commands have higher priority than web content, and some |
77 // have lower priority. Regardless of whether the event is being redispatched, | 77 // have lower priority. Regardless of whether the event is being redispatched, |
78 // let the extension system try to handle the event. In case this is a | 78 // let the extension system try to handle the event. In case this is a |
79 // redispatched event, [event window] gives the correct window. | 79 // redispatched event, [event window] gives the correct window. |
80 if ([event window]) { | 80 if ([event window]) { |
81 BrowserWindowController* controller = [[event window] windowController]; | 81 BrowserWindowController* controller = [[event window] windowController]; |
82 // |controller| is only set in Cocoa. In toolkit-views extension commands | |
83 // are handled elsewhere. | |
tapted
2015/08/28 05:48:14
elsewhere -> something more specific?
jackhou1
2015/09/01 06:51:05
Done.
| |
82 if ([controller respondsToSelector:@selector(handledByExtensionCommand: | 84 if ([controller respondsToSelector:@selector(handledByExtensionCommand: |
83 priority:)]) { | 85 priority:)]) { |
84 ui::AcceleratorManager::HandlerPriority priority = | 86 ui::AcceleratorManager::HandlerPriority priority = |
85 isRedispatch ? ui::AcceleratorManager::kNormalPriority | 87 isRedispatch ? ui::AcceleratorManager::kNormalPriority |
86 : ui::AcceleratorManager::kHighPriority; | 88 : ui::AcceleratorManager::kHighPriority; |
87 if ([controller handledByExtensionCommand:event priority:priority]) | 89 if ([controller handledByExtensionCommand:event priority:priority]) |
88 return YES; | 90 return YES; |
89 } | 91 } |
90 } | 92 } |
91 return NO; | 93 return NO; |
92 } | 94 } |
93 | 95 |
94 - (BOOL)prePerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window { | 96 - (BOOL)prePerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window { |
95 // Handle per-window shortcuts like cmd-1, but do not handle browser-level | 97 // Handle per-window shortcuts like cmd-1, but do not handle browser-level |
96 // shortcuts like cmd-left (else, cmd-left would do history navigation even | 98 // shortcuts like cmd-left (else, cmd-left would do history navigation even |
97 // if e.g. the Omnibox has focus). | 99 // if e.g. the Omnibox has focus). |
98 return HandleExtraWindowKeyboardShortcut(event, window); | 100 return HandleExtraWindowKeyboardShortcut(event, window); |
99 } | 101 } |
100 | 102 |
101 - (BOOL)postPerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window { | 103 - (BOOL)postPerformKeyEquivalent:(NSEvent*)event window:(NSWindow*)window { |
102 // Handle per-window shortcuts like Esc after giving everybody else a chance | 104 // Handle per-window shortcuts like Esc after giving everybody else a chance |
103 // to handle them | 105 // to handle them |
104 return HandleDelayedWindowKeyboardShortcut(event, window); | 106 return HandleDelayedWindowKeyboardShortcut(event, window); |
105 } | 107 } |
106 | 108 |
107 @end // ChromeCommandDispatchDelegate | 109 @end // ChromeCommandDispatchDelegate |
OLD | NEW |