| 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 25 matching lines...) Expand all Loading... |
| 36 #include "chrome/browser/ui/browser_command_controller.h" | 36 #include "chrome/browser/ui/browser_command_controller.h" |
| 37 #include "chrome/browser/ui/browser_commands.h" | 37 #include "chrome/browser/ui/browser_commands.h" |
| 38 #include "chrome/browser/ui/browser_instant_controller.h" | 38 #include "chrome/browser/ui/browser_instant_controller.h" |
| 39 #include "chrome/browser/ui/browser_list.h" | 39 #include "chrome/browser/ui/browser_list.h" |
| 40 #include "chrome/browser/ui/browser_window_state.h" | 40 #include "chrome/browser/ui/browser_window_state.h" |
| 41 #import "chrome/browser/ui/cocoa/background_gradient_view.h" | 41 #import "chrome/browser/ui/cocoa/background_gradient_view.h" |
| 42 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 42 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" | 43 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_editor_controller.h" |
| 44 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 44 #import "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 45 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" | 45 #import "chrome/browser/ui/cocoa/browser_window_controller_private.h" |
| 46 #import "chrome/browser/ui/cocoa/browser_window_layout.h" |
| 46 #import "chrome/browser/ui/cocoa/browser_window_utils.h" | 47 #import "chrome/browser/ui/cocoa/browser_window_utils.h" |
| 47 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" | 48 #import "chrome/browser/ui/cocoa/constrained_window/constrained_window_sheet_con
troller.h" |
| 48 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" | 49 #import "chrome/browser/ui/cocoa/dev_tools_controller.h" |
| 49 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" | 50 #import "chrome/browser/ui/cocoa/download/download_shelf_controller.h" |
| 50 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" | 51 #include "chrome/browser/ui/cocoa/extensions/extension_keybinding_registry_cocoa
.h" |
| 51 #import "chrome/browser/ui/cocoa/fast_resize_view.h" | 52 #import "chrome/browser/ui/cocoa/fast_resize_view.h" |
| 52 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" | 53 #import "chrome/browser/ui/cocoa/find_bar/find_bar_bridge.h" |
| 53 #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" |
| 54 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 55 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
| 55 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 56 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
| (...skipping 909 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 965 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { | 966 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { |
| 966 // We should only ever be called for one of the following four views. | 967 // We should only ever be called for one of the following four views. |
| 967 // |downloadShelfController_| may be nil. If we are asked to size the bookmark | 968 // |downloadShelfController_| may be nil. If we are asked to size the bookmark |
| 968 // bar directly, its superview must be this controller's content view. | 969 // bar directly, its superview must be this controller's content view. |
| 969 DCHECK(view); | 970 DCHECK(view); |
| 970 DCHECK(view == [toolbarController_ view] || | 971 DCHECK(view == [toolbarController_ view] || |
| 971 view == [infoBarContainerController_ view] || | 972 view == [infoBarContainerController_ view] || |
| 972 view == [downloadShelfController_ view] || | 973 view == [downloadShelfController_ view] || |
| 973 view == [bookmarkBarController_ view]); | 974 view == [bookmarkBarController_ view]); |
| 974 | 975 |
| 976 // The infobar has insufficient information to determine its new height. It |
| 977 // knows the total height of all of the info bars (which is what it passes |
| 978 // into this method), but knows nothing about the maximum arrow height, which |
| 979 // is determined by this class. |
| 980 if (view == [infoBarContainerController_ view]) { |
| 981 base::scoped_nsobject<BrowserWindowLayout> layout( |
| 982 [[BrowserWindowLayout alloc] init]); |
| 983 [self updateLayoutParameters:layout]; |
| 984 // Use the new height for the info bar. |
| 985 [layout setInfoBarHeight:height]; |
| 986 |
| 987 chrome::LayoutOutput output = [layout computeLayout]; |
| 988 |
| 989 height = NSHeight(output.infoBarFrame); |
| 990 } |
| 991 |
| 975 // Change the height of the view and call |-layoutSubViews|. We set the height | 992 // Change the height of the view and call |-layoutSubViews|. We set the height |
| 976 // here without regard to where the view is on the screen or whether it needs | 993 // here without regard to where the view is on the screen or whether it needs |
| 977 // to "grow up" or "grow down." The below call to |-layoutSubviews| will | 994 // to "grow up" or "grow down." The below call to |-layoutSubviews| will |
| 978 // position each view correctly. | 995 // position each view correctly. |
| 979 NSRect frame = [view frame]; | 996 NSRect frame = [view frame]; |
| 980 if (NSHeight(frame) == height) | 997 if (NSHeight(frame) == height) |
| 981 return; | 998 return; |
| 982 | 999 |
| 983 // Disable screen updates to prevent flickering. | 1000 // Disable screen updates to prevent flickering. |
| 984 gfx::ScopedNSDisableScreenUpdates disabler; | 1001 gfx::ScopedNSDisableScreenUpdates disabler; |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1551 | 1568 |
| 1552 - (DevToolsController*)devToolsController { | 1569 - (DevToolsController*)devToolsController { |
| 1553 return devToolsController_; | 1570 return devToolsController_; |
| 1554 } | 1571 } |
| 1555 | 1572 |
| 1556 - (BOOL)isDownloadShelfVisible { | 1573 - (BOOL)isDownloadShelfVisible { |
| 1557 return downloadShelfController_ != nil && | 1574 return downloadShelfController_ != nil && |
| 1558 [downloadShelfController_ isVisible]; | 1575 [downloadShelfController_ isVisible]; |
| 1559 } | 1576 } |
| 1560 | 1577 |
| 1561 - (DownloadShelfController*)downloadShelf { | 1578 - (void)createAndAddDownloadShelf { |
| 1562 if (!downloadShelfController_.get()) { | 1579 if (!downloadShelfController_.get()) { |
| 1563 downloadShelfController_.reset([[DownloadShelfController alloc] | 1580 downloadShelfController_.reset([[DownloadShelfController alloc] |
| 1564 initWithBrowser:browser_.get() resizeDelegate:self]); | 1581 initWithBrowser:browser_.get() resizeDelegate:self]); |
| 1565 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; | 1582 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; |
| 1566 } | 1583 } |
| 1584 } |
| 1585 |
| 1586 - (DownloadShelfController*)downloadShelf { |
| 1567 return downloadShelfController_; | 1587 return downloadShelfController_; |
| 1568 } | 1588 } |
| 1569 | 1589 |
| 1570 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1590 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
| 1571 // Shouldn't call addFindBar twice. | 1591 // Shouldn't call addFindBar twice. |
| 1572 DCHECK(!findBarCocoaController_.get()); | 1592 DCHECK(!findBarCocoaController_.get()); |
| 1573 | 1593 |
| 1574 // Create a controller for the findbar. | 1594 // Create a controller for the findbar. |
| 1575 findBarCocoaController_.reset([findBarCocoaController retain]); | 1595 findBarCocoaController_.reset([findBarCocoaController retain]); |
| 1576 [self layoutSubviews]; | 1596 [self layoutSubviews]; |
| 1577 [self updateSubviewZOrder:[self isInFullscreenWithOmniboxSliding]]; | 1597 [self updateSubviewZOrder]; |
| 1578 } | 1598 } |
| 1579 | 1599 |
| 1580 - (NSWindow*)createFullscreenWindow { | 1600 - (NSWindow*)createFullscreenWindow { |
| 1581 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1601 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
| 1582 autorelease]; | 1602 autorelease]; |
| 1583 } | 1603 } |
| 1584 | 1604 |
| 1585 - (NSInteger)numberOfTabs { | 1605 - (NSInteger)numberOfTabs { |
| 1586 // count() includes pinned tabs. | 1606 // count() includes pinned tabs. |
| 1587 return browser_->tab_strip_model()->count(); | 1607 return browser_->tab_strip_model()->count(); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2202 | 2222 |
| 2203 - (BOOL)supportsBookmarkBar { | 2223 - (BOOL)supportsBookmarkBar { |
| 2204 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2224 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
| 2205 } | 2225 } |
| 2206 | 2226 |
| 2207 - (BOOL)isTabbedWindow { | 2227 - (BOOL)isTabbedWindow { |
| 2208 return browser_->is_type_tabbed(); | 2228 return browser_->is_type_tabbed(); |
| 2209 } | 2229 } |
| 2210 | 2230 |
| 2211 @end // @implementation BrowserWindowController(WindowType) | 2231 @end // @implementation BrowserWindowController(WindowType) |
| OLD | NEW |