| 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 #include "chrome/browser/profiles/profile_manager.h" | 5 #include "chrome/browser/profiles/profile_manager.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 758 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( | 758 void ProfileManager::BrowserListObserver::OnBrowserSetLastActive( |
| 759 Browser* browser) { | 759 Browser* browser) { |
| 760 // If all browsers are being closed (e.g. the user is in the process of | 760 // If all browsers are being closed (e.g. the user is in the process of |
| 761 // shutting down), this event will be fired after each browser is | 761 // shutting down), this event will be fired after each browser is |
| 762 // closed. This does not represent a user intention to change the active | 762 // closed. This does not represent a user intention to change the active |
| 763 // browser so is not handled here. | 763 // browser so is not handled here. |
| 764 if (profile_manager_->closing_all_browsers_) | 764 if (profile_manager_->closing_all_browsers_) |
| 765 return; | 765 return; |
| 766 | 766 |
| 767 Profile* last_active = browser->profile(); | 767 Profile* last_active = browser->profile(); |
| 768 ProfileInfoCache& cache = profile_manager_->GetProfileInfoCache(); |
| 769 size_t profile_index = |
| 770 cache.GetIndexOfProfileWithPath(last_active->GetPath()); |
| 771 if (profile_index != std::string::npos) { |
| 772 cache.SetProfileActive(profile_index); |
| 773 } |
| 768 | 774 |
| 769 // Don't remember ephemeral profiles as last because they are not going to | 775 // Don't remember ephemeral profiles as last because they are not going to |
| 770 // persist after restart. | 776 // persist after restart. |
| 771 if (last_active->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) | 777 if (last_active->GetPrefs()->GetBoolean(prefs::kForceEphemeralProfiles)) |
| 772 return; | 778 return; |
| 773 | 779 |
| 774 PrefService* local_state = g_browser_process->local_state(); | 780 PrefService* local_state = g_browser_process->local_state(); |
| 775 DCHECK(local_state); | 781 DCHECK(local_state); |
| 776 // Only keep track of profiles that we are managing; tests may create others. | 782 // Only keep track of profiles that we are managing; tests may create others. |
| 777 if (profile_manager_->profiles_info_.find( | 783 if (profile_manager_->profiles_info_.find( |
| (...skipping 471 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1249 ProfileManager::ProfileInfo::ProfileInfo( | 1255 ProfileManager::ProfileInfo::ProfileInfo( |
| 1250 Profile* profile, | 1256 Profile* profile, |
| 1251 bool created) | 1257 bool created) |
| 1252 : profile(profile), | 1258 : profile(profile), |
| 1253 created(created) { | 1259 created(created) { |
| 1254 } | 1260 } |
| 1255 | 1261 |
| 1256 ProfileManager::ProfileInfo::~ProfileInfo() { | 1262 ProfileManager::ProfileInfo::~ProfileInfo() { |
| 1257 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1263 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
| 1258 } | 1264 } |
| OLD | NEW |