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

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

Issue 322623002: Consolidate SDK forwards in sdk_forward_declarations.h. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit Created 6 years, 6 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 | Annotate | Revision Log
OLDNEW
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 @interface NSWindow (NSPrivateApis) 179 @interface NSWindow (NSPrivateApis)
180 // Note: These functions are private, use -[NSObject respondsToSelector:] 180 // Note: These functions are private, use -[NSObject respondsToSelector:]
181 // before calling them. 181 // before calling them.
182 182
183 - (void)setBottomCornerRounded:(BOOL)rounded; 183 - (void)setBottomCornerRounded:(BOOL)rounded;
184 184
185 - (NSRect)_growBoxRect; 185 - (NSRect)_growBoxRect;
186 186
187 @end 187 @end
188 188
189 // Replicate specific 10.7 SDK declarations for building with prior SDKs.
190 #if !defined(MAC_OS_X_VERSION_10_7) || \
191 MAC_OS_X_VERSION_MAX_ALLOWED < MAC_OS_X_VERSION_10_7
192
193 enum {
194 NSWindowCollectionBehaviorFullScreenPrimary = 1 << 7,
195 NSWindowCollectionBehaviorFullScreenAuxiliary = 1 << 8
196 };
197
198 enum {
199 NSFullScreenWindowMask = 1 << 14
200 };
201
202 @interface NSWindow (LionSDKDeclarations)
203 - (void)setRestorable:(BOOL)flag;
204 @end
205
206 #endif // MAC_OS_X_VERSION_10_7
207
208 @implementation BrowserWindowController 189 @implementation BrowserWindowController
209 190
210 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window { 191 + (BrowserWindowController*)browserWindowControllerForWindow:(NSWindow*)window {
211 while (window) { 192 while (window) {
212 id controller = [window windowController]; 193 id controller = [window windowController];
213 if ([controller isKindOfClass:[BrowserWindowController class]]) 194 if ([controller isKindOfClass:[BrowserWindowController class]])
214 return (BrowserWindowController*)controller; 195 return (BrowserWindowController*)controller;
215 window = [window parentWindow]; 196 window = [window parentWindow];
216 } 197 }
217 return nil; 198 return nil;
(...skipping 822 matching lines...) Expand 10 before | Expand all | Expand 10 after
1040 if (![item respondsToSelector:@selector(state)] || 1021 if (![item respondsToSelector:@selector(state)] ||
1041 ![item respondsToSelector:@selector(setState:)]) 1022 ![item respondsToSelector:@selector(setState:)])
1042 return; 1023 return;
1043 1024
1044 // On Windows this logic happens in bookmark_bar_view.cc. On the 1025 // On Windows this logic happens in bookmark_bar_view.cc. On the
1045 // Mac we're a lot more MVC happy so we've moved it into a 1026 // Mac we're a lot more MVC happy so we've moved it into a
1046 // controller. To be clear, this simply updates the menu item; it 1027 // controller. To be clear, this simply updates the menu item; it
1047 // does not display the bookmark bar itself. 1028 // does not display the bookmark bar itself.
1048 if (tag == IDC_SHOW_BOOKMARK_BAR) { 1029 if (tag == IDC_SHOW_BOOKMARK_BAR) {
1049 bool toggled = windowShim_->IsBookmarkBarVisible(); 1030 bool toggled = windowShim_->IsBookmarkBarVisible();
1050 NSInteger oldState = [item state]; 1031 NSInteger oldState = [(NSMenuItem*)item state];
1051 NSInteger newState = toggled ? NSOnState : NSOffState; 1032 NSInteger newState = toggled ? NSOnState : NSOffState;
1052 if (oldState != newState) 1033 if (oldState != newState)
1053 [item setState:newState]; 1034 [item setState:newState];
1054 } 1035 }
1055 1036
1056 // Update the checked/Unchecked state of items in the encoding menu. 1037 // Update the checked/Unchecked state of items in the encoding menu.
1057 // On Windows, this logic is part of |EncodingMenuModel| in 1038 // On Windows, this logic is part of |EncodingMenuModel| in
1058 // browser/ui/views/toolbar_view.h. 1039 // browser/ui/views/toolbar_view.h.
1059 EncodingMenuController encoding_controller; 1040 EncodingMenuController encoding_controller;
1060 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) { 1041 if (encoding_controller.DoesCommandBelongToEncodingMenu(tag)) {
1061 DCHECK(browser_.get()); 1042 DCHECK(browser_.get());
1062 Profile* profile = browser_->profile(); 1043 Profile* profile = browser_->profile();
1063 DCHECK(profile); 1044 DCHECK(profile);
1064 WebContents* current_tab = 1045 WebContents* current_tab =
1065 browser_->tab_strip_model()->GetActiveWebContents(); 1046 browser_->tab_strip_model()->GetActiveWebContents();
1066 if (!current_tab) 1047 if (!current_tab)
1067 return; 1048 return;
1068 1049
1069 const std::string encoding = current_tab->GetEncoding(); 1050 const std::string encoding = current_tab->GetEncoding();
1070 1051
1071 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag); 1052 bool toggled = encoding_controller.IsItemChecked(profile, encoding, tag);
1072 NSInteger oldState = [item state]; 1053 NSInteger oldState = [(NSMenuItem*)item state];
1073 NSInteger newState = toggled ? NSOnState : NSOffState; 1054 NSInteger newState = toggled ? NSOnState : NSOffState;
1074 if (oldState != newState) 1055 if (oldState != newState)
1075 [item setState:newState]; 1056 [item setState:newState];
1076 } 1057 }
1077 } 1058 }
1078 1059
1079 // Called to validate menu and toolbar items when this window is key. All the 1060 // Called to validate menu and toolbar items when this window is key. All the
1080 // items we care about have been set with the |-commandDispatch:| or 1061 // items we care about have been set with the |-commandDispatch:| or
1081 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder 1062 // |-commandDispatchUsingKeyModifiers:| actions and a target of FirstResponder
1082 // in IB. If it's not one of those, let it continue up the responder chain to be 1063 // in IB. If it's not one of those, let it continue up the responder chain to be
(...skipping 1219 matching lines...) Expand 10 before | Expand all | Expand 10 after
2302 2283
2303 - (BOOL)supportsBookmarkBar { 2284 - (BOOL)supportsBookmarkBar {
2304 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2285 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2305 } 2286 }
2306 2287
2307 - (BOOL)isTabbedWindow { 2288 - (BOOL)isTabbedWindow {
2308 return browser_->is_type_tabbed(); 2289 return browser_->is_type_tabbed();
2309 } 2290 }
2310 2291
2311 @end // @implementation BrowserWindowController(WindowType) 2292 @end // @implementation BrowserWindowController(WindowType)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698