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 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 | 348 |
349 void BrowserWindowCocoa::Restore() { | 349 void BrowserWindowCocoa::Restore() { |
350 if (IsMaximized()) | 350 if (IsMaximized()) |
351 [window() zoom:controller_]; // Toggles zoom mode. | 351 [window() zoom:controller_]; // Toggles zoom mode. |
352 else if (IsMinimized()) | 352 else if (IsMinimized()) |
353 [window() deminiaturize:controller_]; | 353 [window() deminiaturize:controller_]; |
354 } | 354 } |
355 | 355 |
356 void BrowserWindowCocoa::EnterFullscreen( | 356 void BrowserWindowCocoa::EnterFullscreen( |
357 const GURL& url, FullscreenExitBubbleType bubble_type) { | 357 const GURL& url, FullscreenExitBubbleType bubble_type) { |
358 // When simplified fullscreen is enabled, always enter normal fullscreen. | 358 [controller_ enterGenericFullscreenForURL:url bubbleType:bubble_type]; |
359 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | |
360 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) { | |
361 if (url.is_empty()) | |
362 [controller_ enterFullscreen]; | |
363 else | |
364 [controller_ enterFullscreenForURL:url bubbleType:bubble_type]; | |
365 return; | |
366 } | |
367 | |
368 [controller_ enterPresentationModeForURL:url | |
369 bubbleType:bubble_type]; | |
370 } | 359 } |
371 | 360 |
372 void BrowserWindowCocoa::ExitFullscreen() { | 361 void BrowserWindowCocoa::ExitFullscreen() { |
373 [controller_ exitFullscreen]; | 362 [controller_ exitGenericFullscreen]; |
374 } | 363 } |
375 | 364 |
376 void BrowserWindowCocoa::UpdateFullscreenExitBubbleContent( | 365 void BrowserWindowCocoa::UpdateFullscreenExitBubbleContent( |
377 const GURL& url, | 366 const GURL& url, |
378 FullscreenExitBubbleType bubble_type) { | 367 FullscreenExitBubbleType bubble_type) { |
379 [controller_ updateFullscreenExitBubbleURL:url bubbleType:bubble_type]; | 368 [controller_ updateFullscreenExitBubbleURL:url bubbleType:bubble_type]; |
380 } | 369 } |
381 | 370 |
382 bool BrowserWindowCocoa::ShouldHideUIForFullscreen() const { | 371 bool BrowserWindowCocoa::ShouldHideUIForFullscreen() const { |
383 // On Mac, fullscreen mode has most normal things (in a slide-down panel). | 372 // On Mac, fullscreen mode has most normal things (in a slide-down panel). |
384 return false; | 373 return false; |
385 } | 374 } |
386 | 375 |
387 bool BrowserWindowCocoa::IsFullscreen() const { | 376 bool BrowserWindowCocoa::IsFullscreen() const { |
388 if ([controller_ inPresentationMode]) | 377 return [controller_ isInOrEnteringAnyFullscreenMode]; |
389 CHECK([controller_ isFullscreen]); // Presentation mode must be fullscreen. | |
390 return [controller_ isFullscreen]; | |
391 } | 378 } |
392 | 379 |
393 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { | 380 bool BrowserWindowCocoa::IsFullscreenBubbleVisible() const { |
394 return false; | 381 return false; |
395 } | 382 } |
396 | 383 |
397 void BrowserWindowCocoa::ConfirmAddSearchProvider( | 384 void BrowserWindowCocoa::ConfirmAddSearchProvider( |
398 TemplateURL* template_url, | 385 TemplateURL* template_url, |
399 Profile* profile) { | 386 Profile* profile) { |
400 // The controller will release itself when the window closes. | 387 // The controller will release itself when the window closes. |
(...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
616 void BrowserWindowCocoa::Paste() { | 603 void BrowserWindowCocoa::Paste() { |
617 [NSApp sendAction:@selector(paste:) to:nil from:nil]; | 604 [NSApp sendAction:@selector(paste:) to:nil from:nil]; |
618 } | 605 } |
619 | 606 |
620 void BrowserWindowCocoa::EnterFullscreenWithChrome() { | 607 void BrowserWindowCocoa::EnterFullscreenWithChrome() { |
621 // This method cannot be called if simplified fullscreen is enabled. | 608 // This method cannot be called if simplified fullscreen is enabled. |
622 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 609 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
623 DCHECK(!command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)); | 610 DCHECK(!command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)); |
624 | 611 |
625 CHECK(chrome::mac::SupportsSystemFullscreen()); | 612 CHECK(chrome::mac::SupportsSystemFullscreen()); |
626 if ([controller_ inPresentationMode]) | 613 [controller_ enterFullscreenWithChrome]; |
627 [controller_ exitPresentationMode]; | |
628 else | |
629 [controller_ enterFullscreen]; | |
630 } | 614 } |
631 | 615 |
632 bool BrowserWindowCocoa::IsFullscreenWithChrome() { | 616 bool BrowserWindowCocoa::IsFullscreenWithChrome() { |
633 // The WithChrome mode does not exist when simplified fullscreen is enabled. | 617 // The WithChrome mode does not exist when simplified fullscreen is enabled. |
634 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 618 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
635 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) | 619 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) |
636 return false; | 620 return false; |
637 return IsFullscreen() && ![controller_ inPresentationMode]; | 621 return IsFullscreen() && ![controller_ inPresentationMode]; |
638 } | 622 } |
639 | 623 |
640 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { | 624 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { |
641 // Presentation mode does not exist if simplified fullscreen is enabled. The | 625 // Presentation mode does not exist if simplified fullscreen is enabled. The |
642 // WithoutChrome mode simply maps to whether or not the window is fullscreen. | 626 // WithoutChrome mode simply maps to whether or not the window is fullscreen. |
643 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 627 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
644 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) | 628 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) |
645 return IsFullscreen(); | 629 return IsFullscreen(); |
646 | 630 |
647 return IsFullscreen() && [controller_ inPresentationMode]; | 631 return IsFullscreen() && [controller_ inPresentationMode]; |
648 } | 632 } |
649 | 633 |
650 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( | 634 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( |
651 const gfx::Rect& bounds) { | 635 const gfx::Rect& bounds) { |
652 // When using Cocoa's System Fullscreen mode, convert popups into tabs. | 636 // When using Cocoa's System Fullscreen mode, convert popups into tabs. |
653 if ([controller_ isInSystemFullscreen]) | 637 if ([controller_ isInOrEnteringAppKitFullscreen]) |
654 return NEW_FOREGROUND_TAB; | 638 return NEW_FOREGROUND_TAB; |
655 return NEW_POPUP; | 639 return NEW_POPUP; |
656 } | 640 } |
657 | 641 |
658 FindBar* BrowserWindowCocoa::CreateFindBar() { | 642 FindBar* BrowserWindowCocoa::CreateFindBar() { |
659 // We could push the AddFindBar() call into the FindBarBridge | 643 // We could push the AddFindBar() call into the FindBarBridge |
660 // constructor or the FindBarCocoaController init, but that makes | 644 // constructor or the FindBarCocoaController init, but that makes |
661 // unit testing difficult, since we would also require a | 645 // unit testing difficult, since we would also require a |
662 // BrowserWindow object. | 646 // BrowserWindow object. |
663 FindBarBridge* bridge = new FindBarBridge(browser_); | 647 FindBarBridge* bridge = new FindBarBridge(browser_); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
758 | 742 |
759 void BrowserWindowCocoa::ShowPageActionPopup( | 743 void BrowserWindowCocoa::ShowPageActionPopup( |
760 const extensions::Extension* extension) { | 744 const extensions::Extension* extension) { |
761 [cocoa_controller() activatePageAction:extension->id()]; | 745 [cocoa_controller() activatePageAction:extension->id()]; |
762 } | 746 } |
763 | 747 |
764 void BrowserWindowCocoa::ShowBrowserActionPopup( | 748 void BrowserWindowCocoa::ShowBrowserActionPopup( |
765 const extensions::Extension* extension) { | 749 const extensions::Extension* extension) { |
766 [cocoa_controller() activateBrowserAction:extension->id()]; | 750 [cocoa_controller() activateBrowserAction:extension->id()]; |
767 } | 751 } |
OLD | NEW |