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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 } | 958 } |
959 | 959 |
960 NSInteger tag = [sender tag]; | 960 NSInteger tag = [sender tag]; |
961 | 961 |
962 // If there are no browser windows, and we are trying to open a browser | 962 // If there are no browser windows, and we are trying to open a browser |
963 // for a locked profile or the system profile, we have to show the User | 963 // for a locked profile or the system profile, we have to show the User |
964 // Manager instead as the locked profile needs authentication and the system | 964 // Manager instead as the locked profile needs authentication and the system |
965 // profile cannot have a browser. | 965 // profile cannot have a browser. |
966 if (IsProfileSignedOut(lastProfile) || lastProfile->IsSystemProfile()) { | 966 if (IsProfileSignedOut(lastProfile) || lastProfile->IsSystemProfile()) { |
967 UserManager::Show(base::FilePath(), | 967 UserManager::Show(base::FilePath(), |
968 profiles::USER_MANAGER_NO_TUTORIAL, | |
969 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 968 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
970 return; | 969 return; |
971 } | 970 } |
972 | 971 |
973 switch (tag) { | 972 switch (tag) { |
974 case IDC_NEW_TAB: | 973 case IDC_NEW_TAB: |
975 // Create a new tab in an existing browser window (which we activate) if | 974 // Create a new tab in an existing browser window (which we activate) if |
976 // possible. | 975 // possible. |
977 if (Browser* browser = ActivateBrowser(lastProfile)) { | 976 if (Browser* browser = ActivateBrowser(lastProfile)) { |
978 chrome::ExecuteCommand(browser, IDC_NEW_TAB); | 977 chrome::ExecuteCommand(browser, IDC_NEW_TAB); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 | 1162 |
1164 // Otherwise open a new window. | 1163 // Otherwise open a new window. |
1165 // If the last profile was locked, we have to open the User Manager, as the | 1164 // If the last profile was locked, we have to open the User Manager, as the |
1166 // profile requires authentication. Similarly, because guest mode and system | 1165 // profile requires authentication. Similarly, because guest mode and system |
1167 // profile are implemented as forced incognito, we can't open a new guest | 1166 // profile are implemented as forced incognito, we can't open a new guest |
1168 // browser either, so we have to show the User Manager as well. | 1167 // browser either, so we have to show the User Manager as well. |
1169 Profile* lastProfile = [self lastProfile]; | 1168 Profile* lastProfile = [self lastProfile]; |
1170 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile) || | 1169 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile) || |
1171 lastProfile->IsSystemProfile()) { | 1170 lastProfile->IsSystemProfile()) { |
1172 UserManager::Show(base::FilePath(), | 1171 UserManager::Show(base::FilePath(), |
1173 profiles::USER_MANAGER_NO_TUTORIAL, | |
1174 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1172 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
1175 } else { | 1173 } else { |
1176 CreateBrowser(lastProfile); | 1174 CreateBrowser(lastProfile); |
1177 } | 1175 } |
1178 | 1176 |
1179 // We've handled the reopen event, so return NO to tell AppKit not | 1177 // We've handled the reopen event, so return NO to tell AppKit not |
1180 // to do anything. | 1178 // to do anything. |
1181 return NO; | 1179 return NO; |
1182 } | 1180 } |
1183 | 1181 |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1335 - (IBAction)showPreferences:(id)sender { | 1333 - (IBAction)showPreferences:(id)sender { |
1336 if (Browser* browser = ActivateBrowser([self lastProfile])) { | 1334 if (Browser* browser = ActivateBrowser([self lastProfile])) { |
1337 // Show options tab in the active browser window. | 1335 // Show options tab in the active browser window. |
1338 chrome::ShowSettings(browser); | 1336 chrome::ShowSettings(browser); |
1339 } else if ([self canOpenNewBrowser]) { | 1337 } else if ([self canOpenNewBrowser]) { |
1340 // No browser window, so create one for the options tab. | 1338 // No browser window, so create one for the options tab. |
1341 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); | 1339 chrome::OpenOptionsWindow([self safeLastProfileForNewWindows]); |
1342 } else { | 1340 } else { |
1343 // No way to create a browser, default to the User Manager. | 1341 // No way to create a browser, default to the User Manager. |
1344 UserManager::Show(base::FilePath(), | 1342 UserManager::Show(base::FilePath(), |
1345 profiles::USER_MANAGER_NO_TUTORIAL, | |
1346 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS); | 1343 profiles::USER_MANAGER_SELECT_PROFILE_CHROME_SETTINGS); |
1347 } | 1344 } |
1348 } | 1345 } |
1349 | 1346 |
1350 - (IBAction)orderFrontStandardAboutPanel:(id)sender { | 1347 - (IBAction)orderFrontStandardAboutPanel:(id)sender { |
1351 if (Browser* browser = ActivateBrowser([self lastProfile])) { | 1348 if (Browser* browser = ActivateBrowser([self lastProfile])) { |
1352 chrome::ShowAboutChrome(browser); | 1349 chrome::ShowAboutChrome(browser); |
1353 } else if ([self canOpenNewBrowser]) { | 1350 } else if ([self canOpenNewBrowser]) { |
1354 // No browser window, so create one for the options tab. | 1351 // No browser window, so create one for the options tab. |
1355 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); | 1352 chrome::OpenAboutWindow([self safeLastProfileForNewWindows]); |
1356 } else { | 1353 } else { |
1357 // No way to create a browser, default to the User Manager. | 1354 // No way to create a browser, default to the User Manager. |
1358 UserManager::Show(base::FilePath(), | 1355 UserManager::Show(base::FilePath(), |
1359 profiles::USER_MANAGER_NO_TUTORIAL, | |
1360 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME); | 1356 profiles::USER_MANAGER_SELECT_PROFILE_ABOUT_CHROME); |
1361 } | 1357 } |
1362 } | 1358 } |
1363 | 1359 |
1364 - (IBAction)toggleConfirmToQuit:(id)sender { | 1360 - (IBAction)toggleConfirmToQuit:(id)sender { |
1365 PrefService* prefService = g_browser_process->local_state(); | 1361 PrefService* prefService = g_browser_process->local_state(); |
1366 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); | 1362 bool enabled = prefService->GetBoolean(prefs::kConfirmToQuitEnabled); |
1367 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); | 1363 prefService->SetBoolean(prefs::kConfirmToQuitEnabled, !enabled); |
1368 } | 1364 } |
1369 | 1365 |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1616 | 1612 |
1617 //--------------------------------------------------------------------------- | 1613 //--------------------------------------------------------------------------- |
1618 | 1614 |
1619 namespace app_controller_mac { | 1615 namespace app_controller_mac { |
1620 | 1616 |
1621 bool IsOpeningNewWindow() { | 1617 bool IsOpeningNewWindow() { |
1622 return g_is_opening_new_window; | 1618 return g_is_opening_new_window; |
1623 } | 1619 } |
1624 | 1620 |
1625 } // namespace app_controller_mac | 1621 } // namespace app_controller_mac |
OLD | NEW |