OLD | NEW |
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/logging.h" | 9 #include "base/logging.h" |
10 #import "base/memory/scoped_nsobject.h" | 10 #import "base/mac/scoped_nsobject.h" |
11 #include "base/strings/string_piece.h" | 11 #include "base/strings/string_piece.h" |
12 #include "base/strings/sys_string_conversions.h" | 12 #include "base/strings/sys_string_conversions.h" |
13 #include "content/public/browser/native_web_keyboard_event.h" | 13 #include "content/public/browser/native_web_keyboard_event.h" |
14 #include "content/public/browser/web_contents.h" | 14 #include "content/public/browser/web_contents.h" |
15 #include "content/public/browser/web_contents_view.h" | 15 #include "content/public/browser/web_contents_view.h" |
16 #include "content/shell/app/resource.h" | 16 #include "content/shell/app/resource.h" |
17 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
18 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 18 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
19 | 19 |
20 #if !defined(MAC_OS_X_VERSION_10_7) || \ | 20 #if !defined(MAC_OS_X_VERSION_10_7) || \ |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
99 const CGFloat kMinimumWindowWidth = 400; | 99 const CGFloat kMinimumWindowWidth = 400; |
100 const CGFloat kMinimumWindowHeight = 300; | 100 const CGFloat kMinimumWindowHeight = 300; |
101 | 101 |
102 void MakeShellButton(NSRect* rect, | 102 void MakeShellButton(NSRect* rect, |
103 NSString* title, | 103 NSString* title, |
104 NSView* parent, | 104 NSView* parent, |
105 int control, | 105 int control, |
106 NSView* target, | 106 NSView* target, |
107 NSString* key, | 107 NSString* key, |
108 NSUInteger modifier) { | 108 NSUInteger modifier) { |
109 scoped_nsobject<NSButton> button([[NSButton alloc] initWithFrame:*rect]); | 109 base::scoped_nsobject<NSButton> button( |
| 110 [[NSButton alloc] initWithFrame:*rect]); |
110 [button setTitle:title]; | 111 [button setTitle:title]; |
111 [button setBezelStyle:NSSmallSquareBezelStyle]; | 112 [button setBezelStyle:NSSmallSquareBezelStyle]; |
112 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; | 113 [button setAutoresizingMask:(NSViewMaxXMargin | NSViewMinYMargin)]; |
113 [button setTarget:target]; | 114 [button setTarget:target]; |
114 [button setAction:@selector(performAction:)]; | 115 [button setAction:@selector(performAction:)]; |
115 [button setTag:control]; | 116 [button setTag:control]; |
116 [button setKeyEquivalent:key]; | 117 [button setKeyEquivalent:key]; |
117 [button setKeyEquivalentModifierMask:modifier]; | 118 [button setKeyEquivalentModifierMask:modifier]; |
118 [parent addSubview:button]; | 119 [parent addSubview:button]; |
119 rect->origin.x += kButtonWidth; | 120 rect->origin.x += kButtonWidth; |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
215 (NSView*)delegate, @"[", NSCommandKeyMask); | 216 (NSView*)delegate, @"[", NSCommandKeyMask); |
216 MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD, | 217 MakeShellButton(&button_frame, @"Forward", content, IDC_NAV_FORWARD, |
217 (NSView*)delegate, @"]", NSCommandKeyMask); | 218 (NSView*)delegate, @"]", NSCommandKeyMask); |
218 MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD, | 219 MakeShellButton(&button_frame, @"Reload", content, IDC_NAV_RELOAD, |
219 (NSView*)delegate, @"r", NSCommandKeyMask); | 220 (NSView*)delegate, @"r", NSCommandKeyMask); |
220 MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP, | 221 MakeShellButton(&button_frame, @"Stop", content, IDC_NAV_STOP, |
221 (NSView*)delegate, @".", NSCommandKeyMask); | 222 (NSView*)delegate, @".", NSCommandKeyMask); |
222 | 223 |
223 button_frame.size.width = | 224 button_frame.size.width = |
224 NSWidth(initial_window_bounds) - NSMinX(button_frame); | 225 NSWidth(initial_window_bounds) - NSMinX(button_frame); |
225 scoped_nsobject<NSTextField> url_edit_view( | 226 base::scoped_nsobject<NSTextField> url_edit_view( |
226 [[NSTextField alloc] initWithFrame:button_frame]); | 227 [[NSTextField alloc] initWithFrame:button_frame]); |
227 [content addSubview:url_edit_view]; | 228 [content addSubview:url_edit_view]; |
228 [url_edit_view setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; | 229 [url_edit_view setAutoresizingMask:(NSViewWidthSizable | NSViewMinYMargin)]; |
229 [url_edit_view setTarget:delegate]; | 230 [url_edit_view setTarget:delegate]; |
230 [url_edit_view setAction:@selector(takeURLStringValueFrom:)]; | 231 [url_edit_view setAction:@selector(takeURLStringValueFrom:)]; |
231 [[url_edit_view cell] setWraps:NO]; | 232 [[url_edit_view cell] setWraps:NO]; |
232 [[url_edit_view cell] setScrollable:YES]; | 233 [[url_edit_view cell] setScrollable:YES]; |
233 url_edit_view_ = url_edit_view.get(); | 234 url_edit_view_ = url_edit_view.get(); |
234 | 235 |
235 // show the window | 236 // show the window |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 [[event.os_event characters] isEqual:@"l"]) { | 315 [[event.os_event characters] isEqual:@"l"]) { |
315 [window_ makeFirstResponder:url_edit_view_]; | 316 [window_ makeFirstResponder:url_edit_view_]; |
316 return; | 317 return; |
317 } | 318 } |
318 | 319 |
319 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; | 320 [[NSApp mainMenu] performKeyEquivalent:event.os_event]; |
320 } | 321 } |
321 } | 322 } |
322 | 323 |
323 } // namespace content | 324 } // namespace content |
OLD | NEW |