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/tab_contents_controller.h" | 67 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
67 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 68 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
68 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 69 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
69 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 70 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
70 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 71 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
71 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" | 72 #import "chrome/browser/ui/cocoa/translate/translate_bubble_controller.h" |
72 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" | 73 #include "chrome/browser/ui/cocoa/website_settings/permission_bubble_cocoa.h" |
73 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" | 74 #include "chrome/browser/ui/exclusive_access/fullscreen_controller.h" |
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 | 307 |
307 // Create the overlayable contents controller. This provides the switch | 308 // Create the overlayable contents controller. This provides the switch |
308 // view that TabStripController needs. | 309 // view that TabStripController needs. |
309 overlayableContentsController_.reset( | 310 overlayableContentsController_.reset( |
310 [[OverlayableContentsController alloc] init]); | 311 [[OverlayableContentsController alloc] init]); |
311 [[overlayableContentsController_ view] | 312 [[overlayableContentsController_ view] |
312 setFrame:[[devToolsController_ view] bounds]]; | 313 setFrame:[[devToolsController_ view] bounds]]; |
313 [[devToolsController_ view] | 314 [[devToolsController_ view] |
314 addSubview:[overlayableContentsController_ view]]; | 315 addSubview:[overlayableContentsController_ view]]; |
315 | 316 |
| 317 // Create a sub-controller for the docked sidebar and add its view to the |
| 318 // hierarchy. |
| 319 sidebarController_.reset([[SidebarController alloc] |
| 320 initWithParentViewController:devToolsController_ |
| 321 andContentsController:overlayableContentsController_]); |
| 322 |
316 // Create a controller for the tab strip, giving it the model object for | 323 // Create a controller for the tab strip, giving it the model object for |
317 // this window's Browser and the tab strip view. The controller will handle | 324 // this window's Browser and the tab strip view. The controller will handle |
318 // registering for the appropriate tab notifications from the back-end and | 325 // registering for the appropriate tab notifications from the back-end and |
319 // managing the creation of new tabs. | 326 // managing the creation of new tabs. |
320 [self createTabStripController]; | 327 [self createTabStripController]; |
321 | 328 |
322 // Create a controller for the toolbar, giving it the toolbar model object | 329 // Create a controller for the toolbar, giving it the toolbar model object |
323 // and the toolbar view from the nib. The controller will handle | 330 // and the toolbar view from the nib. The controller will handle |
324 // registering for the appropriate command state changes from the back-end. | 331 // registering for the appropriate command state changes from the back-end. |
325 // Adds the toolbar to the content area. | 332 // Adds the toolbar to the content area. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
550 } | 557 } |
551 | 558 |
552 - (void)updateDevToolsForContents:(WebContents*)contents { | 559 - (void)updateDevToolsForContents:(WebContents*)contents { |
553 BOOL layout_changed = | 560 BOOL layout_changed = |
554 [devToolsController_ updateDevToolsForWebContents:contents | 561 [devToolsController_ updateDevToolsForWebContents:contents |
555 withProfile:browser_->profile()]; | 562 withProfile:browser_->profile()]; |
556 if (layout_changed && [findBarCocoaController_ isFindBarVisible]) | 563 if (layout_changed && [findBarCocoaController_ isFindBarVisible]) |
557 [self layoutSubviews]; | 564 [self layoutSubviews]; |
558 } | 565 } |
559 | 566 |
| 567 |
| 568 - (void)updateSidebarForContents:(content::WebContents*)tab_contents |
| 569 sidebar_contents:(content::WebContents*)sidebar_contents { |
| 570 [sidebarController_ updateSidebarForTabContents:tab_contents |
| 571 sidebar_contents:sidebar_contents]; |
| 572 [sidebarController_ ensureContentsVisible]; |
| 573 } |
| 574 |
560 // Called when the user wants to close a window or from the shutdown process. | 575 // Called when the user wants to close a window or from the shutdown process. |
561 // The Browser object is in control of whether or not we're allowed to close. It | 576 // The Browser object is in control of whether or not we're allowed to close. It |
562 // may defer closing due to several states, such as onUnload handlers needing to | 577 // may defer closing due to several states, such as onUnload handlers needing to |
563 // be fired. If closing is deferred, the Browser will handle the processing | 578 // be fired. If closing is deferred, the Browser will handle the processing |
564 // required to get us to the closing state and (by watching for all the tabs | 579 // required to get us to the closing state and (by watching for all the tabs |
565 // going away) will again call to close the window when it's finally ready. | 580 // going away) will again call to close the window when it's finally ready. |
566 - (BOOL)windowShouldClose:(id)sender { | 581 - (BOOL)windowShouldClose:(id)sender { |
567 // Disable updates while closing all tabs to avoid flickering. | 582 // Disable updates while closing all tabs to avoid flickering. |
568 gfx::ScopedCocoaDisableScreenUpdates disabler; | 583 gfx::ScopedCocoaDisableScreenUpdates disabler; |
569 // Give beforeunload handlers the chance to cancel the close before we hide | 584 // Give beforeunload handlers the chance to cancel the close before we hide |
(...skipping 910 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1480 } | 1495 } |
1481 | 1496 |
1482 // TabStripControllerDelegate protocol. | 1497 // TabStripControllerDelegate protocol. |
1483 - (void)onActivateTabWithContents:(WebContents*)contents { | 1498 - (void)onActivateTabWithContents:(WebContents*)contents { |
1484 // Update various elements that are interested in knowing the current | 1499 // Update various elements that are interested in knowing the current |
1485 // WebContents. | 1500 // WebContents. |
1486 | 1501 |
1487 // Update all the UI bits. | 1502 // Update all the UI bits. |
1488 windowShim_->UpdateTitleBar(); | 1503 windowShim_->UpdateTitleBar(); |
1489 | 1504 |
| 1505 [sidebarController_ |
| 1506 updateSidebarForTabContents:static_cast<content::WebContents*>(contents) |
| 1507 sidebar_contents:[sidebarController_ currentSidebarContents]]; |
1490 // Update the bookmark bar. | 1508 // Update the bookmark bar. |
1491 // TODO(viettrungluu): perhaps update to not terminate running animations (if | 1509 // TODO(viettrungluu): perhaps update to not terminate running animations (if |
1492 // applicable)? | 1510 // applicable)? |
1493 windowShim_->BookmarkBarStateChanged( | 1511 windowShim_->BookmarkBarStateChanged( |
1494 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 1512 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
1495 | 1513 |
1496 [infoBarContainerController_ changeWebContents:contents]; | 1514 [infoBarContainerController_ changeWebContents:contents]; |
1497 | 1515 |
| 1516 // Update devTools and sidebar contents after size for all views is set. |
| 1517 [sidebarController_ ensureContentsVisible]; |
| 1518 |
1498 // Must do this after bookmark and infobar updates to avoid | 1519 // Must do this after bookmark and infobar updates to avoid |
1499 // unnecesary resize in contents. | 1520 // unnecesary resize in contents. |
1500 [devToolsController_ updateDevToolsForWebContents:contents | 1521 [devToolsController_ updateDevToolsForWebContents:contents |
1501 withProfile:browser_->profile()]; | 1522 withProfile:browser_->profile()]; |
1502 } | 1523 } |
1503 | 1524 |
1504 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change | 1525 - (void)onTabChanged:(TabStripModelObserver::TabChangeType)change |
1505 withContents:(WebContents*)contents { | 1526 withContents:(WebContents*)contents { |
1506 // Update titles if this is the currently selected tab and if it isn't just | 1527 // Update titles if this is the currently selected tab and if it isn't just |
1507 // the loading state which changed. | 1528 // the loading state which changed. |
(...skipping 553 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2061 | 2082 |
2062 - (BOOL)supportsBookmarkBar { | 2083 - (BOOL)supportsBookmarkBar { |
2063 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2084 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2064 } | 2085 } |
2065 | 2086 |
2066 - (BOOL)isTabbedWindow { | 2087 - (BOOL)isTabbedWindow { |
2067 return browser_->is_type_tabbed(); | 2088 return browser_->is_type_tabbed(); |
2068 } | 2089 } |
2069 | 2090 |
2070 @end // @implementation BrowserWindowController(WindowType) | 2091 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |