| 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 NSRect rect = NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight); |
| 28 NSRect rect = NSZeroRect; | |
| 29 rect.size.width = host_->extension()->launch_width(); | |
| 30 rect.size.height = host_->extension()->launch_height(); | |
| 31 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | | 28 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | |
| 32 NSMiniaturizableWindowMask | NSResizableWindowMask; | 29 NSMiniaturizableWindowMask | NSResizableWindowMask; |
| 33 scoped_nsobject<NSWindow> window( | 30 scoped_nsobject<NSWindow> window( |
| 34 [[NSWindow alloc] initWithContentRect:rect | 31 [[NSWindow alloc] initWithContentRect:rect |
| 35 styleMask:styleMask | 32 styleMask:styleMask |
| 36 backing:NSBackingStoreBuffered | 33 backing:NSBackingStoreBuffered |
| 37 defer:NO]); | 34 defer:NO]); |
| 38 [window setTitle:base::SysUTF8ToNSString(host->extension()->name())]; | 35 [window setTitle:base::SysUTF8ToNSString(host->extension()->name())]; |
| 39 [window setContentMinSize: | |
| 40 NSMakeSize(host_->extension()->launch_min_width(), | |
| 41 host_->extension()->launch_min_height())]; | |
| 42 | 36 |
| 43 NSView* view = host->view()->native_view(); | 37 NSView* view = host->view()->native_view(); |
| 44 [view setFrame:rect]; | 38 [view setFrame:rect]; |
| 45 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 39 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 46 [[window contentView] addSubview:view]; | 40 [[window contentView] addSubview:view]; |
| 47 | 41 |
| 48 window_controller_.reset( | 42 window_controller_.reset( |
| 49 [[ShellWindowController alloc] initWithWindow:window.release()]); | 43 [[ShellWindowController alloc] initWithWindow:window.release()]); |
| 50 [[window_controller_ window] setDelegate:window_controller_]; | 44 [[window_controller_ window] setDelegate:window_controller_]; |
| 51 [window_controller_ setShellWindow:this]; | 45 [window_controller_ setShellWindow:this]; |
| (...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 } | 156 } |
| 163 | 157 |
| 164 NSWindow* ShellWindowCocoa::window() const { | 158 NSWindow* ShellWindowCocoa::window() const { |
| 165 return [window_controller_ window]; | 159 return [window_controller_ window]; |
| 166 } | 160 } |
| 167 | 161 |
| 168 // static | 162 // static |
| 169 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 163 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { |
| 170 return new ShellWindowCocoa(host); | 164 return new ShellWindowCocoa(host); |
| 171 } | 165 } |
| OLD | NEW |