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 "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h" |
6 | 6 |
7 #include "base/sys_string_conversions.h" | 7 #include "base/sys_string_conversions.h" |
8 #include "chrome/browser/extensions/extension_host.h" | 8 #include "chrome/browser/extensions/extension_host.h" |
9 #include "chrome/browser/ui/cocoa/browser_window_utils.h" | 9 #include "chrome/browser/ui/cocoa/browser_window_utils.h" |
10 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" | 10 #include "chrome/browser/ui/cocoa/extensions/extension_view_mac.h" |
11 #include "chrome/common/extensions/extension.h" | 11 #include "chrome/common/extensions/extension.h" |
12 | 12 |
13 @implementation ShellWindowController | 13 @implementation ShellWindowController |
14 | 14 |
15 @synthesize shellWindow = shellWindow_; | 15 @synthesize shellWindow = shellWindow_; |
16 | 16 |
17 - (void)windowWillClose:(NSNotification*)notification { | 17 - (void)windowWillClose:(NSNotification*)notification { |
18 if (shellWindow_) | 18 if (shellWindow_) |
19 shellWindow_->WindowWillClose(); | 19 shellWindow_->WindowWillClose(); |
20 } | 20 } |
21 | 21 |
22 @end | 22 @end |
23 | 23 |
24 ShellWindowCocoa::ShellWindowCocoa(ExtensionHost* host) | 24 ShellWindowCocoa::ShellWindowCocoa(ExtensionHost* host) |
25 : ShellWindow(host), | 25 : ShellWindow(host), |
26 attention_request_id_(0) { | 26 attention_request_id_(0) { |
27 // TOOD(mihaip): Restore prior window dimensions and positions on relaunch. | 27 // TOOD(mihaip): Restore prior window dimensions and positions on relaunch. |
28 NSRect rect = NSZeroRect; | 28 NSRect rect = NSMakeRect(0, 0, 512, 384); |
29 rect.size.width = host_->extension()->launch_width(); | |
30 rect.size.height = host_->extension()->launch_height(); | |
31 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | | 29 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | |
32 NSMiniaturizableWindowMask | NSResizableWindowMask; | 30 NSMiniaturizableWindowMask | NSResizableWindowMask; |
33 scoped_nsobject<NSWindow> window( | 31 scoped_nsobject<NSWindow> window( |
34 [[NSWindow alloc] initWithContentRect:rect | 32 [[NSWindow alloc] initWithContentRect:rect |
35 styleMask:styleMask | 33 styleMask:styleMask |
36 backing:NSBackingStoreBuffered | 34 backing:NSBackingStoreBuffered |
37 defer:NO]); | 35 defer:NO]); |
38 [window setTitle:base::SysUTF8ToNSString(host->extension()->name())]; | 36 [window setTitle:base::SysUTF8ToNSString(host->extension()->name())]; |
39 [window setContentMinSize: | |
40 NSMakeSize(host_->extension()->launch_min_width(), | |
41 host_->extension()->launch_min_height())]; | |
42 | 37 |
43 NSView* view = host->view()->native_view(); | 38 NSView* view = host->view()->native_view(); |
44 [view setFrame:rect]; | 39 [view setFrame:rect]; |
45 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 40 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
46 [[window contentView] addSubview:view]; | 41 [[window contentView] addSubview:view]; |
47 | 42 |
48 window_controller_.reset( | 43 window_controller_.reset( |
49 [[ShellWindowController alloc] initWithWindow:window.release()]); | 44 [[ShellWindowController alloc] initWithWindow:window.release()]); |
50 [[window_controller_ window] setDelegate:window_controller_]; | 45 [[window_controller_ window] setDelegate:window_controller_]; |
51 [window_controller_ setShellWindow:this]; | 46 [window_controller_ setShellWindow:this]; |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 } | 157 } |
163 | 158 |
164 NSWindow* ShellWindowCocoa::window() const { | 159 NSWindow* ShellWindowCocoa::window() const { |
165 return [window_controller_ window]; | 160 return [window_controller_ window]; |
166 } | 161 } |
167 | 162 |
168 // static | 163 // static |
169 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 164 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
170 return new ShellWindowCocoa(host); | 165 return new ShellWindowCocoa(host); |
171 } | 166 } |
OLD | NEW |