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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 // Ignore commands during session restore's browser creation. It uses a | 1025 // Ignore commands during session restore's browser creation. It uses a |
1026 // nested message loop and commands dispatched during this operation cause | 1026 // nested message loop and commands dispatched during this operation cause |
1027 // havoc. | 1027 // havoc. |
1028 if (SessionRestore::IsRestoring(lastProfile) && | 1028 if (SessionRestore::IsRestoring(lastProfile) && |
1029 base::MessageLoop::current()->IsNested()) | 1029 base::MessageLoop::current()->IsNested()) |
1030 return; | 1030 return; |
1031 | 1031 |
1032 NSInteger tag = [sender tag]; | 1032 NSInteger tag = [sender tag]; |
1033 | 1033 |
1034 // If there are no browser windows, and we are trying to open a browser | 1034 // If there are no browser windows, and we are trying to open a browser |
1035 // for a locked profile, we have to show the User Manager instead as the | 1035 // for a locked profile or the system profile, we have to show the User |
1036 // locked profile needs authentication. | 1036 // Manager instead as the locked profile needs authentication and the system |
1037 if (IsProfileSignedOut(lastProfile)) { | 1037 // profile cannot have a browser. |
| 1038 if (IsProfileSignedOut(lastProfile) || lastProfile->IsSystemProfile()) { |
1038 UserManager::Show(base::FilePath(), | 1039 UserManager::Show(base::FilePath(), |
1039 profiles::USER_MANAGER_NO_TUTORIAL, | 1040 profiles::USER_MANAGER_NO_TUTORIAL, |
1040 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1041 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
1041 return; | 1042 return; |
1042 } | 1043 } |
1043 | 1044 |
1044 switch (tag) { | 1045 switch (tag) { |
1045 case IDC_NEW_TAB: | 1046 case IDC_NEW_TAB: |
1046 // Create a new tab in an existing browser window (which we activate) if | 1047 // Create a new tab in an existing browser window (which we activate) if |
1047 // possible. | 1048 // possible. |
(...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1239 SessionServiceFactory::GetForProfileForSessionRestore( | 1240 SessionServiceFactory::GetForProfileForSessionRestore( |
1240 [self lastProfile]); | 1241 [self lastProfile]); |
1241 if (sessionService && | 1242 if (sessionService && |
1242 sessionService->RestoreIfNecessary(std::vector<GURL>())) | 1243 sessionService->RestoreIfNecessary(std::vector<GURL>())) |
1243 return NO; | 1244 return NO; |
1244 } | 1245 } |
1245 } | 1246 } |
1246 | 1247 |
1247 // Otherwise open a new window. | 1248 // Otherwise open a new window. |
1248 // If the last profile was locked, we have to open the User Manager, as the | 1249 // If the last profile was locked, we have to open the User Manager, as the |
1249 // profile requires authentication. Similarly, because guest mode is | 1250 // profile requires authentication. Similarly, because guest mode and system |
1250 // implemented as forced incognito, we can't open a new guest browser either, | 1251 // profile are implemented as forced incognito, we can't open a new guest |
1251 // so we have to show the User Manager as well. | 1252 // browser either, so we have to show the User Manager as well. |
1252 Profile* lastProfile = [self lastProfile]; | 1253 Profile* lastProfile = [self lastProfile]; |
1253 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile)) { | 1254 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile) || |
| 1255 lastProfile->IsSystemProfile()) { |
1254 UserManager::Show(base::FilePath(), | 1256 UserManager::Show(base::FilePath(), |
1255 profiles::USER_MANAGER_NO_TUTORIAL, | 1257 profiles::USER_MANAGER_NO_TUTORIAL, |
1256 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1258 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
1257 } else { | 1259 } else { |
1258 CreateBrowser(lastProfile); | 1260 CreateBrowser(lastProfile); |
1259 } | 1261 } |
1260 | 1262 |
1261 // We've handled the reopen event, so return NO to tell AppKit not | 1263 // We've handled the reopen event, so return NO to tell AppKit not |
1262 // to do anything. | 1264 // to do anything. |
1263 return NO; | 1265 return NO; |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 | 1706 |
1705 //--------------------------------------------------------------------------- | 1707 //--------------------------------------------------------------------------- |
1706 | 1708 |
1707 namespace app_controller_mac { | 1709 namespace app_controller_mac { |
1708 | 1710 |
1709 bool IsOpeningNewWindow() { | 1711 bool IsOpeningNewWindow() { |
1710 return g_is_opening_new_window; | 1712 return g_is_opening_new_window; |
1711 } | 1713 } |
1712 | 1714 |
1713 } // namespace app_controller_mac | 1715 } // namespace app_controller_mac |
OLD | NEW |