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

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

Issue 1301583004: Revert of Delete dead signin code (SigninGlobalError) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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"
47 #include "chrome/browser/sync/profile_sync_service.h" 48 #include "chrome/browser/sync/profile_sync_service.h"
48 #include "chrome/browser/sync/sync_ui_util.h" 49 #include "chrome/browser/sync/sync_ui_util.h"
49 #include "chrome/browser/ui/browser.h" 50 #include "chrome/browser/ui/browser.h"
50 #include "chrome/browser/ui/browser_command_controller.h" 51 #include "chrome/browser/ui/browser_command_controller.h"
51 #include "chrome/browser/ui/browser_commands.h" 52 #include "chrome/browser/ui/browser_commands.h"
52 #include "chrome/browser/ui/browser_dialogs.h" 53 #include "chrome/browser/ui/browser_dialogs.h"
53 #include "chrome/browser/ui/browser_finder.h" 54 #include "chrome/browser/ui/browser_finder.h"
54 #include "chrome/browser/ui/browser_iterator.h" 55 #include "chrome/browser/ui/browser_iterator.h"
55 #include "chrome/browser/ui/browser_mac.h" 56 #include "chrome/browser/ui/browser_mac.h"
56 #include "chrome/browser/ui/browser_window.h" 57 #include "chrome/browser/ui/browser_window.h"
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
295 296
296 AppController* app_controller_; // Weak; owns us. 297 AppController* app_controller_; // Weak; owns us.
297 298
298 DISALLOW_COPY_AND_ASSIGN(AppControllerProfileObserver); 299 DISALLOW_COPY_AND_ASSIGN(AppControllerProfileObserver);
299 }; 300 };
300 301
301 @implementation AppController 302 @implementation AppController
302 303
303 @synthesize startupComplete = startupComplete_; 304 @synthesize startupComplete = startupComplete_;
304 305
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
305 - (void)dealloc { 333 - (void)dealloc {
306 [[closeTabMenuItem_ menu] setDelegate:nil]; 334 [[closeTabMenuItem_ menu] setDelegate:nil];
307 [super dealloc]; 335 [super dealloc];
308 } 336 }
309 337
310 // This method is called very early in application startup (ie, before 338 // This method is called very early in application startup (ie, before
311 // the profile is loaded or any preferences have been registered). Defer any 339 // the profile is loaded or any preferences have been registered). Defer any
312 // user-data initialization until -applicationDidFinishLaunching:. 340 // user-data initialization until -applicationDidFinishLaunching:.
313 - (void)awakeFromNib { 341 - (void)awakeFromNib {
314 MacStartupProfiler::GetInstance()->Profile( 342 MacStartupProfiler::GetInstance()->Profile(
(...skipping 607 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 case IDC_SHOW_HISTORY: 950 case IDC_SHOW_HISTORY:
923 case IDC_SHOW_BOOKMARK_MANAGER: 951 case IDC_SHOW_BOOKMARK_MANAGER:
924 enable = ![self keyWindowIsModal]; 952 enable = ![self keyWindowIsModal];
925 break; 953 break;
926 // Browser-level items that open in new windows. 954 // Browser-level items that open in new windows.
927 case IDC_TASK_MANAGER: 955 case IDC_TASK_MANAGER:
928 // Allow the user to open a new window if there's a window-modal 956 // Allow the user to open a new window if there's a window-modal
929 // dialog. 957 // dialog.
930 enable = ![self keyWindowIsModal]; 958 enable = ![self keyWindowIsModal];
931 break; 959 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 }
932 #if defined(GOOGLE_CHROME_BUILD) 981 #if defined(GOOGLE_CHROME_BUILD)
933 case IDC_FEEDBACK: 982 case IDC_FEEDBACK:
934 enable = NO; 983 enable = NO;
935 break; 984 break;
936 #endif 985 #endif
937 default: 986 default:
938 enable = menuState_->IsCommandEnabled(tag) ? 987 enable = menuState_->IsCommandEnabled(tag) ?
939 ![self keyWindowIsModal] : NO; 988 ![self keyWindowIsModal] : NO;
940 } 989 }
941 } 990 }
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1073 chrome::ShowExtensions(browser, std::string()); 1122 chrome::ShowExtensions(browser, std::string());
1074 else 1123 else
1075 chrome::OpenExtensionsWindow(lastProfile); 1124 chrome::OpenExtensionsWindow(lastProfile);
1076 break; 1125 break;
1077 case IDC_HELP_PAGE_VIA_MENU: 1126 case IDC_HELP_PAGE_VIA_MENU:
1078 if (Browser* browser = ActivateBrowser(lastProfile)) 1127 if (Browser* browser = ActivateBrowser(lastProfile))
1079 chrome::ShowHelp(browser, chrome::HELP_SOURCE_MENU); 1128 chrome::ShowHelp(browser, chrome::HELP_SOURCE_MENU);
1080 else 1129 else
1081 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); 1130 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU);
1082 break; 1131 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;
1083 case IDC_TASK_MANAGER: 1140 case IDC_TASK_MANAGER:
1084 chrome::OpenTaskManager(NULL); 1141 chrome::OpenTaskManager(NULL);
1085 break; 1142 break;
1086 case IDC_OPTIONS: 1143 case IDC_OPTIONS:
1087 [self showPreferences:sender]; 1144 [self showPreferences:sender];
1088 break; 1145 break;
1089 } 1146 }
1090 } 1147 }
1091 1148
1092 // Run a (background) application in a new tab. 1149 // Run a (background) application in a new tab.
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1226 menuState_->UpdateCommandEnabled(IDC_FOCUS_SEARCH, true); 1283 menuState_->UpdateCommandEnabled(IDC_FOCUS_SEARCH, true);
1227 menuState_->UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true); 1284 menuState_->UpdateCommandEnabled(IDC_SHOW_BOOKMARK_MANAGER, true);
1228 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true); 1285 menuState_->UpdateCommandEnabled(IDC_SHOW_HISTORY, true);
1229 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true); 1286 menuState_->UpdateCommandEnabled(IDC_SHOW_DOWNLOADS, true);
1230 menuState_->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, true); 1287 menuState_->UpdateCommandEnabled(IDC_MANAGE_EXTENSIONS, true);
1231 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true); 1288 menuState_->UpdateCommandEnabled(IDC_HELP_PAGE_VIA_MENU, true);
1232 menuState_->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true); 1289 menuState_->UpdateCommandEnabled(IDC_IMPORT_SETTINGS, true);
1233 #if defined(GOOGLE_CHROME_BUILD) 1290 #if defined(GOOGLE_CHROME_BUILD)
1234 menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true); 1291 menuState_->UpdateCommandEnabled(IDC_FEEDBACK, true);
1235 #endif 1292 #endif
1293 menuState_->UpdateCommandEnabled(IDC_SHOW_SYNC_SETUP, true);
1236 menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true); 1294 menuState_->UpdateCommandEnabled(IDC_TASK_MANAGER, true);
1237 } 1295 }
1238 1296
1239 // Conditionally adds the Profile menu to the main menu bar. 1297 // Conditionally adds the Profile menu to the main menu bar.
1240 - (void)initProfileMenu { 1298 - (void)initProfileMenu {
1241 NSMenu* mainMenu = [NSApp mainMenu]; 1299 NSMenu* mainMenu = [NSApp mainMenu];
1242 NSMenuItem* profileMenu = [mainMenu itemWithTag:IDC_PROFILE_MAIN_MENU]; 1300 NSMenuItem* profileMenu = [mainMenu itemWithTag:IDC_PROFILE_MAIN_MENU];
1243 1301
1244 if (!profiles::IsMultipleProfilesEnabled()) { 1302 if (!profiles::IsMultipleProfilesEnabled()) {
1245 [mainMenu removeItem:profileMenu]; 1303 [mainMenu removeItem:profileMenu];
(...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after
1654 1712
1655 //--------------------------------------------------------------------------- 1713 //---------------------------------------------------------------------------
1656 1714
1657 namespace app_controller_mac { 1715 namespace app_controller_mac {
1658 1716
1659 bool IsOpeningNewWindow() { 1717 bool IsOpeningNewWindow() {
1660 return g_is_opening_new_window; 1718 return g_is_opening_new_window;
1661 } 1719 }
1662 1720
1663 } // namespace app_controller_mac 1721 } // 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