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/sys_string_conversions.h" | 10 #include "base/sys_string_conversions.h" |
11 #include "chrome/app/chrome_command_ids.h" | 11 #include "chrome/app/chrome_command_ids.h" |
12 #include "chrome/browser/bookmarks/bookmark_utils.h" | 12 #include "chrome/browser/bookmarks/bookmark_utils.h" |
13 #include "chrome/browser/download/download_shelf.h" | 13 #include "chrome/browser/download/download_shelf.h" |
14 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 14 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
15 #include "chrome/browser/page_info_window.h" | 15 #include "chrome/browser/page_info_window.h" |
16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/sidebar/sidebar_container.h" | 18 #include "chrome/browser/sidebar/sidebar_container.h" |
19 #include "chrome/browser/sidebar/sidebar_manager.h" | 19 #include "chrome/browser/sidebar/sidebar_manager.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_list.h" | 21 #include "chrome/browser/ui/browser_list.h" |
22 #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" |
23 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 23 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
24 #import "chrome/browser/ui/cocoa/bug_report_window_controller.h" | 24 #import "chrome/browser/ui/cocoa/bug_report_window_controller.h" |
25 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" | 25 #import "chrome/browser/ui/cocoa/chrome_event_processing_window.h" |
26 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" | 26 #import "chrome/browser/ui/cocoa/content_settings/collected_cookies_mac.h" |
27 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 27 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 28 #include "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
28 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" | 29 #import "chrome/browser/ui/cocoa/html_dialog_window_controller.h" |
29 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" | 30 #import "chrome/browser/ui/cocoa/location_bar/location_bar_view_mac.h" |
30 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" | 31 #import "chrome/browser/ui/cocoa/nsmenuitem_additions.h" |
31 #include "chrome/browser/ui/cocoa/repost_form_warning_mac.h" | 32 #include "chrome/browser/ui/cocoa/repost_form_warning_mac.h" |
32 #include "chrome/browser/ui/cocoa/restart_browser.h" | 33 #include "chrome/browser/ui/cocoa/restart_browser.h" |
33 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" | 34 #include "chrome/browser/ui/cocoa/status_bubble_mac.h" |
34 #include "chrome/browser/ui/cocoa/task_manager_mac.h" | 35 #include "chrome/browser/ui/cocoa/task_manager_mac.h" |
35 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h" | 36 #import "chrome/browser/ui/cocoa/theme_install_bubble_view.h" |
36 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 37 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
37 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 38 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 // This is called from Browser, which in turn is called directly from | 301 // This is called from Browser, which in turn is called directly from |
301 // a menu option. All we do here is set a preference. The act of | 302 // a menu option. All we do here is set a preference. The act of |
302 // setting the preference sends notifications to all windows who then | 303 // setting the preference sends notifications to all windows who then |
303 // know what to do. | 304 // know what to do. |
304 void BrowserWindowCocoa::ToggleBookmarkBar() { | 305 void BrowserWindowCocoa::ToggleBookmarkBar() { |
305 bookmark_utils::ToggleWhenVisible(browser_->profile()); | 306 bookmark_utils::ToggleWhenVisible(browser_->profile()); |
306 } | 307 } |
307 | 308 |
308 void BrowserWindowCocoa::AddFindBar( | 309 void BrowserWindowCocoa::AddFindBar( |
309 FindBarCocoaController* find_bar_cocoa_controller) { | 310 FindBarCocoaController* find_bar_cocoa_controller) { |
310 return [controller_ addFindBar:find_bar_cocoa_controller]; | 311 [controller_ addFindBar:find_bar_cocoa_controller]; |
311 } | 312 } |
312 | 313 |
313 void BrowserWindowCocoa::ShowAboutChromeDialog() { | 314 void BrowserWindowCocoa::ShowAboutChromeDialog() { |
314 // Go through AppController's implementation to bring up the branded panel. | 315 // Go through AppController's implementation to bring up the branded panel. |
315 [[NSApp delegate] orderFrontStandardAboutPanel:nil]; | 316 [[NSApp delegate] orderFrontStandardAboutPanel:nil]; |
316 } | 317 } |
317 | 318 |
318 void BrowserWindowCocoa::ShowUpdateChromeDialog() { | 319 void BrowserWindowCocoa::ShowUpdateChromeDialog() { |
319 restart_browser::RequestRestart(window()); | 320 restart_browser::RequestRestart(window()); |
320 } | 321 } |
(...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
578 gfx::Rect bounds(NSRectToCGRect(frame)); | 579 gfx::Rect bounds(NSRectToCGRect(frame)); |
579 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); | 580 bounds.set_y(NSHeight(monitorFrame) - bounds.y() - bounds.height()); |
580 return bounds; | 581 return bounds; |
581 } | 582 } |
582 | 583 |
583 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( | 584 WindowOpenDisposition BrowserWindowCocoa::GetDispositionForPopupBounds( |
584 const gfx::Rect& bounds) { | 585 const gfx::Rect& bounds) { |
585 return NEW_POPUP; | 586 return NEW_POPUP; |
586 } | 587 } |
587 | 588 |
| 589 FindBar* BrowserWindowCocoa::CreateFindBar() { |
| 590 // We could push the AddFindBar() call into the FindBarBridge |
| 591 // constructor or the FindBarCocoaController init, but that makes |
| 592 // unit testing difficult, since we would also require a |
| 593 // BrowserWindow object. |
| 594 FindBarBridge* bridge = new FindBarBridge(); |
| 595 AddFindBar(bridge->find_bar_cocoa_controller()); |
| 596 return bridge; |
| 597 } |
| 598 |
588 void BrowserWindowCocoa::Observe(int type, | 599 void BrowserWindowCocoa::Observe(int type, |
589 const NotificationSource& source, | 600 const NotificationSource& source, |
590 const NotificationDetails& details) { | 601 const NotificationDetails& details) { |
591 switch (type) { | 602 switch (type) { |
592 // Only the key window gets a direct toggle from the menu. | 603 // Only the key window gets a direct toggle from the menu. |
593 // Other windows hear about it from the notification. | 604 // Other windows hear about it from the notification. |
594 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 605 case chrome::NOTIFICATION_BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
595 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; | 606 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; |
596 break; | 607 break; |
597 case chrome::NOTIFICATION_SIDEBAR_CHANGED: | 608 case chrome::NOTIFICATION_SIDEBAR_CHANGED: |
(...skipping 15 matching lines...) Expand all Loading... |
613 | 624 |
614 NSWindow* BrowserWindowCocoa::window() const { | 625 NSWindow* BrowserWindowCocoa::window() const { |
615 return [controller_ window]; | 626 return [controller_ window]; |
616 } | 627 } |
617 | 628 |
618 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { | 629 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
619 if (tab_contents == browser_->GetSelectedTabContents()) { | 630 if (tab_contents == browser_->GetSelectedTabContents()) { |
620 [controller_ updateSidebarForContents:tab_contents]; | 631 [controller_ updateSidebarForContents:tab_contents]; |
621 } | 632 } |
622 } | 633 } |
OLD | NEW |