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 1022 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1033 // Ignore commands during session restore's browser creation. It uses a | 1033 // Ignore commands during session restore's browser creation. It uses a |
| 1034 // nested message loop and commands dispatched during this operation cause | 1034 // nested message loop and commands dispatched during this operation cause |
| 1035 // havoc. | 1035 // havoc. |
| 1036 if (SessionRestore::IsRestoring(lastProfile) && | 1036 if (SessionRestore::IsRestoring(lastProfile) && |
| 1037 base::MessageLoop::current()->IsNested()) | 1037 base::MessageLoop::current()->IsNested()) |
| 1038 return; | 1038 return; |
| 1039 | 1039 |
| 1040 NSInteger tag = [sender tag]; | 1040 NSInteger tag = [sender tag]; |
| 1041 | 1041 |
| 1042 // If there are no browser windows, and we are trying to open a browser | 1042 // If there are no browser windows, and we are trying to open a browser |
| 1043 // for a locked profile, we have to show the User Manager instead as the | 1043 // for a locked profile or the system profile, we have to show the User |
| 1044 // locked profile needs authentication. | 1044 // Manager instead as the locked profile needs authentication and the system |
| 1045 if (IsProfileSignedOut(lastProfile)) { | 1045 // profile cannot have a browser. |
| 1046 if (IsProfileSignedOut(lastProfile) || lastProfile->IsSystemProfile()) { | |
| 1046 UserManager::Show(base::FilePath(), | 1047 UserManager::Show(base::FilePath(), |
| 1047 profiles::USER_MANAGER_NO_TUTORIAL, | 1048 profiles::USER_MANAGER_NO_TUTORIAL, |
| 1048 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1049 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 1049 return; | 1050 return; |
| 1050 } | 1051 } |
| 1051 | 1052 |
| 1052 switch (tag) { | 1053 switch (tag) { |
| 1053 case IDC_NEW_TAB: | 1054 case IDC_NEW_TAB: |
| 1054 // Create a new tab in an existing browser window (which we activate) if | 1055 // Create a new tab in an existing browser window (which we activate) if |
| 1055 // possible. | 1056 // possible. |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1246 SessionService* sessionService = | 1247 SessionService* sessionService = |
| 1247 SessionServiceFactory::GetForProfileForSessionRestore( | 1248 SessionServiceFactory::GetForProfileForSessionRestore( |
| 1248 [self lastProfile]); | 1249 [self lastProfile]); |
| 1249 if (sessionService && | 1250 if (sessionService && |
| 1250 sessionService->RestoreIfNecessary(std::vector<GURL>())) | 1251 sessionService->RestoreIfNecessary(std::vector<GURL>())) |
| 1251 return NO; | 1252 return NO; |
| 1252 } | 1253 } |
| 1253 } | 1254 } |
| 1254 | 1255 |
| 1255 // Otherwise open a new window. | 1256 // Otherwise open a new window. |
| 1256 // If the last profile was locked, we have to open the User Manager, as the | 1257 // If the last profile was locked, we have to open the User Manager, as the |
|
msw
2015/05/21 04:34:43
nit: update comment for system profile.
Mike Lerman
2015/05/21 15:27:30
Done.
| |
| 1257 // profile requires authentication. Similarly, because guest mode is | 1258 // profile requires authentication. Similarly, because guest mode is |
| 1258 // implemented as forced incognito, we can't open a new guest browser either, | 1259 // implemented as forced incognito, we can't open a new guest browser either, |
| 1259 // so we have to show the User Manager as well. | 1260 // so we have to show the User Manager as well. |
| 1260 Profile* lastProfile = [self lastProfile]; | 1261 Profile* lastProfile = [self lastProfile]; |
| 1261 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile)) { | 1262 if (lastProfile->IsGuestSession() || IsProfileSignedOut(lastProfile) || |
| 1263 lastProfile->IsSystemProfile()) { | |
| 1262 UserManager::Show(base::FilePath(), | 1264 UserManager::Show(base::FilePath(), |
| 1263 profiles::USER_MANAGER_NO_TUTORIAL, | 1265 profiles::USER_MANAGER_NO_TUTORIAL, |
| 1264 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); | 1266 profiles::USER_MANAGER_SELECT_PROFILE_NO_ACTION); |
| 1265 } else { | 1267 } else { |
| 1266 CreateBrowser(lastProfile); | 1268 CreateBrowser(lastProfile); |
| 1267 } | 1269 } |
| 1268 | 1270 |
| 1269 // We've handled the reopen event, so return NO to tell AppKit not | 1271 // We've handled the reopen event, so return NO to tell AppKit not |
| 1270 // to do anything. | 1272 // to do anything. |
| 1271 return NO; | 1273 return NO; |
| (...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1712 | 1714 |
| 1713 //--------------------------------------------------------------------------- | 1715 //--------------------------------------------------------------------------- |
| 1714 | 1716 |
| 1715 namespace app_controller_mac { | 1717 namespace app_controller_mac { |
| 1716 | 1718 |
| 1717 bool IsOpeningNewWindow() { | 1719 bool IsOpeningNewWindow() { |
| 1718 return g_is_opening_new_window; | 1720 return g_is_opening_new_window; |
| 1719 } | 1721 } |
| 1720 | 1722 |
| 1721 } // namespace app_controller_mac | 1723 } // namespace app_controller_mac |
| OLD | NEW |