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