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

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

Issue 10824307: Port Extension Commands to Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 8 years, 4 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 | Annotate | Revision Log
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/tabs/tab_strip_controller.h" 10 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h"
10 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 11 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
11 #import "content/public/browser/render_widget_host_view_mac_base.h" 12 #import "content/public/browser/render_widget_host_view_mac_base.h"
12 13
13 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int, unichar); 14 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int, unichar);
14 15
15 @interface ChromeEventProcessingWindow () 16 @interface ChromeEventProcessingWindow ()
16 // Duplicate the given key event, but changing the associated window. 17 // Duplicate the given key event, but changing the associated window.
17 - (NSEvent*)keyEventForWindow:(NSWindow*)window fromKeyEvent:(NSEvent*)event; 18 - (NSEvent*)keyEventForWindow:(NSWindow*)window fromKeyEvent:(NSEvent*)event;
18 @end 19 @end
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 57
57 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event { 58 - (BOOL)handleExtraBrowserKeyboardShortcut:(NSEvent*)event {
58 return [self handleExtraKeyboardShortcut:event 59 return [self handleExtraKeyboardShortcut:event
59 fromTable:CommandForBrowserKeyboardShortcut]; 60 fromTable:CommandForBrowserKeyboardShortcut];
60 } 61 }
61 62
62 - (BOOL)performKeyEquivalent:(NSEvent*)event { 63 - (BOOL)performKeyEquivalent:(NSEvent*)event {
63 if (redispatchingEvent_) 64 if (redispatchingEvent_)
64 return NO; 65 return NO;
65 66
67 NSWindow* window = event.window;
68 if (window) {
69 BrowserWindowController* controller = [window windowController];
70 if ([controller respondsToSelector:@selector(handledByExtensionCommand:)]) {
71 if ([controller handledByExtensionCommand:event])
72 return YES;
73 }
74 }
75
66 // Give the web site a chance to handle the event. If it doesn't want to 76 // Give the web site a chance to handle the event. If it doesn't want to
67 // handle it, it will call us back with one of the |handle*| methods above. 77 // handle it, it will call us back with one of the |handle*| methods above.
68 NSResponder* r = [self firstResponder]; 78 NSResponder* r = [self firstResponder];
69 if ([r conformsToProtocol:@protocol(RenderWidgetHostViewMacBase)]) 79 if ([r conformsToProtocol:@protocol(RenderWidgetHostViewMacBase)])
70 return [r performKeyEquivalent:event]; 80 return [r performKeyEquivalent:event];
71 81
72 // If the delegate does not implement the BrowserCommandExecutor protocol, 82 // If the delegate does not implement the BrowserCommandExecutor protocol,
73 // then we don't need to handle browser specific shortcut keys. 83 // then we don't need to handle browser specific shortcut keys.
74 if (![[self delegate] conformsToProtocol:@protocol(BrowserCommandExecutor)]) 84 if (![[self delegate] conformsToProtocol:@protocol(BrowserCommandExecutor)])
75 return [super performKeyEquivalent:event]; 85 return [super performKeyEquivalent:event];
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 timestamp:[event timestamp] 164 timestamp:[event timestamp]
155 windowNumber:[window windowNumber] 165 windowNumber:[window windowNumber]
156 context:nil 166 context:nil
157 characters:eventCharacters 167 characters:eventCharacters
158 charactersIgnoringModifiers:eventUnmodCharacters 168 charactersIgnoringModifiers:eventUnmodCharacters
159 isARepeat:eventIsARepeat 169 isARepeat:eventIsARepeat
160 keyCode:[event keyCode]]; 170 keyCode:[event keyCode]];
161 } 171 }
162 172
163 @end // ChromeEventProcessingWindow 173 @end // ChromeEventProcessingWindow
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698