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

Side by Side Diff: content/shell/shell_mac.mm

Issue 10832221: Add keyboard shortcuts for Mac content shell. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #include "content/shell/shell.h" 5 #include "content/shell/shell.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 const CGFloat kURLBarHeight = 24; 92 const CGFloat kURLBarHeight = 24;
93 93
94 // The minimum size of the window's content (in view coordinates) 94 // The minimum size of the window's content (in view coordinates)
95 const CGFloat kMinimumWindowWidth = 400; 95 const CGFloat kMinimumWindowWidth = 400;
96 const CGFloat kMinimumWindowHeight = 300; 96 const CGFloat kMinimumWindowHeight = 300;
97 97
98 void MakeShellButton(NSRect* rect, 98 void MakeShellButton(NSRect* rect,
99 NSString* title, 99 NSString* title,
100 NSView* parent, 100 NSView* parent,
101 int control, 101 int control,
102 NSView* target) { 102 NSView* target,
103 NSString* key,
104 NSUInteger modifier) {
103 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]); 105 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]);
104 [button setTitle:title]; 106 [button setTitle:title];
105 [button setBezelStyle:NSSmallSquareBezelStyle]; 107 [button setBezelStyle:NSSmallSquareBezelStyle];
106 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; 108 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)];
107 [button setTarget:target]; 109 [button setTarget:target];
108 [button setAction:@selector(performAction:)]; 110 [button setAction:@selector(performAction:)];
109 [button setTag:control]; 111 [button setTag:control];
112 [button setKeyEquivalent:key];
113 [button setKeyEquivalentModifierMask:modifier];
110 [parent addSubview:button]; 114 [parent addSubview:button];
111 rect->origin.x += kButtonWidth; 115 rect->origin.x += kButtonWidth;
112 } 116 }
113 117
114 } // namespace 118 } // namespace
115 119
116 namespace content { 120 namespace content {
117 121
118 void Shell::PlatformInitialize() { 122 void Shell::PlatformInitialize() {
119 } 123 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
194 // clean itself up so we don't need to hold a reference. 198 // clean itself up so we don't need to hold a reference.
195 ContentShellWindowDelegate* delegate = 199 ContentShellWindowDelegate* delegate =
196 [[ContentShellWindowDelegate alloc] initWithShell:this]; 200 [[ContentShellWindowDelegate alloc] initWithShell:this];
197 [window_ setDelegate:delegate]; 201 [window_ setDelegate:delegate];
198 202
199 NSRect button_frame = 203 NSRect button_frame =
200 NSMakeRect(0, NSMaxY(initial_window_bounds) - kURLBarHeight, 204 NSMakeRect(0, NSMaxY(initial_window_bounds) - kURLBarHeight,
201 kButtonWidth, kURLBarHeight); 205 kButtonWidth, kURLBarHeight);
202 206
203 MakeShellButton(&button_frame, @"Back", content, IDC_NAV_BACK, 207 MakeShellButton(&button_frame, @"Back", content, IDC_NAV_BACK,
204 (NSView*)delegate); 208 (NSView*)delegate, @"[", NSCommandKeyMask);
205 MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD, 209 MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD,
206 (NSView*)delegate); 210 (NSView*)delegate, @"]", NSCommandKeyMask);
207 MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD, 211 MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD,
208 (NSView*)delegate); 212 (NSView*)delegate, @"r", NSCommandKeyMask);
209 MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP, 213 MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP,
210 (NSView*)delegate); 214 (NSView*)delegate, @".", NSCommandKeyMask);
211 215
212 button_frame.size.width = 216 button_frame.size.width =
213 NSWidth(initial_window_bounds) - NSMinX(button_frame); 217 NSWidth(initial_window_bounds) - NSMinX(button_frame);
214 scoped_nsobject<NSTextField> url_edit_view( 218 scoped_nsobject<NSTextField> url_edit_view(
215 [[NSTextField alloc] initWithFrame:button_frame]); 219 [[NSTextField alloc] initWithFrame:button_frame]);
216 [content addSubview:url_edit_view]; 220 [content addSubview:url_edit_view];
217 [url_edit_view setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; 221 [url_edit_view setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)];
218 [url_edit_view setTarget:delegate]; 222 [url_edit_view setTarget:delegate];
219 [url_edit_view setAction:@selector(takeURLStringValueFrom:)]; 223 [url_edit_view setAction:@selector(takeURLStringValueFrom:)];
220 [[url_edit_view cell] setWraps:NO]; 224 [[url_edit_view cell] setWraps:NO];
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 LoadURL(url); 279 LoadURL(url);
276 } 280 }
277 } 281 }
278 282
279 void Shell::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { 283 void Shell::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
280 if (event.skip_in_browser) 284 if (event.skip_in_browser)
281 return; 285 return;
282 286
283 // The event handling to get this strictly right is a tangle; cheat here a bit 287 // The event handling to get this strictly right is a tangle; cheat here a bit
284 // by just letting the menus have a chance at it. 288 // by just letting the menus have a chance at it.
285 if ([event.os_event type] == NSKeyDown) 289 if ([event.os_event type] == NSKeyDown) {
290 if (([event.os_event modifierFlags] & NSCommandKeyMask) &&
291 [[event.os_event characters] isEqual:@"l"]) {
292 [window_ makeFirstResponder:url_edit_view_];
293 return;
294 }
295
286 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; 296 [[NSApp mainMenu] performKeyEquivalent:event.os_event];
297 }
287 } 298 }
288 299
289 } // namespace content 300 } // namespace content
OLDNEW
« 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