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/message_loop.h" | 10 #include "base/message_loop.h" |
11 #include "base/sys_string_conversions.h" | 11 #include "base/sys_string_conversions.h" |
12 #include "chrome/app/chrome_command_ids.h" | 12 #include "chrome/app/chrome_command_ids.h" |
13 #include "chrome/browser/bookmarks/bookmark_utils.h" | 13 #include "chrome/browser/bookmarks/bookmark_utils.h" |
14 #include "chrome/browser/download/download_shelf.h" | 14 #include "chrome/browser/download/download_shelf.h" |
15 #include "chrome/browser/prefs/pref_service.h" | 15 #include "chrome/browser/prefs/pref_service.h" |
16 #include "chrome/browser/profiles/profile.h" | 16 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" |
17 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
19 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" | 20 #import "chrome/browser/ui/cocoa/browser/avatar_button_controller.h" |
20 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" | 21 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" |
21 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" | 22 #import "chrome/browser/ui/cocoa/browser/edit_search_engine_cocoa_controller.h" |
22 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 23 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
23 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 24 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
24 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 25 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
25 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" | 26 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" |
26 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 27 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 [controller_ destroyBrowser]; | 593 [controller_ destroyBrowser]; |
593 | 594 |
594 // at this point the controller is dead (autoreleased), so | 595 // at this point the controller is dead (autoreleased), so |
595 // make sure we don't try to reference it any more. | 596 // make sure we don't try to reference it any more. |
596 } | 597 } |
597 | 598 |
598 NSWindow* BrowserWindowCocoa::window() const { | 599 NSWindow* BrowserWindowCocoa::window() const { |
599 return [controller_ window]; | 600 return [controller_ window]; |
600 } | 601 } |
601 | 602 |
| 603 void BrowserWindowCocoa::UpdatePreferredSize(content::WebContents* web_contents, |
| 604 const gfx::Size& pref_size) { |
| 605 static_cast<TabContentsViewMac*>(web_contents->GetView())-> |
| 606 set_preferred_width(pref_size.width()); |
| 607 } |
| 608 |
602 void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents, | 609 void BrowserWindowCocoa::ShowAvatarBubble(WebContents* web_contents, |
603 const gfx::Rect& rect) { | 610 const gfx::Rect& rect) { |
604 NSView* view = web_contents->GetNativeView(); | 611 NSView* view = web_contents->GetNativeView(); |
605 NSRect bounds = [view bounds]; | 612 NSRect bounds = [view bounds]; |
606 NSPoint point; | 613 NSPoint point; |
607 point.x = NSMinX(bounds) + rect.right(); | 614 point.x = NSMinX(bounds) + rect.right(); |
608 // The view's origin is at the bottom but |rect|'s origin is at the top. | 615 // The view's origin is at the bottom but |rect|'s origin is at the top. |
609 point.y = NSMaxY(bounds) - rect.bottom(); | 616 point.y = NSMaxY(bounds) - rect.bottom(); |
610 point = [view convertPoint:point toView:nil]; | 617 point = [view convertPoint:point toView:nil]; |
611 point = [[view window] convertBaseToScreen:point]; | 618 point = [[view window] convertBaseToScreen:point]; |
612 | 619 |
613 // |menu| will automatically release itself on close. | 620 // |menu| will automatically release itself on close. |
614 AvatarMenuBubbleController* menu = | 621 AvatarMenuBubbleController* menu = |
615 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ | 622 [[AvatarMenuBubbleController alloc] initWithBrowser:browser_ |
616 anchoredAt:point]; | 623 anchoredAt:point]; |
617 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; | 624 [[menu bubble] setAlignment:info_bubble::kAlignEdgeToAnchorEdge]; |
618 [menu showWindow:nil]; | 625 [menu showWindow:nil]; |
619 } | 626 } |
620 | 627 |
621 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { | 628 void BrowserWindowCocoa::ShowAvatarBubbleFromAvatarButton() { |
622 [[controller_ avatarButtonController] showAvatarBubble]; | 629 [[controller_ avatarButtonController] showAvatarBubble]; |
623 } | 630 } |
OLD | NEW |