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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/shell_window_cocoa.mm

Issue 10119003: Pull shell window stuff out of ExtensionHost and put in ShellWindow (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Comments Created 8 years, 7 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
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 "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
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::CreateImpl(Profile* profile,
169 return new ShellWindowCocoa(host); 173 const Extension* extension,
174 const GURL& url) {
175 return new ShellWindowCocoa(profile, extension, url);
170 } 176 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/extensions/shell_window_cocoa.h ('k') | chrome/browser/ui/extensions/shell_window.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698