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

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

Issue 1041313003: MacViews: Remove BrowserWindowController dependency from AppController (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@titlebar
Patch Set: Fix tests Created 5 years, 8 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 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"
11 #include "base/mac/bundle_locations.h" 11 #include "base/mac/bundle_locations.h"
12 #import "base/mac/foundation_util.h" 12 #import "base/mac/foundation_util.h"
13 #include "base/mac/mac_util.h" 13 #include "base/mac/mac_util.h"
14 #import "base/mac/sdk_forward_declarations.h" 14 #import "base/mac/sdk_forward_declarations.h"
15 #include "base/strings/sys_string_conversions.h" 15 #include "base/strings/sys_string_conversions.h"
16 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
17 #include "chrome/app/chrome_command_ids.h" // IDC_* 17 #include "chrome/app/chrome_command_ids.h" // IDC_*
18 #import "chrome/browser/app_controller_mac.h"
18 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 19 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
19 #include "chrome/browser/bookmarks/chrome_bookmark_client.h" 20 #include "chrome/browser/bookmarks/chrome_bookmark_client.h"
20 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h" 21 #include "chrome/browser/bookmarks/chrome_bookmark_client_factory.h"
21 #include "chrome/browser/browser_process.h" 22 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/devtools/devtools_window.h" 23 #include "chrome/browser/devtools/devtools_window.h"
23 #include "chrome/browser/extensions/extension_commands_global_registry.h" 24 #include "chrome/browser/extensions/extension_commands_global_registry.h"
24 #include "chrome/browser/fullscreen.h" 25 #include "chrome/browser/fullscreen.h"
25 #include "chrome/browser/profiles/avatar_menu.h" 26 #include "chrome/browser/profiles/avatar_menu.h"
26 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
27 #include "chrome/browser/profiles/profile_info_cache.h" 28 #include "chrome/browser/profiles/profile_info_cache.h"
28 #include "chrome/browser/profiles/profile_manager.h" 29 #include "chrome/browser/profiles/profile_manager.h"
29 #include "chrome/browser/profiles/profiles_state.h" 30 #include "chrome/browser/profiles/profiles_state.h"
30 #include "chrome/browser/signin/signin_ui_util.h"
31 #include "chrome/browser/themes/theme_service.h" 31 #include "chrome/browser/themes/theme_service.h"
32 #include "chrome/browser/themes/theme_service_factory.h" 32 #include "chrome/browser/themes/theme_service_factory.h"
33 #include "chrome/browser/translate/chrome_translate_client.h" 33 #include "chrome/browser/translate/chrome_translate_client.h"
34 #include "chrome/browser/ui/bookmarks/bookmark_editor.h" 34 #include "chrome/browser/ui/bookmarks/bookmark_editor.h"
35 #include "chrome/browser/ui/bookmarks/bookmark_utils.h" 35 #include "chrome/browser/ui/bookmarks/bookmark_utils.h"
36 #include "chrome/browser/ui/browser.h" 36 #include "chrome/browser/ui/browser.h"
37 #include "chrome/browser/ui/browser_command_controller.h" 37 #include "chrome/browser/ui/browser_command_controller.h"
38 #include "chrome/browser/ui/browser_commands.h" 38 #include "chrome/browser/ui/browser_commands.h"
39 #include "chrome/browser/ui/browser_instant_controller.h" 39 #include "chrome/browser/ui/browser_instant_controller.h"
40 #include "chrome/browser/ui/browser_list.h" 40 #include "chrome/browser/ui/browser_list.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 window = [window parentWindow]; 203 window = [window parentWindow];
204 } 204 }
205 return nil; 205 return nil;
206 } 206 }
207 207
208 + (BrowserWindowController*)browserWindowControllerForView:(NSView*)view { 208 + (BrowserWindowController*)browserWindowControllerForView:(NSView*)view {
209 NSWindow* window = [view window]; 209 NSWindow* window = [view window];
210 return [BrowserWindowController browserWindowControllerForWindow:window]; 210 return [BrowserWindowController browserWindowControllerForWindow:window];
211 } 211 }
212 212
213 + (void)updateSigninItem:(id)signinItem
214 shouldShow:(BOOL)showSigninMenuItem
215 currentProfile:(Profile*)profile {
216 DCHECK([signinItem isKindOfClass:[NSMenuItem class]]);
217 NSMenuItem* signinMenuItem = static_cast<NSMenuItem*>(signinItem);
218
219 // Look for a separator immediately after the menu item so it can be hidden
220 // or shown appropriately along with the signin menu item.
221 NSMenuItem* followingSeparator = nil;
222 NSMenu* menu = [signinItem menu];
223 if (menu) {
224 NSInteger signinItemIndex = [menu indexOfItem:signinMenuItem];
225 DCHECK_NE(signinItemIndex, -1);
226 if ((signinItemIndex + 1) < [menu numberOfItems]) {
227 NSMenuItem* menuItem = [menu itemAtIndex:(signinItemIndex + 1)];
228 if ([menuItem isSeparatorItem]) {
229 followingSeparator = menuItem;
230 }
231 }
232 }
233
234 base::string16 label = signin_ui_util::GetSigninMenuLabel(profile);
235 [signinMenuItem setTitle:l10n_util::FixUpWindowsStyleLabel(label)];
236 [signinMenuItem setHidden:!showSigninMenuItem];
237 [followingSeparator setHidden:!showSigninMenuItem];
238 }
239
240 // Load the browser window nib and do any Cocoa-specific initialization. 213 // Load the browser window nib and do any Cocoa-specific initialization.
241 // Takes ownership of |browser|. Note that the nib also sets this controller 214 // Takes ownership of |browser|. Note that the nib also sets this controller
242 // up as the window's delegate. 215 // up as the window's delegate.
243 - (id)initWithBrowser:(Browser*)browser { 216 - (id)initWithBrowser:(Browser*)browser {
244 return [self initWithBrowser:browser takeOwnership:YES]; 217 return [self initWithBrowser:browser takeOwnership:YES];
245 } 218 }
246 219
247 // Private(TestingAPI) init routine with testing options. 220 // Private(TestingAPI) init routine with testing options.
248 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt { 221 - (id)initWithBrowser:(Browser*)browser takeOwnership:(BOOL)ownIt {
249 bool hasTabStrip = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP); 222 bool hasTabStrip = browser->SupportsWindowFeature(Browser::FEATURE_TABSTRIP);
(...skipping 880 matching lines...) Expand 10 before | Expand all | Expand 10 after
1130 NSString* menuTitle = l10n_util::GetNSString( 1103 NSString* menuTitle = l10n_util::GetNSString(
1131 [self inPresentationMode] ? IDS_EXIT_PRESENTATION_MAC : 1104 [self inPresentationMode] ? IDS_EXIT_PRESENTATION_MAC :
1132 IDS_ENTER_PRESENTATION_MAC); 1105 IDS_ENTER_PRESENTATION_MAC);
1133 [menuItem setTitle:menuTitle]; 1106 [menuItem setTitle:menuTitle];
1134 } 1107 }
1135 break; 1108 break;
1136 } 1109 }
1137 case IDC_SHOW_SIGNIN: { 1110 case IDC_SHOW_SIGNIN: {
1138 Profile* original_profile = 1111 Profile* original_profile =
1139 browser_->profile()->GetOriginalProfile(); 1112 browser_->profile()->GetOriginalProfile();
1140 [BrowserWindowController updateSigninItem:item 1113 [AppController updateSigninItem:item
1141 shouldShow:enable 1114 shouldShow:enable
1142 currentProfile:original_profile]; 1115 currentProfile:original_profile];
1143 break; 1116 break;
1144 } 1117 }
1145 case IDC_BOOKMARK_PAGE: { 1118 case IDC_BOOKMARK_PAGE: {
1146 // Extensions have the ability to hide the bookmark page menu item. 1119 // Extensions have the ability to hide the bookmark page menu item.
1147 // This only affects the bookmark page menu item under the main menu. 1120 // This only affects the bookmark page menu item under the main menu.
1148 // The bookmark page menu item under the wrench menu has its 1121 // The bookmark page menu item under the wrench menu has its
1149 // visibility controlled by WrenchMenuModel. 1122 // visibility controlled by WrenchMenuModel.
1150 bool shouldHide = 1123 bool shouldHide =
1151 chrome::ShouldRemoveBookmarkThisPageUI(browser_->profile()); 1124 chrome::ShouldRemoveBookmarkThisPageUI(browser_->profile());
1152 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item); 1125 NSMenuItem* menuItem = base::mac::ObjCCast<NSMenuItem>(item);
(...skipping 1078 matching lines...) Expand 10 before | Expand all | Expand 10 after
2231 2204
2232 - (BOOL)supportsBookmarkBar { 2205 - (BOOL)supportsBookmarkBar {
2233 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR]; 2206 return [self supportsWindowFeature:Browser::FEATURE_BOOKMARKBAR];
2234 } 2207 }
2235 2208
2236 - (BOOL)isTabbedWindow { 2209 - (BOOL)isTabbedWindow {
2237 return browser_->is_type_tabbed(); 2210 return browser_->is_type_tabbed();
2238 } 2211 }
2239 2212
2240 @end // @implementation BrowserWindowController(WindowType) 2213 @end // @implementation BrowserWindowController(WindowType)
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/browser_window_controller.h ('k') | chrome/browser/ui/cocoa/browser_window_controller_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698