| 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_ enterHTML5FullscreenForURL: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_ exitAnyFullscreen]; |
| 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_ isInAnyFullscreenMode]; |
| 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 216 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 617 void BrowserWindowCocoa::Paste() { | 604 void BrowserWindowCocoa::Paste() { |
| 618 [NSApp sendAction:@selector(paste:) to:nil from:nil]; | 605 [NSApp sendAction:@selector(paste:) to:nil from:nil]; |
| 619 } | 606 } |
| 620 | 607 |
| 621 void BrowserWindowCocoa::EnterFullscreenWithChrome() { | 608 void BrowserWindowCocoa::EnterFullscreenWithChrome() { |
| 622 // This method cannot be called if simplified fullscreen is enabled. | 609 // This method cannot be called if simplified fullscreen is enabled. |
| 623 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 610 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 624 DCHECK(!command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)); | 611 DCHECK(!command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)); |
| 625 | 612 |
| 626 CHECK(chrome::mac::SupportsSystemFullscreen()); | 613 CHECK(chrome::mac::SupportsSystemFullscreen()); |
| 627 if ([controller_ inPresentationMode]) | 614 [controller_ enterFullscreenWithChrome]; |
| 628 [controller_ exitPresentationMode]; | |
| 629 else | |
| 630 [controller_ enterFullscreen]; | |
| 631 } | 615 } |
| 632 | 616 |
| 633 bool BrowserWindowCocoa::IsFullscreenWithChrome() { | 617 bool BrowserWindowCocoa::IsFullscreenWithChrome() { |
| 634 // The WithChrome mode does not exist when simplified fullscreen is enabled. | 618 // The WithChrome mode does not exist when simplified fullscreen is enabled. |
| 635 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 619 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 636 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) | 620 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) |
| 637 return false; | 621 return false; |
| 638 return IsFullscreen() && ![controller_ inPresentationMode]; | 622 return IsFullscreen() && ![controller_ inPresentationMode]; |
| 639 } | 623 } |
| 640 | 624 |
| 641 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { | 625 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { |
| 642 // Presentation mode does not exist if simplified fullscreen is enabled. The | 626 // Presentation mode does not exist if simplified fullscreen is enabled. The |
| 643 // WithoutChrome mode simply maps to whether or not the window is fullscreen. | 627 // WithoutChrome mode simply maps to whether or not the window is fullscreen. |
| 644 const CommandLine* command_line = CommandLine::ForCurrentProcess(); | 628 const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
| 645 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) | 629 if (command_line->HasSwitch(switches::kEnableSimplifiedFullscreen)) |
| 646 return IsFullscreen(); | 630 return IsFullscreen(); |
| 647 | 631 |
| 648 return IsFullscreen() && [controller_ inPresentationMode]; | 632 return IsFullscreen() && [controller_ inPresentationMode]; |
| 649 } | 633 } |
| 650 | 634 |
| 651 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( | 635 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( |
| 652 const gfx::Rect& bounds) { | 636 const gfx::Rect& bounds) { |
| 653 // When using Cocoa's System Fullscreen mode, convert popups into tabs. | 637 // When using Cocoa's System Fullscreen mode, convert popups into tabs. |
| 654 if ([controller_ isInSystemFullscreen]) | 638 if ([controller_ isInAppKitFullscreen]) |
| 655 return NEW_FOREGROUND_TAB; | 639 return NEW_FOREGROUND_TAB; |
| 656 return NEW_POPUP; | 640 return NEW_POPUP; |
| 657 } | 641 } |
| 658 | 642 |
| 659 FindBar* BrowserWindowCocoa::CreateFindBar() { | 643 FindBar* BrowserWindowCocoa::CreateFindBar() { |
| 660 // We could push the AddFindBar() call into the FindBarBridge | 644 // We could push the AddFindBar() call into the FindBarBridge |
| 661 // constructor or the FindBarCocoaController init, but that makes | 645 // constructor or the FindBarCocoaController init, but that makes |
| 662 // unit testing difficult, since we would also require a | 646 // unit testing difficult, since we would also require a |
| 663 // BrowserWindow object. | 647 // BrowserWindow object. |
| 664 FindBarBridge* bridge = new FindBarBridge(browser_); | 648 FindBarBridge* bridge = new FindBarBridge(browser_); |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 749 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) | 733 if (browser_->bookmark_bar_state() != BookmarkBar::DETACHED) |
| 750 return 0; | 734 return 0; |
| 751 return 40; | 735 return 40; |
| 752 } | 736 } |
| 753 | 737 |
| 754 void BrowserWindowCocoa::ExecuteExtensionCommand( | 738 void BrowserWindowCocoa::ExecuteExtensionCommand( |
| 755 const extensions::Extension* extension, | 739 const extensions::Extension* extension, |
| 756 const extensions::Command& command) { | 740 const extensions::Command& command) { |
| 757 [cocoa_controller() executeExtensionCommand:extension->id() command:command]; | 741 [cocoa_controller() executeExtensionCommand:extension->id() command:command]; |
| 758 } | 742 } |
| OLD | NEW |