Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 if (!switches::IsNewProfileManagement()) | 198 if (!switches::IsNewProfileManagement()) |
| 199 return false; | 199 return false; |
| 200 ProfileInfoCache& cache = | 200 ProfileInfoCache& cache = |
| 201 g_browser_process->profile_manager()->GetProfileInfoCache(); | 201 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 202 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); | 202 size_t profile_index = cache.GetIndexOfProfileWithPath(profile->GetPath()); |
| 203 if (profile_index == std::string::npos) | 203 if (profile_index == std::string::npos) |
| 204 return false; | 204 return false; |
| 205 return cache.ProfileIsSigninRequiredAtIndex(profile_index); | 205 return cache.ProfileIsSigninRequiredAtIndex(profile_index); |
| 206 } | 206 } |
| 207 | 207 |
| 208 bool IsGuestModeEnabled() { | |
| 209 const PrefService* prefs = g_browser_process->local_state(); | |
| 210 return prefs->GetBoolean(prefs::kBrowserGuestModeEnabled); | |
| 211 } | |
| 212 | |
| 208 } // anonymous namespace | 213 } // anonymous namespace |
| 209 | 214 |
| 210 @interface AppController (Private) | 215 @interface AppController (Private) |
| 211 - (void)initMenuState; | 216 - (void)initMenuState; |
| 212 - (void)initProfileMenu; | 217 - (void)initProfileMenu; |
| 213 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; | 218 - (void)updateConfirmToQuitPrefMenuItem:(NSMenuItem*)item; |
| 214 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; | 219 - (void)updateDisplayMessageCenterPrefMenuItem:(NSMenuItem*)item; |
| 215 - (void)registerServicesMenuTypesTo:(NSApplication*)app; | 220 - (void)registerServicesMenuTypesTo:(NSApplication*)app; |
| 216 - (void)openUrls:(const std::vector<GURL>&)urls; | 221 - (void)openUrls:(const std::vector<GURL>&)urls; |
| 217 - (void)getUrl:(NSAppleEventDescriptor*)event | 222 - (void)getUrl:(NSAppleEventDescriptor*)event |
| (...skipping 876 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1094 else | 1099 else |
| 1095 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); | 1100 chrome::OpenHelpWindow(lastProfile, chrome::HELP_SOURCE_MENU); |
| 1096 break; | 1101 break; |
| 1097 case IDC_SHOW_SYNC_SETUP: | 1102 case IDC_SHOW_SYNC_SETUP: |
| 1098 if (Browser* browser = ActivateBrowser(lastProfile)) { | 1103 if (Browser* browser = ActivateBrowser(lastProfile)) { |
| 1099 chrome::ShowBrowserSignin(browser, signin::SOURCE_MENU); | 1104 chrome::ShowBrowserSignin(browser, signin::SOURCE_MENU); |
| 1100 } else { | 1105 } else { |
| 1101 chrome::OpenSyncSetupWindow(lastProfile, signin::SOURCE_MENU); | 1106 chrome::OpenSyncSetupWindow(lastProfile, signin::SOURCE_MENU); |
| 1102 } | 1107 } |
| 1103 break; | 1108 break; |
| 1104 case IDC_TASK_MANAGER: | 1109 case IDC_TASK_MANAGER: |
|
Mark Mentovai
2014/10/07 20:22:57
How does the task manager interact with this? It’s
Mike Lerman
2014/10/08 15:41:37
Web UI can be launched from the "Stats for nerds"
Mark Mentovai
2014/10/08 16:43:22
Mike Lerman wrote:
Mike Lerman
2014/10/08 20:23:41
Ok. I can do this for Mac implementation (Windows
| |
| 1105 content::RecordAction(UserMetricsAction("TaskManager")); | 1110 if ([self safeLastProfileForNewWindows]->IsGuestSession() && |
| 1106 TaskManagerMac::Show(); | 1111 !IsGuestModeEnabled()) { |
| 1112 UserManager::Show(lastProfile->GetPath(), | |
| 1113 profiles::USER_MANAGER_NO_TUTORIAL, | |
| 1114 profiles::USER_MANAGER_SELECT_PROFILE_TASK_MANAGER); | |
| 1115 } else { | |
| 1116 content::RecordAction(UserMetricsAction("TaskManager")); | |
| 1117 TaskManagerMac::Show(); | |
| 1118 } | |
| 1107 break; | 1119 break; |
| 1108 case IDC_OPTIONS: | 1120 case IDC_OPTIONS: |
| 1109 [self showPreferences:sender]; | 1121 [self showPreferences:sender]; |
| 1110 break; | 1122 break; |
| 1111 } | 1123 } |
| 1112 } | 1124 } |
| 1113 | 1125 |
| 1114 // Run a (background) application in a new tab. | 1126 // Run a (background) application in a new tab. |
| 1115 - (void)executeApplication:(id)sender { | 1127 - (void)executeApplication:(id)sender { |
| 1116 NSInteger tag = [sender tag]; | 1128 NSInteger tag = [sender tag]; |
| (...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1375 } | 1387 } |
| 1376 | 1388 |
| 1377 // Show the preferences window, or bring it to the front if it's already | 1389 // Show the preferences window, or bring it to the front if it's already |
| 1378 // visible. | 1390 // visible. |
| 1379 - (IBAction)showPreferences:(id)sender { | 1391 - (IBAction)showPreferences:(id)sender { |
| 1380 if (Browser* browser = ActivateBrowser([self lastProfile])) { | 1392 if (Browser* browser = ActivateBrowser([self lastProfile])) { |
| 1381 // Show options tab in the active browser window. | 1393 // Show options tab in the active browser window. |
| 1382 chrome::ShowSettings(browser); | 1394 chrome::ShowSettings(browser); |
| 1383 } else { | 1395 } else { |
| 1384 // No browser window, so create one for the options tab. | 1396 // No browser window, so create one for the options tab. |
| 1385 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); | 1397 Profile* lastProfile = [self safeLastProfileForNewWindows]; |
| 1398 if (lastProfile->IsGuestSession() && !IsGuestModeEnabled()) { | |
| 1399 UserManager::Show(lastProfile->GetPath(), | |
| 1400 profiles::USER_MANAGER_NO_TUTORIAL, | |
| 1401 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS); | |
| 1402 } else { | |
| 1403 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); | |
| 1404 } | |
| 1386 } | 1405 } |
| 1387 } | 1406 } |
| 1388 | 1407 |
| 1389 - (IBAction)orderFrontStandardAboutPanel:(id)sender { | 1408 - (IBAction)orderFrontStandardAboutPanel:(id)sender { |
| 1390 if (Browser* browser = ActivateBrowser([self lastProfile])) { | 1409 if (Browser* browser = ActivateBrowser([self lastProfile])) { |
| 1391 chrome::ShowAboutChrome(browser); | 1410 chrome::ShowAboutChrome(browser); |
| 1392 } else { | 1411 } else { |
| 1393 // No browser window, so create one for the about tab. | 1412 // No browser window, so create one for the about tab. |
| 1394 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); | 1413 Profile* lastProfile = [self safeLastProfileForNewWindows]; |
| 1414 if (lastProfile->IsGuestSession() && !IsGuestModeEnabled()) { | |
|
Mark Mentovai
2014/10/07 20:22:57
This is getting kind of repetitive. Maybe it could
Mike Lerman
2014/10/08 15:41:37
Done - refactored.
| |
| 1415 UserManager::Show(lastProfile->GetPath(), | |
| 1416 profiles::USER_MANAGER_NO_TUTORIAL, | |
| 1417 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME); | |
| 1418 } else { | |
| 1419 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); | |
| 1420 } | |
| 1395 } | 1421 } |
| 1396 } | 1422 } |
| 1397 | 1423 |
| 1398 - (IBAction)toggleConfirmToQuit:(id)sender { | 1424 - (IBAction)toggleConfirmToQuit:(id)sender { |
| 1399 PrefService* prefService = g_browser_process->local_state(); | 1425 PrefService* prefService = g_browser_process->local_state(); |
| 1400 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); | 1426 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); |
| 1401 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); | 1427 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); |
| 1402 } | 1428 } |
| 1403 | 1429 |
| 1404 - (IBAction)toggleDisplayMessageCenter:(id)sender { | 1430 - (IBAction)toggleDisplayMessageCenter:(id)sender { |
| (...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1580 | 1606 |
| 1581 //--------------------------------------------------------------------------- | 1607 //--------------------------------------------------------------------------- |
| 1582 | 1608 |
| 1583 namespace app_controller_mac { | 1609 namespace app_controller_mac { |
| 1584 | 1610 |
| 1585 bool IsOpeningNewWindow() { | 1611 bool IsOpeningNewWindow() { |
| 1586 return g_is_opening_new_window; | 1612 return g_is_opening_new_window; |
| 1587 } | 1613 } |
| 1588 | 1614 |
| 1589 } // namespace app_controller_mac | 1615 } // namespace app_controller_mac |
| OLD | NEW |