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 ExitFullscreen(); |
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::EnterFullscreen(const GURL& url, bool ask_permission) { |
259 [controller_ setFullscreen:fullscreen]; | 259 [controller_ setFullscreen:YES |
| 260 url:url |
| 261 askPermission:ask_permission]; |
| 262 } |
| 263 |
| 264 void BrowserWindowCocoa::ExitFullscreen() { |
| 265 [controller_ setFullscreen:NO |
| 266 url:GURL() |
| 267 askPermission:NO]; |
260 } | 268 } |
261 | 269 |
262 bool BrowserWindowCocoa::IsFullscreen() const { | 270 bool BrowserWindowCocoa::IsFullscreen() const { |
263 return !![controller_ isFullscreen]; | 271 return !![controller_ isFullscreen]; |
264 } | 272 } |
265 | 273 |
266 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { | 274 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { |
267 return false; | 275 return false; |
268 } | 276 } |
269 | 277 |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
495 } | 503 } |
496 | 504 |
497 void BrowserWindowCocoa::Paste() { | 505 void BrowserWindowCocoa::Paste() { |
498 [NSApp sendAction:@selector(paste:) to:nil from:nil]; | 506 [NSApp sendAction:@selector(paste:) to:nil from:nil]; |
499 } | 507 } |
500 | 508 |
501 void BrowserWindowCocoa::OpenTabpose() { | 509 void BrowserWindowCocoa::OpenTabpose() { |
502 [controller_ openTabpose]; | 510 [controller_ openTabpose]; |
503 } | 511 } |
504 | 512 |
505 void BrowserWindowCocoa::SetPresentationMode(bool presentation_mode) { | 513 void BrowserWindowCocoa::SetPresentationMode(bool presentation_mode, |
506 [controller_ setPresentationMode:presentation_mode]; | 514 const GURL& url, |
| 515 bool ask_permission) { |
| 516 [controller_ setPresentationMode:presentation_mode |
| 517 url:url |
| 518 askPermission:ask_permission]; |
507 } | 519 } |
508 | 520 |
509 bool BrowserWindowCocoa::InPresentationMode() { | 521 bool BrowserWindowCocoa::InPresentationMode() { |
510 return [controller_ inPresentationMode]; | 522 return [controller_ inPresentationMode]; |
511 } | 523 } |
512 | 524 |
513 void BrowserWindowCocoa::ShowInstant(TabContentsWrapper* preview) { | 525 void BrowserWindowCocoa::ShowInstant(TabContentsWrapper* preview) { |
514 [controller_ showInstant:preview->tab_contents()]; | 526 [controller_ showInstant:preview->tab_contents()]; |
515 } | 527 } |
516 | 528 |
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 point.y = NSMaxY(bounds) - rect.bottom(); | 604 point.y = NSMaxY(bounds) - rect.bottom(); |
593 point = [view convertPoint:point toView:nil]; | 605 point = [view convertPoint:point toView:nil]; |
594 point = [[view window] convertBaseToScreen:point]; | 606 point = [[view window] convertBaseToScreen:point]; |
595 | 607 |
596 // |menu| will automatically release itself on close. | 608 // |menu| will automatically release itself on close. |
597 AvatarMenuBubbleController* menu = | 609 AvatarMenuBubbleController* menu = |
598 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ | 610 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ |
599 anchoredAt:point]; | 611 anchoredAt:point]; |
600 [menu showWindow:nil]; | 612 [menu showWindow:nil]; |
601 } | 613 } |
OLD | NEW |