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

Side by Side Diff: chrome/browser/ui/cocoa/chrome_event_processing_window.mm

Issue 388313002: mac: Allow WebContents key handling to supplant extension overrides of the bookmark shortcut. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Comments from yoz and shess. Created 6 years, 5 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_event_processing_window.h" 5 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/ui/cocoa/browser_command_executor.h" 8 #import "chrome/browser/ui/cocoa/browser_command_executor.h"
9 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" 9 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h"
10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 return [self handleExtraKeyboardShortcut:event 54 return [self handleExtraKeyboardShortcut:event
55 fromTable:CommandForDelayedWindowKeyboardShortcut]; 55 fromTable:CommandForDelayedWindowKeyboardShortcut];
56 } 56 }
57 57
58 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event { 58 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event {
59 return [self handleExtraKeyboardShortcut:event 59 return [self handleExtraKeyboardShortcut:event
60 fromTable:CommandForBrowserKeyboardShortcut]; 60 fromTable:CommandForBrowserKeyboardShortcut];
61 } 61 }
62 62
63 - (BOOL)performKeyEquivalent:(NSEvent*)event { 63 - (BOOL)performKeyEquivalent:(NSEvent*)event {
64 if (redispatchingEvent_) 64 // Some extension commands have higher priority than web content, and some
65 return NO; 65 // have lower priority. Regardless of whether the event is being
66 66 // redispatched, let the extension system try to handle the event.
67 NSWindow* window = event.window; 67 NSWindow* window = event.window;
68 if (window) { 68 if (window) {
69 BrowserWindowController* controller = [window windowController]; 69 BrowserWindowController* controller = [window windowController];
70 if ([controller respondsToSelector:@selector(handledByExtensionCommand:)]) { 70 if ([controller respondsToSelector:@selector(handledByExtensionCommand:
71 if ([controller handledByExtensionCommand:event]) 71 priority:)]) {
72 ui::AcceleratorManager::HandlerPriority priority =
73 redispatchingEvent_ ? ui::AcceleratorManager::kNormalPriority
74 : ui::AcceleratorManager::kHighPriority;
75 if ([controller handledByExtensionCommand:event priority:priority])
72 return YES; 76 return YES;
73 } 77 }
74 } 78 }
75 79
80 if (redispatchingEvent_)
81 return NO;
82
76 // Give the web site a chance to handle the event. If it doesn't want to 83 // Give the web site a chance to handle the event. If it doesn't want to
77 // handle it, it will call us back with one of the |handle*| methods above. 84 // handle it, it will call us back with one of the |handle*| methods above.
78 NSResponder* r = [self firstResponder]; 85 NSResponder* r = [self firstResponder];
79 if ([r conformsToProtocol:@protocol(RenderWidgetHostViewMacBase)]) 86 if ([r conformsToProtocol:@protocol(RenderWidgetHostViewMacBase)])
80 return [r performKeyEquivalent:event]; 87 return [r performKeyEquivalent:event];
81 88
82 // If the delegate does not implement the BrowserCommandExecutor protocol, 89 // If the delegate does not implement the BrowserCommandExecutor protocol,
83 // then we don't need to handle browser specific shortcut keys. 90 // then we don't need to handle browser specific shortcut keys.
84 if (![[self delegate] conformsToProtocol:@protocol(BrowserCommandExecutor)]) 91 if (![[self delegate] conformsToProtocol:@protocol(BrowserCommandExecutor)])
85 return [super performKeyEquivalent:event]; 92 return [super performKeyEquivalent:event];
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 timestamp:[event timestamp] 171 timestamp:[event timestamp]
165 windowNumber:[window windowNumber] 172 windowNumber:[window windowNumber]
166 context:nil 173 context:nil
167 characters:eventCharacters 174 characters:eventCharacters
168 charactersIgnoringModifiers:eventUnmodCharacters 175 charactersIgnoringModifiers:eventUnmodCharacters
169 isARepeat:eventIsARepeat 176 isARepeat:eventIsARepeat
170 keyCode:[event keyCode]]; 177 keyCode:[event keyCode]];
171 } 178 }
172 179
173 @end // ChromeEventProcessingWindow 180 @end // ChromeEventProcessingWindow
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698