Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(126)

Side by Side Diff: chrome/browser/cocoa/browser_window_controller.mm

Issue 2976008: Bar (Closed)
Patch Set: rebase Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/cocoa/browser_window_controller.h" 5 #import "chrome/browser/cocoa/browser_window_controller.h"
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 8
9 #include "app/l10n_util_mac.h" 9 #include "app/l10n_util_mac.h"
10 #include "base/mac_util.h" 10 #include "base/mac_util.h"
(...skipping 26 matching lines...) Expand all
37 #import "chrome/browser/cocoa/fullscreen_window.h" 37 #import "chrome/browser/cocoa/fullscreen_window.h"
38 #import "chrome/browser/cocoa/infobar_container_controller.h" 38 #import "chrome/browser/cocoa/infobar_container_controller.h"
39 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h" 39 #import "chrome/browser/cocoa/location_bar/autocomplete_text_field_editor.h"
40 #import "chrome/browser/cocoa/sad_tab_controller.h" 40 #import "chrome/browser/cocoa/sad_tab_controller.h"
41 #import "chrome/browser/cocoa/status_bubble_mac.h" 41 #import "chrome/browser/cocoa/status_bubble_mac.h"
42 #import "chrome/browser/cocoa/tab_contents_controller.h" 42 #import "chrome/browser/cocoa/tab_contents_controller.h"
43 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h" 43 #import "chrome/browser/cocoa/tab_strip_model_observer_bridge.h"
44 #import "chrome/browser/cocoa/tab_strip_controller.h" 44 #import "chrome/browser/cocoa/tab_strip_controller.h"
45 #import "chrome/browser/cocoa/tab_strip_view.h" 45 #import "chrome/browser/cocoa/tab_strip_view.h"
46 #import "chrome/browser/cocoa/tab_view.h" 46 #import "chrome/browser/cocoa/tab_view.h"
47 #import "chrome/browser/cocoa/tabpose_window.h"
47 #import "chrome/browser/cocoa/toolbar_controller.h" 48 #import "chrome/browser/cocoa/toolbar_controller.h"
48 #include "chrome/browser/renderer_host/render_widget_host_view.h" 49 #include "chrome/browser/renderer_host/render_widget_host_view.h"
49 #include "chrome/browser/sync/profile_sync_service.h" 50 #include "chrome/browser/sync/profile_sync_service.h"
50 #include "chrome/browser/sync/sync_ui_util_mac.h" 51 #include "chrome/browser/sync/sync_ui_util_mac.h"
51 #include "chrome/browser/tab_contents/tab_contents.h" 52 #include "chrome/browser/tab_contents/tab_contents.h"
52 #include "chrome/browser/tab_contents/tab_contents_view_mac.h" 53 #include "chrome/browser/tab_contents/tab_contents_view_mac.h"
53 #include "chrome/browser/tabs/tab_strip_model.h" 54 #include "chrome/browser/tabs/tab_strip_model.h"
54 #include "grit/generated_resources.h" 55 #include "grit/generated_resources.h"
55 #include "grit/locale_settings.h" 56 #include "grit/locale_settings.h"
56 57
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 // through it so you can drag the window by dragging on the spy guy 146 // through it so you can drag the window by dragging on the spy guy
146 @interface IncognitoImageView : NSImageView 147 @interface IncognitoImageView : NSImageView
147 @end 148 @end
148 149
149 @implementation IncognitoImageView 150 @implementation IncognitoImageView
150 - (BOOL)mouseDownCanMoveWindow { 151 - (BOOL)mouseDownCanMoveWindow {
151 return YES; 152 return YES;
152 } 153 }
153 @end 154 @end
154 155
156 // FIXME: private methods don't belong here
157 @interface BrowserWindowController (PrivateToo)
158 -(void)openTabpose:(BOOL)slomo;
159 @end
155 160
156 @implementation BrowserWindowController 161 @implementation BrowserWindowController
157 162
158 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { 163 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window {
159 while (window) { 164 while (window) {
160 id controller = [window windowController]; 165 id controller = [window windowController];
161 if ([controller isKindOfClass:[BrowserWindowController class]]) 166 if ([controller isKindOfClass:[BrowserWindowController class]])
162 return (BrowserWindowController*)controller; 167 return (BrowserWindowController*)controller;
163 window = [window parentWindow]; 168 window = [window parentWindow];
164 } 169 }
(...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after
911 // belong to a background window, yet this controller gets it because it is 916 // belong to a background window, yet this controller gets it because it is
912 // the foreground window's controller and thus in the responder chain. Some 917 // the foreground window's controller and thus in the responder chain. Some
913 // senders don't have this problem (for example, menus only operate on the 918 // senders don't have this problem (for example, menus only operate on the
914 // foreground window), so this is only an issue for senders that are part of 919 // foreground window), so this is only an issue for senders that are part of
915 // windows. 920 // windows.
916 BrowserWindowController* targetController = self; 921 BrowserWindowController* targetController = self;
917 if ([sender respondsToSelector:@selector(window)]) 922 if ([sender respondsToSelector:@selector(window)])
918 targetController = [[sender window] windowController]; 923 targetController = [[sender window] windowController];
919 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]); 924 DCHECK([targetController isKindOfClass:[BrowserWindowController class]]);
920 DCHECK(targetController->browser_.get()); 925 DCHECK(targetController->browser_.get());
921 targetController->browser_->ExecuteCommand([sender tag]); 926
927 NSInteger command = [sender tag];
928 switch (command) {
929 case IDC_TABPOSE: {
930 // FIXME: menu needs to switch between "enter/leave tabpose" depending on
931 // the current window
932 NSUInteger modifierFlags = [[NSApp currentEvent] modifierFlags];
933 [self openTabpose:(modifierFlags & NSShiftKeyMask) != 0];
934 break;
935 }
936 default:
937 targetController->browser_->ExecuteCommand(command);
938 }
922 } 939 }
923 940
924 // Same as |-commandDispatch:|, but executes commands using a disposition 941 // Same as |-commandDispatch:|, but executes commands using a disposition
925 // determined by the key flags. If the window is in the background and the 942 // determined by the key flags. If the window is in the background and the
926 // command key is down, ignore the command key, but process any other modifiers. 943 // command key is down, ignore the command key, but process any other modifiers.
927 - (void)commandDispatchUsingKeyModifiers:(id)sender { 944 - (void)commandDispatchUsingKeyModifiers:(id)sender {
928 DCHECK(sender); 945 DCHECK(sender);
929 // See comment above for why we do this. 946 // See comment above for why we do this.
930 BrowserWindowController* targetController = self; 947 BrowserWindowController* targetController = self;
931 if ([sender respondsToSelector:@selector(window)]) 948 if ([sender respondsToSelector:@selector(window)])
(...skipping 18 matching lines...) Expand all
950 switch (command) { 967 switch (command) {
951 case IDC_BACK: 968 case IDC_BACK:
952 case IDC_FORWARD: 969 case IDC_FORWARD:
953 case IDC_RELOAD: 970 case IDC_RELOAD:
954 case IDC_RELOAD_IGNORING_CACHE: 971 case IDC_RELOAD_IGNORING_CACHE:
955 if (disposition == CURRENT_TAB) { 972 if (disposition == CURRENT_TAB) {
956 // Forcibly reset the location bar, since otherwise it won't discard any 973 // Forcibly reset the location bar, since otherwise it won't discard any
957 // ongoing user edits, since it doesn't realize this is a user-initiated 974 // ongoing user edits, since it doesn't realize this is a user-initiated
958 // action. 975 // action.
959 [targetController locationBarBridge]->Revert(); 976 [targetController locationBarBridge]->Revert();
977 break;
960 } 978 }
961 } 979 }
962 DCHECK(targetController->browser_.get()); 980 DCHECK(targetController->browser_.get());
963 targetController->browser_->ExecuteCommandWithDisposition(command, 981 targetController->browser_->ExecuteCommandWithDisposition(command,
964 disposition); 982 disposition);
965 } 983 }
966 984
967 // Called when another part of the internal codebase needs to execute a 985 // Called when another part of the internal codebase needs to execute a
968 // command. 986 // command.
969 - (void)executeCommand:(int)command { 987 - (void)executeCommand:(int)command {
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 [shadow.get() setShadowColor:[NSColor colorWithCalibratedWhite:0.0 1471 [shadow.get() setShadowColor:[NSColor colorWithCalibratedWhite:0.0
1454 alpha:0.5]]; 1472 alpha:0.5]];
1455 [shadow.get() setShadowOffset:NSMakeSize(0, -1)]; 1473 [shadow.get() setShadowOffset:NSMakeSize(0, -1)];
1456 [shadow setShadowBlurRadius:2.0]; 1474 [shadow setShadowBlurRadius:2.0];
1457 [incognitoBadge_ setShadow:shadow]; 1475 [incognitoBadge_ setShadow:shadow];
1458 1476
1459 // Install the view. 1477 // Install the view.
1460 [[[[self window] contentView] superview] addSubview:incognitoBadge_]; 1478 [[[[self window] contentView] superview] addSubview:incognitoBadge_];
1461 } 1479 }
1462 1480
1481 -(void)openTabpose:(BOOL)slomo {
1482 [TabposeWindow openTabposeFor:self slomo:slomo];
1483 }
1484
1463 // Documented in 10.6+, but present starting in 10.5. Called when we get a 1485 // Documented in 10.6+, but present starting in 10.5. Called when we get a
1464 // three-finger swipe. 1486 // three-finger swipe.
1465 - (void)swipeWithEvent:(NSEvent*)event { 1487 - (void)swipeWithEvent:(NSEvent*)event {
1466 // Map forwards and backwards to history; left is positive, right is negative. 1488 // Map forwards and backwards to history; left is positive, right is negative.
1467 unsigned int command = 0; 1489 unsigned int command = 0;
1468 if ([event deltaX] > 0.5) { 1490 if ([event deltaX] > 0.5) {
1469 command = IDC_BACK; 1491 command = IDC_BACK;
1470 } else if ([event deltaX] < -0.5) { 1492 } else if ([event deltaX] < -0.5) {
1471 command = IDC_FORWARD; 1493 command = IDC_FORWARD;
1472 } else if ([event deltaY] > 0.5) { 1494 } else if ([event deltaY] > 0.5) {
1473 // TODO(pinkerton): figure out page-up, http://crbug.com/16305 1495 // Do nothing.
1474 } else if ([event deltaY] < -0.5) { 1496 } else if ([event deltaY] < -0.5) {
1475 // TODO(pinkerton): figure out page-down, http://crbug.com/16305 1497 [self openTabpose:([event modifierFlags] & NSShiftKeyMask) != 0];
1476 } 1498 }
1477 1499
1478 // Ensure the command is valid first (ExecuteCommand() won't do that) and 1500 // Ensure the command is valid first (ExecuteCommand() won't do that) and
1479 // then make it so. 1501 // then make it so.
1480 if (browser_->command_updater()->IsCommandEnabled(command)) 1502 if (browser_->command_updater()->IsCommandEnabled(command))
1481 browser_->ExecuteCommandWithDisposition(command, 1503 browser_->ExecuteCommandWithDisposition(command,
1482 event_utils::WindowOpenDispositionFromNSEvent(event)); 1504 event_utils::WindowOpenDispositionFromNSEvent(event));
1483 } 1505 }
1484 1506
1485 // Documented in 10.6+, but present starting in 10.5. Called repeatedly during 1507 // Documented in 10.6+, but present starting in 10.5. Called repeatedly during
(...skipping 374 matching lines...) Expand 10 before | Expand all | Expand 10 after
1860 1882
1861 - (BOOL)supportsBookmarkBar { 1883 - (BOOL)supportsBookmarkBar {
1862 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 1884 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
1863 } 1885 }
1864 1886
1865 - (BOOL)isNormalWindow { 1887 - (BOOL)isNormalWindow {
1866 return browser_->type() == Browser::TYPE_NORMAL; 1888 return browser_->type() == Browser::TYPE_NORMAL;
1867 } 1889 }
1868 1890
1869 @end // @implementation BrowserWindowController(WindowType) 1891 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.h ('k') | chrome/browser/cocoa/tab_strip_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698