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 899 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
955 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { | 956 - (void)resizeView:(NSView*)view newHeight:(CGFloat)height { |
956 // We should only ever be called for one of the following four views. | 957 // We should only ever be called for one of the following four views. |
957 // |downloadShelfController_| may be nil. If we are asked to size the bookmark | 958 // |downloadShelfController_| may be nil. If we are asked to size the bookmark |
958 // bar directly, its superview must be this controller's content view. | 959 // bar directly, its superview must be this controller's content view. |
959 DCHECK(view); | 960 DCHECK(view); |
960 DCHECK(view == [toolbarController_ view] || | 961 DCHECK(view == [toolbarController_ view] || |
961 view == [infoBarContainerController_ view] || | 962 view == [infoBarContainerController_ view] || |
962 view == [downloadShelfController_ view] || | 963 view == [downloadShelfController_ view] || |
963 view == [bookmarkBarController_ view]); | 964 view == [bookmarkBarController_ view]); |
964 | 965 |
| 966 // The infobar has insufficient information to determine its new height. It |
| 967 // knows the total height of all of the info bars (which is what it passes |
| 968 // into this method), but knows nothing about the maximum arrow height, which |
| 969 // is determined by this class. |
| 970 if (view == [infoBarContainerController_ view]) { |
| 971 base::scoped_nsobject<BrowserWindowLayout> layout( |
| 972 [[BrowserWindowLayout alloc] init]); |
| 973 [self updateLayoutParameters:layout]; |
| 974 // Use the new height for the info bar. |
| 975 [layout setInfoBarHeight:height]; |
| 976 |
| 977 mac_browser::LayoutOutput output = [layout computeLayout]; |
| 978 |
| 979 height = NSHeight(output.infoBarFrame); |
| 980 } |
| 981 |
965 // Change the height of the view and call |-layoutSubViews|. We set the height | 982 // Change the height of the view and call |-layoutSubViews|. We set the height |
966 // here without regard to where the view is on the screen or whether it needs | 983 // here without regard to where the view is on the screen or whether it needs |
967 // to "grow up" or "grow down." The below call to |-layoutSubviews| will | 984 // to "grow up" or "grow down." The below call to |-layoutSubviews| will |
968 // position each view correctly. | 985 // position each view correctly. |
969 NSRect frame = [view frame]; | 986 NSRect frame = [view frame]; |
970 if (NSHeight(frame) == height) | 987 if (NSHeight(frame) == height) |
971 return; | 988 return; |
972 | 989 |
973 // Disable screen updates to prevent flickering. | 990 // Disable screen updates to prevent flickering. |
974 gfx::ScopedNSDisableScreenUpdates disabler; | 991 gfx::ScopedNSDisableScreenUpdates disabler; |
(...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1541 | 1558 |
1542 - (DevToolsController*)devToolsController { | 1559 - (DevToolsController*)devToolsController { |
1543 return devToolsController_; | 1560 return devToolsController_; |
1544 } | 1561 } |
1545 | 1562 |
1546 - (BOOL)isDownloadShelfVisible { | 1563 - (BOOL)isDownloadShelfVisible { |
1547 return downloadShelfController_ != nil && | 1564 return downloadShelfController_ != nil && |
1548 [downloadShelfController_ isVisible]; | 1565 [downloadShelfController_ isVisible]; |
1549 } | 1566 } |
1550 | 1567 |
1551 - (DownloadShelfController*)downloadShelf { | 1568 - (void)createAndAddDownloadShelf { |
1552 if (!downloadShelfController_.get()) { | 1569 if (!downloadShelfController_.get()) { |
1553 downloadShelfController_.reset([[DownloadShelfController alloc] | 1570 downloadShelfController_.reset([[DownloadShelfController alloc] |
1554 initWithBrowser:browser_.get() resizeDelegate:self]); | 1571 initWithBrowser:browser_.get() resizeDelegate:self]); |
1555 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; | 1572 [[[self window] contentView] addSubview:[downloadShelfController_ view]]; |
1556 } | 1573 } |
| 1574 } |
| 1575 |
| 1576 - (DownloadShelfController*)downloadShelf { |
1557 return downloadShelfController_; | 1577 return downloadShelfController_; |
1558 } | 1578 } |
1559 | 1579 |
1560 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { | 1580 - (void)addFindBar:(FindBarCocoaController*)findBarCocoaController { |
1561 // Shouldn't call addFindBar twice. | 1581 // Shouldn't call addFindBar twice. |
1562 DCHECK(!findBarCocoaController_.get()); | 1582 DCHECK(!findBarCocoaController_.get()); |
1563 | 1583 |
1564 // Create a controller for the findbar. | 1584 // Create a controller for the findbar. |
1565 findBarCocoaController_.reset([findBarCocoaController retain]); | 1585 findBarCocoaController_.reset([findBarCocoaController retain]); |
1566 [self layoutSubviews]; | 1586 [self layoutSubviews]; |
1567 [self updateSubviewZOrder:[self isInFullscreenWithOmniboxSliding]]; | 1587 [self updateSubviewZOrder]; |
1568 } | 1588 } |
1569 | 1589 |
1570 - (NSWindow*)createFullscreenWindow { | 1590 - (NSWindow*)createFullscreenWindow { |
1571 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] | 1591 return [[[FullscreenWindow alloc] initForScreen:[[self window] screen]] |
1572 autorelease]; | 1592 autorelease]; |
1573 } | 1593 } |
1574 | 1594 |
1575 - (NSInteger)numberOfTabs { | 1595 - (NSInteger)numberOfTabs { |
1576 // count() includes pinned tabs. | 1596 // count() includes pinned tabs. |
1577 return browser_->tab_strip_model()->count(); | 1597 return browser_->tab_strip_model()->count(); |
(...skipping 618 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2196 | 2216 |
2197 - (BOOL)supportsBookmarkBar { | 2217 - (BOOL)supportsBookmarkBar { |
2198 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2218 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2199 } | 2219 } |
2200 | 2220 |
2201 - (BOOL)isTabbedWindow { | 2221 - (BOOL)isTabbedWindow { |
2202 return browser_->is_type_tabbed(); | 2222 return browser_->is_type_tabbed(); |
2203 } | 2223 } |
2204 | 2224 |
2205 @end // @implementation BrowserWindowController(WindowType) | 2225 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |