| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 #include "base/message_loop.h" | 10 #include "base/message_loop.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 127 browser_->OnWindowDidShow(); | 127 browser_->OnWindowDidShow(); |
| 128 } | 128 } |
| 129 | 129 |
| 130 void BrowserWindowCocoa::ShowInactive() { | 130 void BrowserWindowCocoa::ShowInactive() { |
| 131 [window() orderFront:controller_]; | 131 [window() orderFront:controller_]; |
| 132 } | 132 } |
| 133 | 133 |
| 134 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { | 134 void BrowserWindowCocoa::SetBounds(const gfx::Rect& bounds) { |
| 135 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; | 135 gfx::Rect real_bounds = [controller_ enforceMinWindowSize:bounds]; |
| 136 | 136 |
| 137 SetFullscreen(false); | 137 SetFullscreen(false, GURL(), false); |
| 138 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, | 138 NSRect cocoa_bounds = NSMakeRect(real_bounds.x(), 0, |
| 139 real_bounds.width(), | 139 real_bounds.width(), |
| 140 real_bounds.height()); | 140 real_bounds.height()); |
| 141 // Flip coordinates based on the primary screen. | 141 // Flip coordinates based on the primary screen. |
| 142 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 142 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
| 143 cocoa_bounds.origin.y = | 143 cocoa_bounds.origin.y = |
| 144 [screen frame].size.height - real_bounds.height() - real_bounds.y(); | 144 [screen frame].size.height - real_bounds.height() - real_bounds.y(); |
| 145 | 145 |
| 146 [window() setFrame:cocoa_bounds display:YES]; | 146 [window() setFrame:cocoa_bounds display:YES]; |
| 147 } | 147 } |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 } | 248 } |
| 249 | 249 |
| 250 bool BrowserWindowCocoa::IsMaximized() const { | 250 bool BrowserWindowCocoa::IsMaximized() const { |
| 251 return [window() isZoomed]; | 251 return [window() isZoomed]; |
| 252 } | 252 } |
| 253 | 253 |
| 254 bool BrowserWindowCocoa::IsMinimized() const { | 254 bool BrowserWindowCocoa::IsMinimized() const { |
| 255 return [window() isMiniaturized]; | 255 return [window() isMiniaturized]; |
| 256 } | 256 } |
| 257 | 257 |
| 258 void BrowserWindowCocoa::SetFullscreen(bool fullscreen) { | 258 void BrowserWindowCocoa::SetFullscreen(bool fullscreen, const GURL& url, |
| 259 [controller_ setFullscreen:fullscreen]; | 259 bool ask_permission) { |
| 260 [controller_ setFullscreen:fullscreen |
| 261 forURL:url |
| 262 askPermission:ask_permission]; |
| 260 } | 263 } |
| 261 | 264 |
| 262 bool BrowserWindowCocoa::IsFullscreen() const { | 265 bool BrowserWindowCocoa::IsFullscreen() const { |
| 263 return !![controller_ isFullscreen]; | 266 return !![controller_ isFullscreen]; |
| 264 } | 267 } |
| 265 | 268 |
| 266 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { | 269 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { |
| 267 return false; | 270 return false; |
| 268 } | 271 } |
| 269 | 272 |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 495 } | 498 } |
| 496 | 499 |
| 497 void BrowserWindowCocoa::Paste() { | 500 void BrowserWindowCocoa::Paste() { |
| 498 [NSApp sendAction:@selector(paste:) to:nil from:nil]; | 501 [NSApp sendAction:@selector(paste:) to:nil from:nil]; |
| 499 } | 502 } |
| 500 | 503 |
| 501 void BrowserWindowCocoa::OpenTabpose() { | 504 void BrowserWindowCocoa::OpenTabpose() { |
| 502 [controller_ openTabpose]; | 505 [controller_ openTabpose]; |
| 503 } | 506 } |
| 504 | 507 |
| 505 void BrowserWindowCocoa::SetPresentationMode(bool presentation_mode) { | 508 void BrowserWindowCocoa::SetPresentationMode(bool presentation_mode, |
| 506 [controller_ setPresentationMode:presentation_mode]; | 509 const GURL& url, |
| 510 bool ask_permission) { |
| 511 [controller_ setPresentationMode:presentation_mode |
| 512 url:url |
| 513 askPermission:ask_permission]; |
| 507 } | 514 } |
| 508 | 515 |
| 509 bool BrowserWindowCocoa::InPresentationMode() { | 516 bool BrowserWindowCocoa::InPresentationMode() { |
| 510 return [controller_ inPresentationMode]; | 517 return [controller_ inPresentationMode]; |
| 511 } | 518 } |
| 512 | 519 |
| 513 void BrowserWindowCocoa::PrepareForInstant() { | 520 void BrowserWindowCocoa::PrepareForInstant() { |
| 514 // TODO: implement fade as done on windows. | 521 // TODO: implement fade as done on windows. |
| 515 } | 522 } |
| 516 | 523 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 592 NSPoint point = NSMakePoint(rect.right(), rect.bottom()); | 599 NSPoint point = NSMakePoint(rect.right(), rect.bottom()); |
| 593 point = [view convertPoint:point toView:nil]; | 600 point = [view convertPoint:point toView:nil]; |
| 594 point = [[view window] convertBaseToScreen:point]; | 601 point = [[view window] convertBaseToScreen:point]; |
| 595 | 602 |
| 596 // |menu| will automatically release itself on close. | 603 // |menu| will automatically release itself on close. |
| 597 AvatarMenuBubbleController* menu = | 604 AvatarMenuBubbleController* menu = |
| 598 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ | 605 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ |
| 599 anchoredAt:point]; | 606 anchoredAt:point]; |
| 600 [menu showWindow:nil]; | 607 [menu showWindow:nil]; |
| 601 } | 608 } |
| OLD | NEW |