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

Side by Side Diff: chrome/browser/app_controller_mac.mm

Issue 1299543002: Delete dead signin code (SigninGlobalError) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix mac? Created 5 years, 4 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
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/app_controller_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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/app_controller_mac.h" 5 #import "chrome/browser/app_controller_mac.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 26 matching lines...) Expand all
37 #include "chrome/browser/profiles/profile_info_cache_observer.h" 37 #include "chrome/browser/profiles/profile_info_cache_observer.h"
38 #include "chrome/browser/profiles/profile_manager.h" 38 #include "chrome/browser/profiles/profile_manager.h"
39 #include "chrome/browser/profiles/profiles_state.h" 39 #include "chrome/browser/profiles/profiles_state.h"
40 #include "chrome/browser/sessions/session_restore.h" 40 #include "chrome/browser/sessions/session_restore.h"
41 #include "chrome/browser/sessions/session_service.h" 41 #include "chrome/browser/sessions/session_service.h"
42 #include "chrome/browser/sessions/session_service_factory.h" 42 #include "chrome/browser/sessions/session_service_factory.h"
43 #include "chrome/browser/sessions/tab_restore_service.h" 43 #include "chrome/browser/sessions/tab_restore_service.h"
44 #include "chrome/browser/sessions/tab_restore_service_factory.h" 44 #include "chrome/browser/sessions/tab_restore_service_factory.h"
45 #include "chrome/browser/signin/signin_manager_factory.h" 45 #include "chrome/browser/signin/signin_manager_factory.h"
46 #include "chrome/browser/signin/signin_promo.h" 46 #include "chrome/browser/signin/signin_promo.h"
47 #include "chrome/browser/signin/signin_ui_util.h"
48 #include "chrome/browser/sync/profile_sync_service.h" 47 #include "chrome/browser/sync/profile_sync_service.h"
49 #include "chrome/browser/sync/sync_ui_util.h" 48 #include "chrome/browser/sync/sync_ui_util.h"
50 #include "chrome/browser/ui/browser.h" 49 #include "chrome/browser/ui/browser.h"
51 #include "chrome/browser/ui/browser_command_controller.h" 50 #include "chrome/browser/ui/browser_command_controller.h"
52 #include "chrome/browser/ui/browser_commands.h" 51 #include "chrome/browser/ui/browser_commands.h"
53 #include "chrome/browser/ui/browser_dialogs.h" 52 #include "chrome/browser/ui/browser_dialogs.h"
54 #include "chrome/browser/ui/browser_finder.h" 53 #include "chrome/browser/ui/browser_finder.h"
55 #include "chrome/browser/ui/browser_iterator.h" 54 #include "chrome/browser/ui/browser_iterator.h"
56 #include "chrome/browser/ui/browser_mac.h" 55 #include "chrome/browser/ui/browser_mac.h"
57 #include "chrome/browser/ui/browser_window.h" 56 #include "chrome/browser/ui/browser_window.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 295
297 AppController* app_controller_; // Weak; owns us. 296 AppController* app_controller_; // Weak; owns us.
298 297
299 DISALLOW_COPY_AND_ASSIGN(AppControllerProfileObserver); 298 DISALLOW_COPY_AND_ASSIGN(AppControllerProfileObserver);
300 }; 299 };
301 300
302 @implementation AppController 301 @implementation AppController
303 302
304 @synthesize startupComplete = startupComplete_; 303 @synthesize startupComplete = startupComplete_;
305 304
306 + (void)updateSigninItem:(id)signinItem
307 shouldShow:(BOOL)showSigninMenuItem
308 currentProfile:(Profile*)profile {
309 DCHECK([signinItem isKindOfClass:[NSMenuItem class]]);
310 NSMenuItem* signinMenuItem = static_cast<NSMenuItem*>(signinItem);
311
312 // Look for a separator immediately after the menu item so it can be hidden
313 // or shown appropriately along with the signin menu item.
314 NSMenuItem* followingSeparator = nil;
315 NSMenu* menu = [signinItem menu];
316 if (menu) {
317 NSInteger signinItemIndex = [menu indexOfItem:signinMenuItem];
318 DCHECK_NE(signinItemIndex, -1);
319 if ((signinItemIndex + 1) < [menu numberOfItems]) {
320 NSMenuItem* menuItem = [menu itemAtIndex:(signinItemIndex + 1)];
321 if ([menuItem isSeparatorItem]) {
322 followingSeparator = menuItem;
323 }
324 }
325 }
326
327 base::string16 label = signin_ui_util::GetSigninMenuLabel(profile);
328 [signinMenuItem setTitle:l10n_util::FixUpWindowsStyleLabel(label)];
329 [signinMenuItem setHidden:!showSigninMenuItem];
330 [followingSeparator setHidden:!showSigninMenuItem];
331 }
332
333 - (void)dealloc { 305 - (void)dealloc {
334 [[closeTabMenuItem_ menu] setDelegate:nil]; 306 [[closeTabMenuItem_ menu] setDelegate:nil];
335 [super dealloc]; 307 [super dealloc];
336 } 308 }
337 309
338 // This method is called very early in application startup (ie, before 310 // This method is called very early in application startup (ie, before
339 // the profile is loaded or any preferences have been registered). Defer any 311 // the profile is loaded or any preferences have been registered). Defer any
340 // user-data initialization until -applicationDidFinishLaunching:. 312 // user-data initialization until -applicationDidFinishLaunching:.
341 - (void)awakeFromNib { 313 - (void)awakeFromNib {
342 MacStartupProfiler::GetInstance()->Profile( 314 MacStartupProfiler::GetInstance()->Profile(
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
950 case IDC_SHOW_HISTORY: 922 case IDC_SHOW_HISTORY:
951 case IDC_SHOW_BOOKMARK_MANAGER: 923 case IDC_SHOW_BOOKMARK_MANAGER:
952 enable = ![self keyWindowIsModal]; 924 enable = ![self keyWindowIsModal];
953 break; 925 break;
954 // Browser-level items that open in new windows. 926 // Browser-level items that open in new windows.
955 case IDC_TASK_MANAGER: 927 case IDC_TASK_MANAGER:
956 // Allow the user to open a new window if there's a window-modal 928 // Allow the user to open a new window if there's a window-modal
957 // dialog. 929 // dialog.
958 enable = ![self keyWindowIsModal]; 930 enable = ![self keyWindowIsModal];
959 break; 931 break;
960 case IDC_SHOW_SYNC_SETUP: {
961 Profile* lastProfile = [self lastProfile];
962 // The profile may be NULL during shutdown -- see
963 // http://code.google.com/p/chromium/issues/detail?id=43048 .
964 //
965 // TODO(akalin,viettrungluu): Figure out whether this method
966 // can be prevented from being called if lastProfile is
967 // NULL.
968 if (!lastProfile) {
969 LOG(WARNING)
970 << "NULL lastProfile detected -- not doing anything";
971 break;
972 }
973 SigninManager* signin = SigninManagerFactory::GetForProfile(
974 lastProfile->GetOriginalProfile());
975 enable = signin->IsSigninAllowed() && ![self keyWindowIsModal];
976 [AppController updateSigninItem:item
977 shouldShow:enable
978 currentProfile:lastProfile];
979 break;
980 }
981 #if defined(GOOGLE_CHROME_BUILD) 932 #if defined(GOOGLE_CHROME_BUILD)
982 case IDC_FEEDBACK: 933 case IDC_FEEDBACK:
983 enable = NO; 934 enable = NO;
984 break; 935 break;
985 #endif 936 #endif
986 default: 937 default:
987 enable = menuState_->IsCommandEnabled(tag) ? 938 enable = menuState_->IsCommandEnabled(tag) ?
988 ![self keyWindowIsModal] : NO; 939 ![self keyWindowIsModal] : NO;
989 } 940 }
990 } 941 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 chrome::ShowExtensions(browser, std::string()); 1073 chrome::ShowExtensions(browser, std::string());
1123 else 1074 else
1124 chrome::OpenExtensionsWindow(lastProfile); 1075 chrome::OpenExtensionsWindow(lastProfile);
1125 break; 1076 break;
1126 case IDC_HELP_PAGE_VIA_MENU: 1077 case IDC_HELP_PAGE_VIA_MENU:
1127 if (Browser* browser = ActivateBrowser(lastProfile)) 1078 if (Browser* browser = ActivateBrowser(lastProfile))
1128 chrome::ShowHelp(browser, chrome::HELP_SOURCE_MENU); 1079 chrome::ShowHelp(browser, chrome::HELP_SOURCE_MENU);
1129 else 1080 else
1130 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); 1081 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU);
1131 break; 1082 break;
1132 case IDC_SHOW_SYNC_SETUP:
1133 if (Browser* browser = ActivateBrowser(lastProfile)) {
1134 chrome::ShowBrowserSigninOrSettings(browser,
1135 signin_metrics::SOURCE_MENU);
1136 } else {
1137 chrome::OpenSyncSetupWindow(lastProfile, signin_metrics::SOURCE_MENU);
1138 }
1139 break;
1140 case IDC_TASK_MANAGER: 1083 case IDC_TASK_MANAGER:
1141 chrome::OpenTaskManager(NULL); 1084 chrome::OpenTaskManager(NULL);
1142 break; 1085 break;
1143 case IDC_OPTIONS: 1086 case IDC_OPTIONS:
1144 [self showPreferences:sender]; 1087 [self showPreferences:sender];
1145 break; 1088 break;
1146 } 1089 }
1147 } 1090 }
1148 1091
1149 // Run a (background) application in a new tab. 1092 // Run a (background) application in a new tab.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 menuState_->UpdateCommandEnabled(IDC_FOCUS_SEARCH, true); 1226 menuState_->UpdateCommandEnabled(IDC_FOCUS_SEARCH, true);
1284 menuState_->UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); 1227 menuState_->UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
1285 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true); 1228 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
1286 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); 1229 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
1287 menuState_->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, true); 1230 menuState_->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, true);
1288 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true); 1231 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true);
1289 menuState_->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true); 1232 menuState_->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true);
1290 #if defined(GOOGLE_CHROME_BUILD) 1233 #if defined(GOOGLE_CHROME_BUILD)
1291 menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true); 1234 menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true);
1292 #endif 1235 #endif
1293 menuState_->UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, true);
1294 menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true); 1236 menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true);
1295 } 1237 }
1296 1238
1297 // Conditionally adds the Profile menu to the main menu bar. 1239 // Conditionally adds the Profile menu to the main menu bar.
1298 - (void)initProfileMenu { 1240 - (void)initProfileMenu {
1299 NSMenu* mainMenu = [NSApp mainMenu]; 1241 NSMenu* mainMenu = [NSApp mainMenu];
1300 NSMenuItem* profileMenu = [mainMenu itemWithTag:IDC_PROFILE_MAIN_MENU]; 1242 NSMenuItem* profileMenu = [mainMenu itemWithTag:IDC_PROFILE_MAIN_MENU];
1301 1243
1302 if (!profiles::IsMultipleProfilesEnabled()) { 1244 if (!profiles::IsMultipleProfilesEnabled()) {
1303 [mainMenu removeItem:profileMenu]; 1245 [mainMenu removeItem:profileMenu];
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1712 1654
1713 //--------------------------------------------------------------------------- 1655 //---------------------------------------------------------------------------
1714 1656
1715 namespace app_controller_mac { 1657 namespace app_controller_mac {
1716 1658
1717 bool IsOpeningNewWindow() { 1659 bool IsOpeningNewWindow() {
1718 return g_is_opening_new_window; 1660 return g_is_opening_new_window;
1719 } 1661 }
1720 1662
1721 } // namespace app_controller_mac 1663 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « chrome/browser/app_controller_mac.h ('k') | chrome/browser/app_controller_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698