OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/cocoa/browser_window_cocoa.h" | 5 #include "chrome/browser/cocoa/browser_window_cocoa.h" |
6 | 6 |
7 #include "app/l10n_util_mac.h" | 7 #include "app/l10n_util_mac.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" |
(...skipping 19 matching lines...) Expand all Loading... |
30 #include "chrome/browser/cocoa/repost_form_warning_mac.h" | 30 #include "chrome/browser/cocoa/repost_form_warning_mac.h" |
31 #include "chrome/browser/cocoa/restart_browser.h" | 31 #include "chrome/browser/cocoa/restart_browser.h" |
32 #include "chrome/browser/cocoa/status_bubble_mac.h" | 32 #include "chrome/browser/cocoa/status_bubble_mac.h" |
33 #include "chrome/browser/cocoa/task_manager_mac.h" | 33 #include "chrome/browser/cocoa/task_manager_mac.h" |
34 #import "chrome/browser/cocoa/theme_install_bubble_view.h" | 34 #import "chrome/browser/cocoa/theme_install_bubble_view.h" |
35 #import "chrome/browser/cocoa/toolbar_controller.h" | 35 #import "chrome/browser/cocoa/toolbar_controller.h" |
36 #include "chrome/browser/download/download_shelf.h" | 36 #include "chrome/browser/download/download_shelf.h" |
37 #include "chrome/browser/global_keyboard_shortcuts_mac.h" | 37 #include "chrome/browser/global_keyboard_shortcuts_mac.h" |
38 #include "chrome/browser/prefs/pref_service.h" | 38 #include "chrome/browser/prefs/pref_service.h" |
39 #include "chrome/browser/profile.h" | 39 #include "chrome/browser/profile.h" |
| 40 #include "chrome/browser/sidebar/sidebar_container.h" |
| 41 #include "chrome/browser/sidebar/sidebar_manager.h" |
40 #include "chrome/browser/tab_contents/tab_contents.h" | 42 #include "chrome/browser/tab_contents/tab_contents.h" |
41 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
42 #include "chrome/common/native_web_keyboard_event.h" | 44 #include "chrome/common/native_web_keyboard_event.h" |
43 #include "chrome/common/notification_service.h" | 45 #include "chrome/common/notification_service.h" |
44 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
45 #include "gfx/rect.h" | 47 #include "gfx/rect.h" |
46 #include "grit/chromium_strings.h" | 48 #include "grit/chromium_strings.h" |
47 #include "grit/generated_resources.h" | 49 #include "grit/generated_resources.h" |
48 | 50 |
49 BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, | 51 BrowserWindowCocoa::BrowserWindowCocoa(Browser* browser, |
50 BrowserWindowController* controller, | 52 BrowserWindowController* controller, |
51 NSWindow* window) | 53 NSWindow* window) |
52 : browser_(browser), | 54 : browser_(browser), |
53 controller_(controller), | 55 controller_(controller), |
54 confirm_close_factory_(browser) { | 56 confirm_close_factory_(browser) { |
55 // This pref applies to all windows, so all must watch for it. | 57 // This pref applies to all windows, so all must watch for it. |
56 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, | 58 registrar_.Add(this, NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED, |
57 NotificationService::AllSources()); | 59 NotificationService::AllSources()); |
| 60 registrar_.Add(this, NotificationType::SIDEBAR_CHANGED, |
| 61 NotificationService::AllSources()); |
58 } | 62 } |
59 | 63 |
60 BrowserWindowCocoa::~BrowserWindowCocoa() { | 64 BrowserWindowCocoa::~BrowserWindowCocoa() { |
61 } | 65 } |
62 | 66 |
63 void BrowserWindowCocoa::Show() { | 67 void BrowserWindowCocoa::Show() { |
64 // The Browser associated with this browser window must become the active | 68 // The Browser associated with this browser window must become the active |
65 // browser at the time |Show()| is called. This is the natural behaviour under | 69 // browser at the time |Show()| is called. This is the natural behaviour under |
66 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| | 70 // Windows, but |-makeKeyAndOrderFront:| won't send |-windowDidBecomeMain:| |
67 // until we return to the runloop. Therefore any calls to | 71 // until we return to the runloop. Therefore any calls to |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
562 | 566 |
563 void BrowserWindowCocoa::Observe(NotificationType type, | 567 void BrowserWindowCocoa::Observe(NotificationType type, |
564 const NotificationSource& source, | 568 const NotificationSource& source, |
565 const NotificationDetails& details) { | 569 const NotificationDetails& details) { |
566 switch (type.value) { | 570 switch (type.value) { |
567 // Only the key window gets a direct toggle from the menu. | 571 // Only the key window gets a direct toggle from the menu. |
568 // Other windows hear about it from the notification. | 572 // Other windows hear about it from the notification. |
569 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: | 573 case NotificationType::BOOKMARK_BAR_VISIBILITY_PREF_CHANGED: |
570 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; | 574 [controller_ updateBookmarkBarVisibilityWithAnimation:YES]; |
571 break; | 575 break; |
| 576 case NotificationType::SIDEBAR_CHANGED: |
| 577 UpdateSidebarForContents( |
| 578 Details<SidebarContainer>(details)->tab_contents()); |
| 579 break; |
572 default: | 580 default: |
573 NOTREACHED(); // we don't ask for anything else! | 581 NOTREACHED(); // we don't ask for anything else! |
574 break; | 582 break; |
575 } | 583 } |
576 } | 584 } |
577 | 585 |
578 void BrowserWindowCocoa::DestroyBrowser() { | 586 void BrowserWindowCocoa::DestroyBrowser() { |
579 [controller_ destroyBrowser]; | 587 [controller_ destroyBrowser]; |
580 | 588 |
581 // at this point the controller is dead (autoreleased), so | 589 // at this point the controller is dead (autoreleased), so |
582 // make sure we don't try to reference it any more. | 590 // make sure we don't try to reference it any more. |
583 } | 591 } |
584 | 592 |
585 NSWindow* BrowserWindowCocoa::window() const { | 593 NSWindow* BrowserWindowCocoa::window() const { |
586 return [controller_ window]; | 594 return [controller_ window]; |
587 } | 595 } |
| 596 |
| 597 void BrowserWindowCocoa::UpdateSidebarForContents(TabContents* tab_contents) { |
| 598 if (tab_contents == browser_->tabstrip_model()->GetSelectedTabContents()) { |
| 599 [controller_ updateSidebarForContents:tab_contents]; |
| 600 } |
| 601 } |
OLD | NEW |