| 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/profiles/profile.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 #include "content/public/browser/web_contents.h" |
| 13 #include "content/public/browser/web_contents_view.h" |
| 12 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" | 14 #import "ui/base/cocoa/underlay_opengl_hosting_window.h" |
| 13 | 15 |
| 14 @implementation ShellWindowController | 16 @implementation ShellWindowController |
| 15 | 17 |
| 16 @synthesize shellWindow = shellWindow_; | 18 @synthesize shellWindow = shellWindow_; |
| 17 | 19 |
| 18 - (void)windowWillClose:(NSNotification*)notification { | 20 - (void)windowWillClose:(NSNotification*)notification { |
| 19 if (shellWindow_) | 21 if (shellWindow_) |
| 20 shellWindow_->WindowWillClose(); | 22 shellWindow_->WindowWillClose(); |
| 21 } | 23 } |
| 22 | 24 |
| 23 @end | 25 @end |
| 24 | 26 |
| 25 ShellWindowCocoa::ShellWindowCocoa(ExtensionHost* host) | 27 ShellWindowCocoa::ShellWindowCocoa(Profile* profile, |
| 26 : ShellWindow(host), | 28 const Extension* extension, |
| 29 const GURL& url) |
| 30 : ShellWindow(profile, extension, url), |
| 27 attention_request_id_(0) { | 31 attention_request_id_(0) { |
| 28 NSRect rect = NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight); | 32 NSRect rect = NSMakeRect(0, 0, kDefaultWidth, kDefaultHeight); |
| 29 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | | 33 NSUInteger styleMask = NSTitledWindowMask | NSClosableWindowMask | |
| 30 NSMiniaturizableWindowMask | NSResizableWindowMask; | 34 NSMiniaturizableWindowMask | NSResizableWindowMask; |
| 31 scoped_nsobject<NSWindow> window([[UnderlayOpenGLHostingWindow alloc] | 35 scoped_nsobject<NSWindow> window([[UnderlayOpenGLHostingWindow alloc] |
| 32 initWithContentRect:rect | 36 initWithContentRect:rect |
| 33 styleMask:styleMask | 37 styleMask:styleMask |
| 34 backing:NSBackingStoreBuffered | 38 backing:NSBackingStoreBuffered |
| 35 defer:NO]); | 39 defer:NO]); |
| 36 [window setTitle:base::SysUTF8ToNSString(host->extension()->name())]; | 40 [window setTitle:base::SysUTF8ToNSString(extension->name())]; |
| 37 | 41 |
| 38 NSView* view = host->view()->native_view(); | 42 NSView* view = web_contents()->GetView()->GetNativeView(); |
| 39 [view setFrame:rect]; | 43 [view setFrame:rect]; |
| 40 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; | 44 [view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable]; |
| 41 [[window contentView] addSubview:view]; | 45 [[window contentView] addSubview:view]; |
| 42 | 46 |
| 43 window_controller_.reset( | 47 window_controller_.reset( |
| 44 [[ShellWindowController alloc] initWithWindow:window.release()]); | 48 [[ShellWindowController alloc] initWithWindow:window.release()]); |
| 45 [[window_controller_ window] setDelegate:window_controller_]; | 49 [[window_controller_ window] setDelegate:window_controller_]; |
| 46 [window_controller_ setShellWindow:this]; | 50 [window_controller_ setShellWindow:this]; |
| 47 [window_controller_ showWindow:nil]; | 51 [window_controller_ showWindow:nil]; |
| 48 } | 52 } |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 158 } | 162 } |
| 159 | 163 |
| 160 ShellWindowCocoa::~ShellWindowCocoa() { | 164 ShellWindowCocoa::~ShellWindowCocoa() { |
| 161 } | 165 } |
| 162 | 166 |
| 163 NSWindow* ShellWindowCocoa::window() const { | 167 NSWindow* ShellWindowCocoa::window() const { |
| 164 return [window_controller_ window]; | 168 return [window_controller_ window]; |
| 165 } | 169 } |
| 166 | 170 |
| 167 // static | 171 // static |
| 168 ShellWindow* ShellWindow::CreateShellWindow(ExtensionHost* host) { | 172 ShellWindow* ShellWindow::CreateShellWindow(Profile* profile, |
| 169 return new ShellWindowCocoa(host); | 173 const Extension* extension, |
| 174 const GURL& url) { |
| 175 return new ShellWindowCocoa(profile, extension, url); |
| 170 } | 176 } |
| OLD | NEW |