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 879 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
890 TabRestoreServiceFactory::GetForProfile([self lastProfile]); | 890 TabRestoreServiceFactory::GetForProfile([self lastProfile]); |
891 return service && !service->entries().empty(); | 891 return service && !service->entries().empty(); |
892 } | 892 } |
893 | 893 |
894 // Called from the AppControllerProfileObserver every time a profile is deleted. | 894 // Called from the AppControllerProfileObserver every time a profile is deleted. |
895 - (void)profileWasRemoved:(const base::FilePath&)profilePath { | 895 - (void)profileWasRemoved:(const base::FilePath&)profilePath { |
896 // If the lastProfile has been deleted, the profile manager has | 896 // If the lastProfile has been deleted, the profile manager has |
897 // already loaded a new one, so the pointer needs to be updated; | 897 // already loaded a new one, so the pointer needs to be updated; |
898 // otherwise we will try to start up a browser window with a pointer | 898 // otherwise we will try to start up a browser window with a pointer |
899 // to the old profile. | 899 // to the old profile. |
900 if (lastProfile_ && profilePath == lastProfile_->GetPath()) | 900 // In a browser test, the application is not brought to the front, so |
| 901 // |lastProfile_| might be null. |
| 902 if (!lastProfile_ || profilePath == lastProfile_->GetPath()) |
901 lastProfile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); | 903 lastProfile_ = g_browser_process->profile_manager()->GetLastUsedProfile(); |
902 | 904 |
903 auto it = profileBookmarkMenuBridgeMap_.find(profilePath); | 905 auto it = profileBookmarkMenuBridgeMap_.find(profilePath); |
904 if (it != profileBookmarkMenuBridgeMap_.end()) { | 906 if (it != profileBookmarkMenuBridgeMap_.end()) { |
905 delete it->second; | 907 delete it->second; |
906 profileBookmarkMenuBridgeMap_.erase(it); | 908 profileBookmarkMenuBridgeMap_.erase(it); |
907 } | 909 } |
908 } | 910 } |
909 | 911 |
910 // Returns true if there is a modal window (either window- or application- | 912 // Returns true if there is a modal window (either window- or application- |
(...skipping 796 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1707 | 1709 |
1708 //--------------------------------------------------------------------------- | 1710 //--------------------------------------------------------------------------- |
1709 | 1711 |
1710 namespace app_controller_mac { | 1712 namespace app_controller_mac { |
1711 | 1713 |
1712 bool IsOpeningNewWindow() { | 1714 bool IsOpeningNewWindow() { |
1713 return g_is_opening_new_window; | 1715 return g_is_opening_new_window; |
1714 } | 1716 } |
1715 | 1717 |
1716 } // namespace app_controller_mac | 1718 } // namespace app_controller_mac |
OLD | NEW |