OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #import "chrome/browser/ui/cocoa/browser_window_controller.h" | 5 #import "chrome/browser/ui/cocoa/browser_window_controller.h" |
6 | 6 |
7 #include <cmath> | 7 #include <cmath> |
8 #include <numeric> | 8 #include <numeric> |
9 | 9 |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" | 54 #import "chrome/browser/ui/cocoa/find_bar/find_bar_cocoa_controller.h" |
55 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 55 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
56 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 56 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
57 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 57 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
58 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" | 58 #include "chrome/browser/ui/cocoa/last_active_browser_cocoa.h" |
59 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 59 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
60 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 60 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
61 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" | 61 #import "chrome/browser/ui/cocoa/profiles/avatar_base_controller.h" |
62 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" | 62 #import "chrome/browser/ui/cocoa/profiles/avatar_button_controller.h" |
63 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" | 63 #import "chrome/browser/ui/cocoa/profiles/avatar_icon_controller.h" |
| 64 #import "chrome/browser/ui/cocoa/sidebar_controller.h" |
64 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 65 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
65 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 66 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
66 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 67 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
67 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 68 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
68 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 70 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
70 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 71 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
71 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 72 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
72 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | 73 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" |
73 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | 74 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
302 | 303 |
303 // Create the overlayable contents controller. This provides the switch | 304 // Create the overlayable contents controller. This provides the switch |
304 // view that TabStripController needs. | 305 // view that TabStripController needs. |
305 overlayableContentsController_.reset( | 306 overlayableContentsController_.reset( |
306 [[OverlayableContentsController alloc] initWithBrowser:browser]); | 307 [[OverlayableContentsController alloc] initWithBrowser:browser]); |
307 [[overlayableContentsController_ view] | 308 [[overlayableContentsController_ view] |
308 setFrame:[[devToolsController_ view] bounds]]; | 309 setFrame:[[devToolsController_ view] bounds]]; |
309 [[devToolsController_ view] | 310 [[devToolsController_ view] |
310 addSubview:[overlayableContentsController_ view]]; | 311 addSubview:[overlayableContentsController_ view]]; |
311 | 312 |
| 313 // Create a sub-controller for the docked sidebar and add its view to the |
| 314 // hierarchy. |
| 315 sidebarController_.reset([[SidebarController alloc] |
| 316 initWithParentViewController:devToolsController_ |
| 317 andContentsController:overlayableContentsController_]); |
| 318 |
312 // Create a controller for the tab strip, giving it the model object for | 319 // Create a controller for the tab strip, giving it the model object for |
313 // this window's Browser and the tab strip view. The controller will handle | 320 // this window's Browser and the tab strip view. The controller will handle |
314 // registering for the appropriate tab notifications from the back-end and | 321 // registering for the appropriate tab notifications from the back-end and |
315 // managing the creation of new tabs. | 322 // managing the creation of new tabs. |
316 [self createTabStripController]; | 323 [self createTabStripController]; |
317 | 324 |
318 // Create a controller for the toolbar, giving it the toolbar model object | 325 // Create a controller for the toolbar, giving it the toolbar model object |
319 // and the toolbar view from the nib. The controller will handle | 326 // and the toolbar view from the nib. The controller will handle |
320 // registering for the appropriate command state changes from the back-end. | 327 // registering for the appropriate command state changes from the back-end. |
321 // Adds the toolbar to the content area. | 328 // Adds the toolbar to the content area. |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 } | 541 } |
535 | 542 |
536 - (void)updateDevToolsForContents:(WebContents*)contents { | 543 - (void)updateDevToolsForContents:(WebContents*)contents { |
537 BOOL layout_changed = | 544 BOOL layout_changed = |
538 [devToolsController_ updateDevToolsForWebContents:contents | 545 [devToolsController_ updateDevToolsForWebContents:contents |
539 withProfile:browser_->profile()]; | 546 withProfile:browser_->profile()]; |
540 if (layout_changed && [findBarCocoaController_ isFindBarVisible]) | 547 if (layout_changed && [findBarCocoaController_ isFindBarVisible]) |
541 [self layoutSubviews]; | 548 [self layoutSubviews]; |
542 } | 549 } |
543 | 550 |
| 551 - (void)updateSidebarForContents:(content::WebContents*)contents { |
| 552 [sidebarController_ updateSidebarForTabContents:contents |
| 553 withContext:browser_->profile()]; |
| 554 [sidebarController_ ensureContentsVisible]; |
| 555 } |
| 556 |
544 // Called when the user wants to close a window or from the shutdown process. | 557 // Called when the user wants to close a window or from the shutdown process. |
545 // The Browser object is in control of whether or not we're allowed to close. It | 558 // The Browser object is in control of whether or not we're allowed to close. It |
546 // may defer closing due to several states, such as onUnload handlers needing to | 559 // may defer closing due to several states, such as onUnload handlers needing to |
547 // be fired. If closing is deferred, the Browser will handle the processing | 560 // be fired. If closing is deferred, the Browser will handle the processing |
548 // required to get us to the closing state and (by watching for all the tabs | 561 // required to get us to the closing state and (by watching for all the tabs |
549 // going away) will again call to close the window when it's finally ready. | 562 // going away) will again call to close the window when it's finally ready. |
550 - (BOOL)windowShouldClose:(id)sender { | 563 - (BOOL)windowShouldClose:(id)sender { |
551 // Disable updates while closing all tabs to avoid flickering. | 564 // Disable updates while closing all tabs to avoid flickering. |
552 gfx::ScopedNSDisableScreenUpdates disabler; | 565 gfx::ScopedNSDisableScreenUpdates disabler; |
553 // Give beforeunload handlers the chance to cancel the close before we hide | 566 // Give beforeunload handlers the chance to cancel the close before we hide |
(...skipping 1100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1654 } | 1667 } |
1655 | 1668 |
1656 // TabStripControllerDelegate protocol. | 1669 // TabStripControllerDelegate protocol. |
1657 - (void)onActivateTabWithContents:(WebContents*)contents { | 1670 - (void)onActivateTabWithContents:(WebContents*)contents { |
1658 // Update various elements that are interested in knowing the current | 1671 // Update various elements that are interested in knowing the current |
1659 // WebContents. | 1672 // WebContents. |
1660 | 1673 |
1661 // Update all the UI bits. | 1674 // Update all the UI bits. |
1662 windowShim_->UpdateTitleBar(); | 1675 windowShim_->UpdateTitleBar(); |
1663 | 1676 |
| 1677 [sidebarController_ |
| 1678 updateSidebarForTabContents:static_cast<content::WebContents*>(contents) |
| 1679 withContext:browser_->profile()]; |
1664 // Update the bookmark bar. | 1680 // Update the bookmark bar. |
1665 // TODO(viettrungluu): perhaps update to not terminate running animations (if | 1681 // TODO(viettrungluu): perhaps update to not terminate running animations (if |
1666 // applicable)? | 1682 // applicable)? |
1667 windowShim_->BookmarkBarStateChanged( | 1683 windowShim_->BookmarkBarStateChanged( |
1668 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 1684 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
1669 | 1685 |
1670 [infoBarContainerController_ changeWebContents:contents]; | 1686 [infoBarContainerController_ changeWebContents:contents]; |
1671 | 1687 |
| 1688 // Update devTools and sidebar contents after size for all views is set. |
| 1689 [sidebarController_ ensureContentsVisible]; |
| 1690 |
1672 // Must do this after bookmark and infobar updates to avoid | 1691 // Must do this after bookmark and infobar updates to avoid |
1673 // unnecesary resize in contents. | 1692 // unnecesary resize in contents. |
1674 [devToolsController_ updateDevToolsForWebContents:contents | 1693 [devToolsController_ updateDevToolsForWebContents:contents |
1675 withProfile:browser_->profile()]; | 1694 withProfile:browser_->profile()]; |
1676 } | 1695 } |
1677 | 1696 |
1678 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change | 1697 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change |
1679 withContents:(WebContents*)contents { | 1698 withContents:(WebContents*)contents { |
1680 // Update titles if this is the currently selected tab and if it isn't just | 1699 // Update titles if this is the currently selected tab and if it isn't just |
1681 // the loading state which changed. | 1700 // the loading state which changed. |
(...skipping 550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2232 | 2251 |
2233 - (BOOL)supportsBookmarkBar { | 2252 - (BOOL)supportsBookmarkBar { |
2234 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2253 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2235 } | 2254 } |
2236 | 2255 |
2237 - (BOOL)isTabbedWindow { | 2256 - (BOOL)isTabbedWindow { |
2238 return browser_->is_type_tabbed(); | 2257 return browser_->is_type_tabbed(); |
2239 } | 2258 } |
2240 | 2259 |
2241 @end // @implementation BrowserWindowController(WindowType) | 2260 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |