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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
52 #import "chrome/browser/ui/cocoa/framed_browser_window.h" | 52 #import "chrome/browser/ui/cocoa/framed_browser_window.h" |
53 #import "chrome/browser/ui/cocoa/fullscreen_window.h" | 53 #import "chrome/browser/ui/cocoa/fullscreen_window.h" |
54 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" | 54 #import "chrome/browser/ui/cocoa/infobars/infobar_container_controller.h" |
55 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" | 55 #import "chrome/browser/ui/cocoa/location_bar/autocomplete_text_field_editor.h" |
56 #import "chrome/browser/ui/cocoa/nsview_additions.h" | 56 #import "chrome/browser/ui/cocoa/nsview_additions.h" |
57 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" | 57 #import "chrome/browser/ui/cocoa/presentation_mode_controller.h" |
58 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" | 58 #import "chrome/browser/ui/cocoa/status_bubble_mac.h" |
59 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" | 59 #import "chrome/browser/ui/cocoa/tab_contents/overlayable_contents_controller.h" |
60 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" | 60 #import "chrome/browser/ui/cocoa/tab_contents/sad_tab_controller.h" |
61 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" | 61 #import "chrome/browser/ui/cocoa/tab_contents/tab_contents_controller.h" |
62 #import "chrome/browser/ui/cocoa/tabpose_window.h" | |
63 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" | 62 #import "chrome/browser/ui/cocoa/tabs/tab_strip_controller.h" |
64 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" | 63 #import "chrome/browser/ui/cocoa/tabs/tab_strip_view.h" |
65 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" | 64 #import "chrome/browser/ui/cocoa/tabs/tab_view.h" |
66 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 65 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
67 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" | 66 #include "chrome/browser/ui/fullscreen/fullscreen_controller.h" |
68 #include "chrome/browser/ui/omnibox/location_bar.h" | 67 #include "chrome/browser/ui/omnibox/location_bar.h" |
69 #include "chrome/browser/ui/tabs/dock_info.h" | 68 #include "chrome/browser/ui/tabs/dock_info.h" |
70 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 69 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
71 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" | 70 #include "chrome/browser/ui/tabs/tab_strip_model_delegate.h" |
72 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" | 71 #include "chrome/browser/ui/toolbar/encoding_menu_controller.h" |
(...skipping 1659 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1732 // Map forwards and backwards to history; left is positive, right is negative. | 1731 // Map forwards and backwards to history; left is positive, right is negative. |
1733 unsigned int command = 0; | 1732 unsigned int command = 0; |
1734 if (deltaX > 0.5) { | 1733 if (deltaX > 0.5) { |
1735 command = IDC_BACK; | 1734 command = IDC_BACK; |
1736 } else if (deltaX < -0.5) { | 1735 } else if (deltaX < -0.5) { |
1737 command = IDC_FORWARD; | 1736 command = IDC_FORWARD; |
1738 } else if (deltaY > 0.5) { | 1737 } else if (deltaY > 0.5) { |
1739 // TODO(pinkerton): figure out page-up, http://crbug.com/16305 | 1738 // TODO(pinkerton): figure out page-up, http://crbug.com/16305 |
1740 } else if (deltaY < -0.5) { | 1739 } else if (deltaY < -0.5) { |
1741 // TODO(pinkerton): figure out page-down, http://crbug.com/16305 | 1740 // TODO(pinkerton): figure out page-down, http://crbug.com/16305 |
1742 chrome::ExecuteCommand(browser_.get(), IDC_TABPOSE); | |
1743 } | 1741 } |
1744 | 1742 |
1745 // Ensure the command is valid first (ExecuteCommand() won't do that) and | 1743 // Ensure the command is valid first (ExecuteCommand() won't do that) and |
1746 // then make it so. | 1744 // then make it so. |
1747 if (chrome::IsCommandEnabled(browser_.get(), command)) { | 1745 if (chrome::IsCommandEnabled(browser_.get(), command)) { |
1748 chrome::ExecuteCommandWithDisposition( | 1746 chrome::ExecuteCommandWithDisposition( |
1749 browser_.get(), | 1747 browser_.get(), |
1750 command, | 1748 command, |
1751 ui::WindowOpenDispositionFromNSEvent(event)); | 1749 ui::WindowOpenDispositionFromNSEvent(event)); |
1752 } | 1750 } |
(...skipping 407 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2160 delay:delay]; | 2158 delay:delay]; |
2161 } | 2159 } |
2162 } | 2160 } |
2163 } | 2161 } |
2164 | 2162 |
2165 - (BOOL)floatingBarHasFocus { | 2163 - (BOOL)floatingBarHasFocus { |
2166 NSResponder* focused = [[self window] firstResponder]; | 2164 NSResponder* focused = [[self window] firstResponder]; |
2167 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; | 2165 return [focused isKindOfClass:[AutocompleteTextFieldEditor class]]; |
2168 } | 2166 } |
2169 | 2167 |
2170 - (void)tabposeWillClose:(NSNotification*)notif { | |
2171 // Re-show the container after Tabpose closes. | |
2172 [[infoBarContainerController_ view] setHidden:NO]; | |
2173 } | |
2174 | |
2175 - (void)openTabpose { | |
2176 NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags]; | |
2177 BOOL slomo = (modifierFlags & NSShiftKeyMask) != 0; | |
2178 | |
2179 // Cover info bars, inspector window, and detached bookmark bar on NTP. | |
2180 // Do not cover download shelf. | |
2181 NSRect activeArea = [[self tabContentArea] frame]; | |
2182 // Take out the anti-spoof height so that Tabpose doesn't draw on top of the | |
2183 // browser chrome. | |
2184 activeArea.size.height += | |
2185 NSHeight([[infoBarContainerController_ view] frame]) - | |
2186 [infoBarContainerController_ overlappingTipHeight]; | |
2187 if ([self isBookmarkBarVisible] && [self placeBookmarkBarBelowInfoBar]) { | |
2188 NSView* bookmarkBarView = [bookmarkBarController_ view]; | |
2189 activeArea.size.height += NSHeight([bookmarkBarView frame]); | |
2190 } | |
2191 | |
2192 // Hide the infobar container so that the anti-spoof bulge doesn't show when | |
2193 // Tabpose is open. | |
2194 [[infoBarContainerController_ view] setHidden:YES]; | |
2195 | |
2196 TabposeWindow* window = | |
2197 [TabposeWindow openTabposeFor:[self window] | |
2198 rect:activeArea | |
2199 slomo:slomo | |
2200 tabStripModel:browser_->tab_strip_model()]; | |
2201 | |
2202 // When the Tabpose window closes, the infobar container needs to be made | |
2203 // visible again. | |
2204 NSNotificationCenter* center = [NSNotificationCenter defaultCenter]; | |
2205 [center addObserver:self | |
2206 selector:@selector(tabposeWillClose:) | |
2207 name:NSWindowWillCloseNotification | |
2208 object:window]; | |
2209 } | |
2210 | |
2211 @end // @implementation BrowserWindowController(Fullscreen) | 2168 @end // @implementation BrowserWindowController(Fullscreen) |
2212 | 2169 |
2213 | 2170 |
2214 @implementation BrowserWindowController(WindowType) | 2171 @implementation BrowserWindowController(WindowType) |
2215 | 2172 |
2216 - (BOOL)supportsWindowFeature:(int)feature { | 2173 - (BOOL)supportsWindowFeature:(int)feature { |
2217 return browser_->SupportsWindowFeature( | 2174 return browser_->SupportsWindowFeature( |
2218 static_cast<Browser::WindowFeature>(feature)); | 2175 static_cast<Browser::WindowFeature>(feature)); |
2219 } | 2176 } |
2220 | 2177 |
(...skipping 11 matching lines...) Expand all Loading... |
2232 | 2189 |
2233 - (BOOL)supportsBookmarkBar { | 2190 - (BOOL)supportsBookmarkBar { |
2234 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; | 2191 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; |
2235 } | 2192 } |
2236 | 2193 |
2237 - (BOOL)isTabbedWindow { | 2194 - (BOOL)isTabbedWindow { |
2238 return browser_->is_type_tabbed(); | 2195 return browser_->is_type_tabbed(); |
2239 } | 2196 } |
2240 | 2197 |
2241 @end // @implementation BrowserWindowController(WindowType) | 2198 @end // @implementation BrowserWindowController(WindowType) |
OLD | NEW |