| 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/logging.h" | 8 #include "base/logging.h" |
| 9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
| 10 #include "base/mac/mac_util.h" | |
| 11 #include "base/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
| 12 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
| 13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| 14 #include "chrome/browser/download/download_shelf.h" | 13 #include "chrome/browser/download/download_shelf.h" |
| 15 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 14 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
| 16 #include "chrome/browser/page_info_window.h" | 15 #include "chrome/browser/page_info_window.h" |
| 17 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/sidebar/sidebar_container.h" | 18 #include "chrome/browser/sidebar/sidebar_container.h" |
| 20 #include "chrome/browser/sidebar/sidebar_manager.h" | 19 #include "chrome/browser/sidebar/sidebar_manager.h" |
| (...skipping 572 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 593 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { | 592 gfx::Rect BrowserWindowCocoa::GetInstantBounds() { |
| 594 // Flip coordinates based on the primary screen. | 593 // Flip coordinates based on the primary screen. |
| 595 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; | 594 NSScreen* screen = [[NSScreen screens] objectAtIndex:0]; |
| 596 NSRect monitorFrame = [screen frame]; | 595 NSRect monitorFrame = [screen frame]; |
| 597 NSRect frame = [controller_ instantFrame]; | 596 NSRect frame = [controller_ instantFrame]; |
| 598 gfx::Rect bounds(NSRectToCGRect(frame)); | 597 gfx::Rect bounds(NSRectToCGRect(frame)); |
| 599 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); | 598 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); |
| 600 return bounds; | 599 return bounds; |
| 601 } | 600 } |
| 602 | 601 |
| 603 gfx::Rect BrowserWindowCocoa::GrabWindowSnapshot(std::vector<unsigned char>* | |
| 604 png_representation) { | |
| 605 int width = 0, height = 0; | |
| 606 base::mac::GrabWindowSnapshot(window(), png_representation, &width, &height); | |
| 607 return gfx::Rect(width, height); | |
| 608 } | |
| 609 | |
| 610 void BrowserWindowCocoa::Observe(NotificationType type, | 602 void BrowserWindowCocoa::Observe(NotificationType type, |
| 611 const NotificationSource& source, | 603 const NotificationSource& source, |
| 612 const NotificationDetails& details) { | 604 const NotificationDetails& details) { |
| 613 switch (type.value) { | 605 switch (type.value) { |
| 614 // Only the key window gets a direct toggle from the menu. | 606 // Only the key window gets a direct toggle from the menu. |
| 615 // Other windows hear about it from the notification. | 607 // Other windows hear about it from the notification. |
| 616 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 608 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
| 617 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; | 609 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; |
| 618 break; | 610 break; |
| 619 case NotificationType::SIDEBAR_CHANGED: | 611 case NotificationType::SIDEBAR_CHANGED: |
| (...skipping 15 matching lines...) Expand all Loading... |
| 635 | 627 |
| 636 NSWindow* BrowserWindowCocoa::window() const { | 628 NSWindow* BrowserWindowCocoa::window() const { |
| 637 return [controller_ window]; | 629 return [controller_ window]; |
| 638 } | 630 } |
| 639 | 631 |
| 640 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { | 632 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
| 641 if (tab_contents == browser_->GetSelectedTabContents()) { | 633 if (tab_contents == browser_->GetSelectedTabContents()) { |
| 642 [controller_ updateSidebarForContents:tab_contents]; | 634 [controller_ updateSidebarForContents:tab_contents]; |
| 643 } | 635 } |
| 644 } | 636 } |
| OLD | NEW |