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 <set> | 5 #include <set> |
6 | 6 |
7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
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 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 save_active_profiles = true; | 554 save_active_profiles = true; |
555 break; | 555 break; |
556 } | 556 } |
557 case chrome::NOTIFICATION_BROWSER_OPENED: { | 557 case chrome::NOTIFICATION_BROWSER_OPENED: { |
558 Browser* browser = content::Source<Browser>(source).ptr(); | 558 Browser* browser = content::Source<Browser>(source).ptr(); |
559 DCHECK(browser); | 559 DCHECK(browser); |
560 Profile* profile = browser->profile(); | 560 Profile* profile = browser->profile(); |
561 DCHECK(profile); | 561 DCHECK(profile); |
562 if (!profile->IsOffTheRecord() && ++browser_counts_[profile] == 1) { | 562 if (!profile->IsOffTheRecord() && ++browser_counts_[profile] == 1) { |
563 active_profiles_.push_back(profile); | 563 active_profiles_.push_back(profile); |
564 save_active_profiles = !closing_all_browsers_; | 564 save_active_profiles = true; |
565 } | 565 } |
| 566 // If browsers are opening, we can't be closing all the browsers. This |
| 567 // can happen if the application was exited, but background mode or |
| 568 // packaged apps prevented the process from shutting down, and then |
| 569 // a new browser window was opened. |
| 570 closing_all_browsers_ = false; |
566 break; | 571 break; |
567 } | 572 } |
568 case chrome::NOTIFICATION_BROWSER_CLOSED: { | 573 case chrome::NOTIFICATION_BROWSER_CLOSED: { |
569 Browser* browser = content::Source<Browser>(source).ptr(); | 574 Browser* browser = content::Source<Browser>(source).ptr(); |
570 DCHECK(browser); | 575 DCHECK(browser); |
571 Profile* profile = browser->profile(); | 576 Profile* profile = browser->profile(); |
572 DCHECK(profile); | 577 DCHECK(profile); |
573 if (!profile->IsOffTheRecord() && --browser_counts_[profile] == 0) { | 578 if (!profile->IsOffTheRecord() && --browser_counts_[profile] == 0) { |
574 active_profiles_.erase(std::find(active_profiles_.begin(), | 579 active_profiles_.erase(std::find(active_profiles_.begin(), |
575 active_profiles_.end(), profile)); | 580 active_profiles_.end(), profile)); |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1012 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, | 1017 void ProfileManager::RunCallbacks(const std::vector<CreateCallback>& callbacks, |
1013 Profile* profile, | 1018 Profile* profile, |
1014 Profile::CreateStatus status) { | 1019 Profile::CreateStatus status) { |
1015 for (size_t i = 0; i < callbacks.size(); ++i) | 1020 for (size_t i = 0; i < callbacks.size(); ++i) |
1016 callbacks[i].Run(profile, status); | 1021 callbacks[i].Run(profile, status); |
1017 } | 1022 } |
1018 | 1023 |
1019 ProfileManager::ProfileInfo::~ProfileInfo() { | 1024 ProfileManager::ProfileInfo::~ProfileInfo() { |
1020 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); | 1025 ProfileDestroyer::DestroyProfileWhenAppropriate(profile.release()); |
1021 } | 1026 } |
OLD | NEW |