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

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

Issue 631163004: Mac - show user manager before opening browser. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use different app_controller_mac method. use different TaskMgr call. Created 6 years, 2 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) 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 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1000 if (SessionRestore::IsRestoring(lastProfile) && 1000 if (SessionRestore::IsRestoring(lastProfile) &&
1001 base::MessageLoop::current()->IsNested()) 1001 base::MessageLoop::current()->IsNested())
1002 return; 1002 return;
1003 1003
1004 NSInteger tag = [sender tag]; 1004 NSInteger tag = [sender tag];
1005 1005
1006 // If there are no browser windows, and we are trying to open a browser 1006 // If there are no browser windows, and we are trying to open a browser
1007 // for a locked profile, we have to show the User Manager instead as the 1007 // for a locked profile, we have to show the User Manager instead as the
1008 // locked profile needs authentication. 1008 // locked profile needs authentication.
1009 if (IsProfileSignedOut(lastProfile)) { 1009 if (IsProfileSignedOut(lastProfile)) {
1010 UserManager::Show(lastProfile->GetPath(), 1010 UserManager::Show(base::FilePath(),
1011 profiles::USER_MANAGER_NO_TUTORIAL, 1011 profiles::USER_MANAGER_NO_TUTORIAL,
1012 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 1012 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
1013 return; 1013 return;
1014 } 1014 }
1015 1015
1016 switch (tag) { 1016 switch (tag) {
1017 case IDC_NEW_TAB: 1017 case IDC_NEW_TAB:
1018 // Create a new tab in an existing browser window (which we activate) if 1018 // Create a new tab in an existing browser window (which we activate) if
1019 // possible. 1019 // possible.
1020 if (Browser* browser = ActivateBrowser(lastProfile)) { 1020 if (Browser* browser = ActivateBrowser(lastProfile)) {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
1095 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); 1095 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU);
1096 break; 1096 break;
1097 case IDC_SHOW_SYNC_SETUP: 1097 case IDC_SHOW_SYNC_SETUP:
1098 if (Browser* browser = ActivateBrowser(lastProfile)) { 1098 if (Browser* browser = ActivateBrowser(lastProfile)) {
1099 chrome::ShowBrowserSignin(browser, signin::SOURCE_MENU); 1099 chrome::ShowBrowserSignin(browser, signin::SOURCE_MENU);
1100 } else { 1100 } else {
1101 chrome::OpenSyncSetupWindow(lastProfile, signin::SOURCE_MENU); 1101 chrome::OpenSyncSetupWindow(lastProfile, signin::SOURCE_MENU);
1102 } 1102 }
1103 break; 1103 break;
1104 case IDC_TASK_MANAGER: 1104 case IDC_TASK_MANAGER:
1105 content::RecordAction(UserMetricsAction("TaskManager")); 1105 if ([self canOpenNewBrowser]) {
1106 TaskManagerMac::Show(); 1106 // Browser parameter gets ignored on the mac implementation.
1107 chrome::OpenTaskManager(NULL);
1108 } else {
1109 // No way to create a browser, default to the User Manager.
1110 UserManager::Show(base::FilePath(),
1111 profiles::USER_MANAGER_NO_TUTORIAL,
1112 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER);
1113 }
1107 break; 1114 break;
1108 case IDC_OPTIONS: 1115 case IDC_OPTIONS:
1109 [self showPreferences:sender]; 1116 [self showPreferences:sender];
1110 break; 1117 break;
1111 } 1118 }
1112 } 1119 }
1113 1120
1114 // Run a (background) application in a new tab. 1121 // Run a (background) application in a new tab.
1115 - (void)executeApplication:(id)sender { 1122 - (void)executeApplication:(id)sender {
1116 NSInteger tag = [sender tag]; 1123 NSInteger tag = [sender tag];
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1204 } 1211 }
1205 } 1212 }
1206 1213
1207 // Otherwise open a new window. 1214 // Otherwise open a new window.
1208 // If the last profile was locked, we have to open the User Manager, as the 1215 // If the last profile was locked, we have to open the User Manager, as the
1209 // profile requires authentication. Similarly, because guest mode is 1216 // profile requires authentication. Similarly, because guest mode is
1210 // implemented as forced incognito, we can't open a new guest browser either, 1217 // implemented as forced incognito, we can't open a new guest browser either,
1211 // so we have to show the User Manager as well. 1218 // so we have to show the User Manager as well.
1212 Profile* lastProfile = [self lastProfile]; 1219 Profile* lastProfile = [self lastProfile];
1213 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile)) { 1220 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile)) {
1214 UserManager::Show(lastProfile->GetPath(), 1221 UserManager::Show(base::FilePath(),
1215 profiles::USER_MANAGER_NO_TUTORIAL, 1222 profiles::USER_MANAGER_NO_TUTORIAL,
1216 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); 1223 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION);
1217 } else { 1224 } else {
1218 CreateBrowser(lastProfile); 1225 CreateBrowser(lastProfile);
1219 } 1226 }
1220 1227
1221 // We've handled the reopen event, so return NO to tell AppKit not 1228 // We've handled the reopen event, so return NO to tell AppKit not
1222 // to do anything. 1229 // to do anything.
1223 return NO; 1230 return NO;
1224 } 1231 }
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1312 - (Profile*)safeLastProfileForNewWindows { 1319 - (Profile*)safeLastProfileForNewWindows {
1313 Profile* profile = [self lastProfile]; 1320 Profile* profile = [self lastProfile];
1314 1321
1315 // Guest sessions must always be OffTheRecord. Use that when opening windows. 1322 // Guest sessions must always be OffTheRecord. Use that when opening windows.
1316 if (profile->IsGuestSession()) 1323 if (profile->IsGuestSession())
1317 return profile->GetOffTheRecordProfile(); 1324 return profile->GetOffTheRecordProfile();
1318 1325
1319 return profile; 1326 return profile;
1320 } 1327 }
1321 1328
1329 - (bool)canOpenNewBrowser {
Mark Mentovai 2014/10/08 16:43:22 You need to document this.
Mike Lerman 2014/10/08 20:23:41 Done.
1330 Profile* profile = [self safeLastProfileForNewWindows];
1331
1332 const PrefService* prefs = g_browser_process->local_state();
1333 return !profile->IsGuestSession() ||
1334 prefs->GetBoolean(prefs::kBrowserGuestModeEnabled);
1335 }
1336
1322 // Various methods to open URLs that we get in a native fashion. We use 1337 // Various methods to open URLs that we get in a native fashion. We use
1323 // StartupBrowserCreator here because on the other platforms, URLs to open come 1338 // StartupBrowserCreator here because on the other platforms, URLs to open come
1324 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best 1339 // through the ProcessSingleton, and it calls StartupBrowserCreator. It's best
1325 // to bottleneck the openings through that for uniform handling. 1340 // to bottleneck the openings through that for uniform handling.
1326 1341
1327 - (void)openUrls:(const std::vector<GURL>&)urls { 1342 - (void)openUrls:(const std::vector<GURL>&)urls {
1328 // If the browser hasn't started yet, just queue up the URLs. 1343 // If the browser hasn't started yet, just queue up the URLs.
1329 if (!startupComplete_) { 1344 if (!startupComplete_) {
1330 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end()); 1345 startupUrls_.insert(startupUrls_.end(), urls.begin(), urls.end());
1331 return; 1346 return;
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1373 1388
1374 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; 1389 [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess];
1375 } 1390 }
1376 1391
1377 // Show the preferences window, or bring it to the front if it's already 1392 // Show the preferences window, or bring it to the front if it's already
1378 // visible. 1393 // visible.
1379 - (IBAction)showPreferences:(id)sender { 1394 - (IBAction)showPreferences:(id)sender {
1380 if (Browser* browser = ActivateBrowser([self lastProfile])) { 1395 if (Browser* browser = ActivateBrowser([self lastProfile])) {
1381 // Show options tab in the active browser window. 1396 // Show options tab in the active browser window.
1382 chrome::ShowSettings(browser); 1397 chrome::ShowSettings(browser);
1383 } else { 1398 } else if ([self canOpenNewBrowser]) {
1384 // No browser window, so create one for the options tab. 1399 // No browser window, so create one for the options tab.
1385 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); 1400 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]);
1401 } else {
1402 // No way to create a browser, default to the User Manager.
1403 UserManager::Show(base::FilePath(),
1404 profiles::USER_MANAGER_NO_TUTORIAL,
1405 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS);
1386 } 1406 }
1387 } 1407 }
1388 1408
1389 - (IBAction)orderFrontStandardAboutPanel:(id)sender { 1409 - (IBAction)orderFrontStandardAboutPanel:(id)sender {
1390 if (Browser* browser = ActivateBrowser([self lastProfile])) { 1410 if (Browser* browser = ActivateBrowser([self lastProfile])) {
1391 chrome::ShowAboutChrome(browser); 1411 chrome::ShowAboutChrome(browser);
1412 } else if ([self canOpenNewBrowser]) {
1413 // No browser window, so create one for the options tab.
1414 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]);
1392 } else { 1415 } else {
1393 // No browser window, so create one for the about tab. 1416 // No way to create a browser, default to the User Manager.
1394 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); 1417 UserManager::Show(base::FilePath(),
1418 profiles::USER_MANAGER_NO_TUTORIAL,
1419 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME);
1395 } 1420 }
1396 } 1421 }
1397 1422
1398 - (IBAction)toggleConfirmToQuit:(id)sender { 1423 - (IBAction)toggleConfirmToQuit:(id)sender {
1399 PrefService* prefService = g_browser_process->local_state(); 1424 PrefService* prefService = g_browser_process->local_state();
1400 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); 1425 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled);
1401 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); 1426 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled);
1402 } 1427 }
1403 1428
1404 - (IBAction)toggleDisplayMessageCenter:(id)sender { 1429 - (IBAction)toggleDisplayMessageCenter:(id)sender {
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
1580 1605
1581 //--------------------------------------------------------------------------- 1606 //---------------------------------------------------------------------------
1582 1607
1583 namespace app_controller_mac { 1608 namespace app_controller_mac {
1584 1609
1585 bool IsOpeningNewWindow() { 1610 bool IsOpeningNewWindow() {
1586 return g_is_opening_new_window; 1611 return g_is_opening_new_window;
1587 } 1612 }
1588 1613
1589 } // namespace app_controller_mac 1614 } // namespace app_controller_mac
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/profiles/profile_window.h » ('j') | chrome/browser/ui/webui/signin/user_manager_screen_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698