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/ui/browser_list_impl.h" | 5 #include "chrome/browser/ui/browser_list_impl.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "chrome/browser/browser_process.h" | 9 #include "chrome/browser/browser_process.h" |
10 #include "chrome/browser/browser_shutdown.h" | 10 #include "chrome/browser/browser_shutdown.h" |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 } | 104 } |
105 | 105 |
106 void BrowserListImpl::SetLastActive(Browser* browser) { | 106 void BrowserListImpl::SetLastActive(Browser* browser) { |
107 RemoveBrowserFrom(browser, &last_active_browsers_); | 107 RemoveBrowserFrom(browser, &last_active_browsers_); |
108 last_active_browsers_.push_back(browser); | 108 last_active_browsers_.push_back(browser); |
109 | 109 |
110 FOR_EACH_OBSERVER(BrowserListObserver, observers_, | 110 FOR_EACH_OBSERVER(BrowserListObserver, observers_, |
111 OnBrowserSetLastActive(browser)); | 111 OnBrowserSetLastActive(browser)); |
112 } | 112 } |
113 | 113 |
114 Browser* BrowserListImpl::GetLastActive() { | 114 Browser* BrowserListImpl::GetLastActive() const { |
115 if (!last_active_browsers_.empty()) | 115 if (!last_active_browsers_.empty()) |
116 return *(last_active_browsers_.rbegin()); | 116 return *(last_active_browsers_.rbegin()); |
117 return NULL; | 117 return NULL; |
118 } | 118 } |
119 | 119 |
120 bool BrowserListImpl::IsIncognitoWindowOpen() { | 120 bool BrowserListImpl::IsIncognitoWindowOpen() const { |
121 for (BrowserListImpl::const_iterator i = BrowserListImpl::begin(); | 121 for (BrowserListImpl::const_iterator i = BrowserListImpl::begin(); |
122 i != BrowserListImpl::end(); ++i) { | 122 i != BrowserListImpl::end(); ++i) { |
123 if ((*i)->profile()->IsOffTheRecord()) | 123 if ((*i)->profile()->IsOffTheRecord()) |
124 return true; | 124 return true; |
125 } | 125 } |
126 return false; | 126 return false; |
127 } | 127 } |
128 | 128 |
129 bool BrowserListImpl::IsIncognitoWindowOpenForProfile(Profile* profile) { | 129 bool BrowserListImpl::IsIncognitoWindowOpenForProfile(Profile* profile) const { |
130 #if defined(OS_CHROMEOS) | 130 #if defined(OS_CHROMEOS) |
131 // In ChromeOS, we assume that the default profile is always valid, so if | 131 // In ChromeOS, we assume that the default profile is always valid, so if |
132 // we are in guest mode, keep the OTR profile active so it won't be deleted. | 132 // we are in guest mode, keep the OTR profile active so it won't be deleted. |
133 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) | 133 if (chromeos::UserManager::Get()->IsLoggedInAsGuest()) |
134 return true; | 134 return true; |
135 #endif | 135 #endif |
136 for (BrowserListImpl::const_iterator i = BrowserListImpl::begin(); | 136 for (BrowserListImpl::const_iterator i = BrowserListImpl::begin(); |
137 i != BrowserListImpl::end(); ++i) { | 137 i != BrowserListImpl::end(); ++i) { |
138 if ((*i)->profile()->IsSameProfile(profile) && | 138 if ((*i)->profile()->IsSameProfile(profile) && |
139 (*i)->profile()->IsOffTheRecord()) { | 139 (*i)->profile()->IsOffTheRecord()) { |
(...skipping 14 matching lines...) Expand all Loading... |
154 | 154 |
155 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, | 155 void BrowserListImpl::RemoveBrowserFrom(Browser* browser, |
156 BrowserVector* browser_list) { | 156 BrowserVector* browser_list) { |
157 const iterator remove_browser = | 157 const iterator remove_browser = |
158 std::find(browser_list->begin(), browser_list->end(), browser); | 158 std::find(browser_list->begin(), browser_list->end(), browser); |
159 if (remove_browser != browser_list->end()) | 159 if (remove_browser != browser_list->end()) |
160 browser_list->erase(remove_browser); | 160 browser_list->erase(remove_browser); |
161 } | 161 } |
162 | 162 |
163 } // namespace chrome | 163 } // namespace chrome |
OLD | NEW |