| 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/debug/crash_logging.h" | 9 #include "base/debug/crash_logging.h" |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| 11 #include "base/mac/mac_util.h" | 11 #include "base/mac/mac_util.h" |
| 12 #include "base/message_loop.h" | 12 #include "base/message_loop.h" |
| 13 #include "base/prefs/pref_service.h" | 13 #include "base/prefs/pref_service.h" |
| 14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
| 15 #include "base/strings/sys_string_conversions.h" | 15 #include "base/strings/sys_string_conversions.h" |
| 16 #include "chrome/app/chrome_command_ids.h" | 16 #include "chrome/app/chrome_command_ids.h" |
| 17 #include "chrome/browser/download/download_shelf.h" | 17 #include "chrome/browser/download/download_shelf.h" |
| 18 #include "chrome/browser/extensions/tab_helper.h" | 18 #include "chrome/browser/extensions/tab_helper.h" |
| 19 #include "chrome/browser/fullscreen.h" |
| 19 #include "chrome/browser/password_manager/password_manager.h" | 20 #include "chrome/browser/password_manager/password_manager.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 21 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/shell_integration.h" | 22 #include "chrome/browser/shell_integration.h" |
| 22 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" | 23 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" |
| 23 #include "chrome/browser/ui/browser.h" | 24 #include "chrome/browser/ui/browser.h" |
| 24 #include "chrome/browser/ui/browser_command_controller.h" | 25 #include "chrome/browser/ui/browser_command_controller.h" |
| 25 #include "chrome/browser/ui/browser_commands.h" | 26 #include "chrome/browser/ui/browser_commands.h" |
| 26 #include "chrome/browser/ui/browser_list.h" | 27 #include "chrome/browser/ui/browser_list.h" |
| 27 #include "chrome/browser/ui/browser_window_state.h" | 28 #include "chrome/browser/ui/browser_window_state.h" |
| 28 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 29 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
| (...skipping 589 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 | 619 |
| 619 void BrowserWindowCocoa::Paste() { | 620 void BrowserWindowCocoa::Paste() { |
| 620 [NSApp sendAction:@selector(paste:) to:nil from:nil]; | 621 [NSApp sendAction:@selector(paste:) to:nil from:nil]; |
| 621 } | 622 } |
| 622 | 623 |
| 623 void BrowserWindowCocoa::OpenTabpose() { | 624 void BrowserWindowCocoa::OpenTabpose() { |
| 624 [controller_ openTabpose]; | 625 [controller_ openTabpose]; |
| 625 } | 626 } |
| 626 | 627 |
| 627 void BrowserWindowCocoa::EnterFullscreenWithChrome() { | 628 void BrowserWindowCocoa::EnterFullscreenWithChrome() { |
| 628 CHECK(base::mac::IsOSLionOrLater()); | 629 CHECK(chrome::mac::SupportsSystemFullscreen()); |
| 629 if ([controller_ inPresentationMode]) | 630 if ([controller_ inPresentationMode]) |
| 630 [controller_ exitPresentationMode]; | 631 [controller_ exitPresentationMode]; |
| 631 else | 632 else |
| 632 [controller_ enterFullscreen]; | 633 [controller_ enterFullscreen]; |
| 633 } | 634 } |
| 634 | 635 |
| 635 bool BrowserWindowCocoa::IsFullscreenWithChrome() { | 636 bool BrowserWindowCocoa::IsFullscreenWithChrome() { |
| 636 return IsFullscreen() && ![controller_ inPresentationMode]; | 637 return IsFullscreen() && ![controller_ inPresentationMode]; |
| 637 } | 638 } |
| 638 | 639 |
| 639 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { | 640 bool BrowserWindowCocoa::IsFullscreenWithoutChrome() { |
| 640 return IsFullscreen() && [controller_ inPresentationMode]; | 641 return IsFullscreen() && [controller_ inPresentationMode]; |
| 641 } | 642 } |
| 642 | 643 |
| 643 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { | 644 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { |
| 644 // Flip coordinates based on the primary screen. | 645 // Flip coordinates based on the primary screen. |
| 645 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 646 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
| 646 NSRect monitorFrame = [screen frame]; | 647 NSRect monitorFrame = [screen frame]; |
| 647 NSRect frame = [controller_ instantFrame]; | 648 NSRect frame = [controller_ instantFrame]; |
| 648 gfx::Rect bounds(NSRectToCGRect(frame)); | 649 gfx::Rect bounds(NSRectToCGRect(frame)); |
| 649 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); | 650 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); |
| 650 return bounds; | 651 return bounds; |
| 651 } | 652 } |
| 652 | 653 |
| 653 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( | 654 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( |
| 654 const gfx::Rect& bounds) { | 655 const gfx::Rect& bounds) { |
| 655 // In Lion fullscreen mode, convert popups into tabs. | 656 // In Lion fullscreen mode, convert popups into tabs. |
| 656 if (base::mac::IsOSLionOrLater() && IsFullscreen()) | 657 if (chrome::mac::SupportsSystemFullscreen() && IsFullscreen()) |
| 657 return NEW_FOREGROUND_TAB; | 658 return NEW_FOREGROUND_TAB; |
| 658 return NEW_POPUP; | 659 return NEW_POPUP; |
| 659 } | 660 } |
| 660 | 661 |
| 661 FindBar* BrowserWindowCocoa::CreateFindBar() { | 662 FindBar* BrowserWindowCocoa::CreateFindBar() { |
| 662 // We could push the AddFindBar() call into the FindBarBridge | 663 // We could push the AddFindBar() call into the FindBarBridge |
| 663 // constructor or the FindBarCocoaController init, but that makes | 664 // constructor or the FindBarCocoaController init, but that makes |
| 664 // unit testing difficult, since we would also require a | 665 // unit testing difficult, since we would also require a |
| 665 // BrowserWindow object. | 666 // BrowserWindow object. |
| 666 FindBarBridge* bridge = new FindBarBridge(browser_); | 667 FindBarBridge* bridge = new FindBarBridge(browser_); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 730 PasswordGenerationBubbleController* controller = | 731 PasswordGenerationBubbleController* controller = |
| 731 [[PasswordGenerationBubbleController alloc] | 732 [[PasswordGenerationBubbleController alloc] |
| 732 initWithWindow:browser_->window()->GetNativeWindow() | 733 initWithWindow:browser_->window()->GetNativeWindow() |
| 733 anchoredAt:point | 734 anchoredAt:point |
| 734 renderViewHost:web_contents->GetRenderViewHost() | 735 renderViewHost:web_contents->GetRenderViewHost() |
| 735 passwordManager:PasswordManager::FromWebContents(web_contents) | 736 passwordManager:PasswordManager::FromWebContents(web_contents) |
| 736 usingGenerator:password_generator | 737 usingGenerator:password_generator |
| 737 forForm:form]; | 738 forForm:form]; |
| 738 [controller showWindow:nil]; | 739 [controller showWindow:nil]; |
| 739 } | 740 } |
| OLD | NEW |