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/browser_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #import "base/mac/sdk_forward_declarations.h" | 10 #import "base/mac/sdk_forward_declarations.h" |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
203 } | 203 } |
204 | 204 |
205 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { | 205 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { |
206 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; | 206 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; |
207 | 207 |
208 ExitFullscreen(); | 208 ExitFullscreen(); |
209 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, | 209 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, |
210 real_bounds.width(), | 210 real_bounds.width(), |
211 real_bounds.height()); | 211 real_bounds.height()); |
212 // Flip coordinates based on the primary screen. | 212 // Flip coordinates based on the primary screen. |
213 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 213 NSScreen* screen = [[NSScreen screens] firstObject]; |
214 cocoa_bounds.origin.y = | 214 cocoa_bounds.origin.y = |
215 NSHeight([screen frame]) - real_bounds.height() - real_bounds.y(); | 215 NSHeight([screen frame]) - real_bounds.height() - real_bounds.y(); |
216 | 216 |
217 [window() setFrame:cocoa_bounds display:YES]; | 217 [window() setFrame:cocoa_bounds display:YES]; |
218 } | 218 } |
219 | 219 |
220 // Callers assume that this doesn't immediately delete the Browser object. | 220 // Callers assume that this doesn't immediately delete the Browser object. |
221 // The controller implementing the window delegate methods called from | 221 // The controller implementing the window delegate methods called from |
222 // |-performClose:| must take precautions to ensure that. | 222 // |-performClose:| must take precautions to ensure that. |
223 void BrowserWindowCocoa::Close() { | 223 void BrowserWindowCocoa::Close() { |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 // way views and GTK do. | 341 // way views and GTK do. |
342 // See http://crbug.com/340720 for discussion. | 342 // See http://crbug.com/340720 for discussion. |
343 } | 343 } |
344 | 344 |
345 void BrowserWindowCocoa::ZoomChangedForActiveTab(bool can_show_bubble) { | 345 void BrowserWindowCocoa::ZoomChangedForActiveTab(bool can_show_bubble) { |
346 [controller_ zoomChangedForActiveTab:can_show_bubble ? YES : NO]; | 346 [controller_ zoomChangedForActiveTab:can_show_bubble ? YES : NO]; |
347 } | 347 } |
348 | 348 |
349 gfx::Rect BrowserWindowCocoa::GetRestoredBounds() const { | 349 gfx::Rect BrowserWindowCocoa::GetRestoredBounds() const { |
350 // Flip coordinates based on the primary screen. | 350 // Flip coordinates based on the primary screen. |
351 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 351 NSScreen* screen = [[NSScreen screens] firstObject]; |
352 NSRect frame = [controller_ regularWindowFrame]; | 352 NSRect frame = [controller_ regularWindowFrame]; |
353 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); | 353 gfx::Rect bounds(frame.origin.x, 0, NSWidth(frame), NSHeight(frame)); |
354 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame)); | 354 bounds.set_y(NSHeight([screen frame]) - NSMaxY(frame)); |
355 return bounds; | 355 return bounds; |
356 } | 356 } |
357 | 357 |
358 ui::WindowShowState BrowserWindowCocoa::GetRestoredState() const { | 358 ui::WindowShowState BrowserWindowCocoa::GetRestoredState() const { |
359 if (IsMaximized()) | 359 if (IsMaximized()) |
360 return ui::SHOW_STATE_MAXIMIZED; | 360 return ui::SHOW_STATE_MAXIMIZED; |
361 if (IsMinimized()) | 361 if (IsMinimized()) |
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
854 void BrowserWindowCocoa::UnhideDownloadShelf() { | 854 void BrowserWindowCocoa::UnhideDownloadShelf() { |
855 GetDownloadShelf()->Unhide(); | 855 GetDownloadShelf()->Unhide(); |
856 } | 856 } |
857 | 857 |
858 void BrowserWindowCocoa::HideDownloadShelf() { | 858 void BrowserWindowCocoa::HideDownloadShelf() { |
859 GetDownloadShelf()->Hide(); | 859 GetDownloadShelf()->Hide(); |
860 StatusBubble* statusBubble = GetStatusBubble(); | 860 StatusBubble* statusBubble = GetStatusBubble(); |
861 if (statusBubble) | 861 if (statusBubble) |
862 statusBubble->Hide(); | 862 statusBubble->Hide(); |
863 } | 863 } |
OLD | NEW |