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

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

Issue 344008: Implemented most of HtmlDialogWindowController, which is a Cocoa port (Closed)
Patch Set: Added TODOs. Created 11 years, 1 month 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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/cocoa/chrome_event_processing_window.h" 5 #import "chrome/browser/cocoa/chrome_event_processing_window.h"
6 6
7 #include "base/logging.h" 7 #include "base/logging.h"
8 #import "chrome/browser/cocoa/browser_window_controller.h" 8 #import "chrome/browser/cocoa/browser_command_executor.h"
9 #import "chrome/browser/cocoa/browser_frame_view.h" 9 #import "chrome/browser/cocoa/browser_frame_view.h"
10 #import "chrome/browser/cocoa/tab_strip_controller.h" 10 #import "chrome/browser/cocoa/tab_strip_controller.h"
11 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h" 11 #import "chrome/browser/renderer_host/render_widget_host_view_mac.h"
12 #include "chrome/browser/global_keyboard_shortcuts_mac.h" 12 #include "chrome/browser/global_keyboard_shortcuts_mac.h"
13 13
14 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int); 14 typedef int (*KeyToCommandMapper)(bool, bool, bool, bool, int);
15 15
16 @implementation ChromeEventProcessingWindow 16 @implementation ChromeEventProcessingWindow
17 17
18 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event fromTable: 18 - (BOOL)handleExtraKeyboardShortcut:(NSEvent*)event fromTable:
19 (KeyToCommandMapper)commandForKeyboardShortcut { 19 (KeyToCommandMapper)commandForKeyboardShortcut {
20 // Extract info from |event|. 20 // Extract info from |event|.
21 NSUInteger modifers = [event modifierFlags]; 21 NSUInteger modifers = [event modifierFlags];
22 const bool cmdKey = modifers & NSCommandKeyMask; 22 const bool cmdKey = modifers & NSCommandKeyMask;
23 const bool shiftKey = modifers & NSShiftKeyMask; 23 const bool shiftKey = modifers & NSShiftKeyMask;
24 const bool cntrlKey = modifers & NSControlKeyMask; 24 const bool cntrlKey = modifers & NSControlKeyMask;
25 const bool optKey = modifers & NSAlternateKeyMask; 25 const bool optKey = modifers & NSAlternateKeyMask;
26 const int keyCode = [event keyCode]; 26 const int keyCode = [event keyCode];
27 27
28 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, optKey, 28 int cmdNum = commandForKeyboardShortcut(cmdKey, shiftKey, cntrlKey, optKey,
29 keyCode); 29 keyCode);
30 30
31 BrowserWindowController* controller =
32 (BrowserWindowController*)[self delegate];
33 // A bit of sanity.
34 DCHECK([controller isKindOfClass:[BrowserWindowController class]]);
35 DCHECK([controller respondsToSelector:@selector(executeCommand:)]);
36
37 if (cmdNum != -1) { 31 if (cmdNum != -1) {
38 [controller executeCommand:cmdNum]; 32 id executor = [self delegate];
33 // A bit of sanity.
34 DCHECK([executor conformsToProtocol:@protocol(BrowserCommandExecutor)]);
35 DCHECK([executor respondsToSelector:@selector(executeCommand:)]);
36 [executor executeCommand:cmdNum];
39 return YES; 37 return YES;
40 } 38 }
41 return NO; 39 return NO;
42 } 40 }
43 41
44 - (BOOL)handleExtraWindowKeyboardShortcut:(NSEvent*)event { 42 - (BOOL)handleExtraWindowKeyboardShortcut:(NSEvent*)event {
45 return [self handleExtraKeyboardShortcut:event 43 return [self handleExtraKeyboardShortcut:event
46 fromTable:CommandForWindowKeyboardShortcut]; 44 fromTable:CommandForWindowKeyboardShortcut];
47 } 45 }
48 46
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
103 101
104 - (void)sendEvent:(NSEvent*)event { 102 - (void)sendEvent:(NSEvent*)event {
105 if (!redispatchingEvent_) 103 if (!redispatchingEvent_)
106 [super sendEvent:event]; 104 [super sendEvent:event];
107 else 105 else
108 eventHandled_ = NO; 106 eventHandled_ = NO;
109 } 107 }
110 108
111 @end // ChromeEventProcessingWindow 109 @end // ChromeEventProcessingWindow
112 110
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/chrome_event_processing_window_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698