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

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

Issue 10825240: Refactor ShellWindow to separate platform-specific code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: gtk Created 8 years, 4 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 | Annotate | Revision Log
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/mac/mac_util.h" 7 #include "base/mac/mac_util.h"
8 #include "base/sys_string_conversions.h" 8 #include "base/sys_string_conversions.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/ui/cocoa/browser_window_utils.h" 10 #include "chrome/browser/ui/cocoa/browser_window_utils.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 } 114 }
115 - (NSView*)hitTest:(NSPoint)aPoint { 115 - (NSView*)hitTest:(NSPoint)aPoint {
116 return nil; 116 return nil;
117 } 117 }
118 @end 118 @end
119 119
120 @interface NSView (WebContentsView) 120 @interface NSView (WebContentsView)
121 - (void)setMouseDownCanMoveWindow:(BOOL)can_move; 121 - (void)setMouseDownCanMoveWindow:(BOOL)can_move;
122 @end 122 @end
123 123
124 ShellWindowCocoa::ShellWindowCocoa(Profile* profile, 124 ShellWindowCocoa::ShellWindowCocoa(ShellWindow* shell_window,
125 const extensions::Extension* extension,
126 const GURL& url,
127 const ShellWindow::CreateParams& params) 125 const ShellWindow::CreateParams& params)
128 : ShellWindow(profile, extension, url), 126 : shell_window_(shell_window),
129 has_frame_(params.frame == ShellWindow::CreateParams::FRAME_CHROME), 127 has_frame_(params.frame == ShellWindow::CreateParams::FRAME_CHROME),
130 attention_request_id_(0) { 128 attention_request_id_(0) {
131 // Flip coordinates based on the primary screen. 129 // Flip coordinates based on the primary screen.
132 NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame]; 130 NSRect main_screen_rect = [[[NSScreen screens] objectAtIndex:0] frame];
133 NSRect cocoa_bounds = NSMakeRect(params.bounds.x(), 131 NSRect cocoa_bounds = NSMakeRect(params.bounds.x(),
134 NSHeight(main_screen_rect) - params.bounds.y() - params.bounds.height(), 132 NSHeight(main_screen_rect) - params.bounds.y() - params.bounds.height(),
135 params.bounds.width(), params.bounds.height()); 133 params.bounds.width(), params.bounds.height());
136 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask | 134 NSUInteger style_mask = NSTitledWindowMask | NSClosableWindowMask |
137 NSMiniaturizableWindowMask | NSResizableWindowMask | 135 NSMiniaturizableWindowMask | NSResizableWindowMask |
138 NSTexturedBackgroundWindowMask; 136 NSTexturedBackgroundWindowMask;
139 scoped_nsobject<NSWindow> window([[ShellNSWindow alloc] 137 scoped_nsobject<NSWindow> window([[ShellNSWindow alloc]
140 initWithContentRect:cocoa_bounds 138 initWithContentRect:cocoa_bounds
141 styleMask:style_mask 139 styleMask:style_mask
142 backing:NSBackingStoreBuffered 140 backing:NSBackingStoreBuffered
143 defer:NO]); 141 defer:NO]);
144 [window setTitle:base::SysUTF8ToNSString(extension->name())]; 142 [window setTitle:base::SysUTF8ToNSString(extension()->name())];
145 gfx::Size min_size = params.minimum_size; 143 gfx::Size min_size = params.minimum_size;
146 if (min_size.width() || min_size.height()) { 144 if (min_size.width() || min_size.height()) {
147 [window setContentMinSize:NSMakeSize(min_size.width(), min_size.height())]; 145 [window setContentMinSize:NSMakeSize(min_size.width(), min_size.height())];
148 } 146 }
149 gfx::Size max_size = params.maximum_size; 147 gfx::Size max_size = params.maximum_size;
150 if (max_size.width() || max_size.height()) { 148 if (max_size.width() || max_size.height()) {
151 CGFloat max_width = max_size.width() ? max_size.width() : CGFLOAT_MAX; 149 CGFloat max_width = max_size.width() ? max_size.width() : CGFLOAT_MAX;
152 CGFloat max_height = max_size.height() ? max_size.height() : CGFLOAT_MAX; 150 CGFloat max_height = max_size.height() ? max_size.height() : CGFLOAT_MAX;
153 [window setContentMaxSize:NSMakeSize(max_width, max_height)]; 151 [window setContentMaxSize:NSMakeSize(max_width, max_height)];
154 } 152 }
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 NSRect cocoa_bounds = NSMakeRect(checked_bounds.x(), 0, 344 NSRect cocoa_bounds = NSMakeRect(checked_bounds.x(), 0,
347 checked_bounds.width(), 345 checked_bounds.width(),
348 checked_bounds.height()); 346 checked_bounds.height());
349 // Flip coordinates based on the primary screen. 347 // Flip coordinates based on the primary screen.
350 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; 348 NSScreen* screen = [[NSScreen screens] objectAtIndex:0];
351 cocoa_bounds.origin.y = NSHeight([screen frame]) - checked_bounds.bottom(); 349 cocoa_bounds.origin.y = NSHeight([screen frame]) - checked_bounds.bottom();
352 350
353 [window() setFrame:cocoa_bounds display:YES]; 351 [window() setFrame:cocoa_bounds display:YES];
354 } 352 }
355 353
354 void ShellWindowCocoa::UpdateWindowTitle() {
355 // TODO(jeremya): implement.
356 }
357
356 void ShellWindowCocoa::UpdateDraggableRegions( 358 void ShellWindowCocoa::UpdateDraggableRegions(
357 const std::vector<extensions::DraggableRegion>& regions) { 359 const std::vector<extensions::DraggableRegion>& regions) {
358 // Draggable region is not supported for non-frameless window. 360 // Draggable region is not supported for non-frameless window.
359 if (has_frame_) 361 if (has_frame_)
360 return; 362 return;
361 363
362 draggable_regions_ = regions; 364 draggable_regions_ = regions;
363 InstallDraggableRegionViews(); 365 InstallDraggableRegionViews();
364 } 366 }
365 367
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
405 attention_request_id_ = 0; 407 attention_request_id_ = 0;
406 } 408 }
407 } 409 }
408 410
409 bool ShellWindowCocoa::IsAlwaysOnTop() const { 411 bool ShellWindowCocoa::IsAlwaysOnTop() const {
410 return false; 412 return false;
411 } 413 }
412 414
413 void ShellWindowCocoa::WindowWillClose() { 415 void ShellWindowCocoa::WindowWillClose() {
414 [window_controller_ setShellWindow:NULL]; 416 [window_controller_ setShellWindow:NULL];
415 OnNativeClose(); 417 shell_window_->OnNativeClose();
416 } 418 }
417 419
418 void ShellWindowCocoa::WindowDidBecomeKey() { 420 void ShellWindowCocoa::WindowDidBecomeKey() {
419 content::RenderWidgetHostView* rwhv = 421 content::RenderWidgetHostView* rwhv =
420 web_contents()->GetRenderWidgetHostView(); 422 web_contents()->GetRenderWidgetHostView();
421 if (rwhv) 423 if (rwhv)
422 rwhv->SetActive(true); 424 rwhv->SetActive(true);
423 } 425 }
424 426
425 void ShellWindowCocoa::WindowDidResignKey() { 427 void ShellWindowCocoa::WindowDidResignKey() {
(...skipping 11 matching lines...) Expand all
437 } 439 }
438 440
439 ShellWindowCocoa::~ShellWindowCocoa() { 441 ShellWindowCocoa::~ShellWindowCocoa() {
440 } 442 }
441 443
442 NSWindow* ShellWindowCocoa::window() const { 444 NSWindow* ShellWindowCocoa::window() const {
443 return [window_controller_ window]; 445 return [window_controller_ window];
444 } 446 }
445 447
446 // static 448 // static
447 ShellWindow* ShellWindow::CreateImpl(Profile* profile, 449 NativeShellWindow* NativeShellWindow::Create(
448 const extensions::Extension* extension, 450 ShellWindow* shell_window, const ShellWindow::CreateParams& params) {
449 const GURL& url, 451 return new ShellWindowCocoa(shell_window, params);
450 const ShellWindow::CreateParams& params) {
451 return new ShellWindowCocoa(profile, extension, url, params);
452 } 452 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698