OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <set> | 9 #include <set> |
10 #include <vector> | 10 #include <vector> |
(...skipping 1239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1250 pending_window_close_ids_.clear(); | 1250 pending_window_close_ids_.clear(); |
1251 } | 1251 } |
1252 | 1252 |
1253 bool SessionService::IsOnlyOneTabLeft() { | 1253 bool SessionService::IsOnlyOneTabLeft() { |
1254 if (!profile()) { | 1254 if (!profile()) { |
1255 // We're testing, always return false. | 1255 // We're testing, always return false. |
1256 return false; | 1256 return false; |
1257 } | 1257 } |
1258 | 1258 |
1259 // NOTE: This uses the original profile so that closing the last non-off the | 1259 // NOTE: This uses the original profile so that closing the last non-off the |
1260 // record window while there are open off the record windows resets state). | 1260 // record window while there are open incognito windows resets state). |
1261 int window_count = 0; | 1261 int window_count = 0; |
1262 for (BrowserList::const_iterator i = BrowserList::begin(); | 1262 for (BrowserList::const_iterator i = BrowserList::begin(); |
1263 i != BrowserList::end(); ++i) { | 1263 i != BrowserList::end(); ++i) { |
1264 const SessionID::id_type window_id = (*i)->session_id().id(); | 1264 const SessionID::id_type window_id = (*i)->session_id().id(); |
1265 if (should_track_changes_for_browser_type((*i)->type()) && | 1265 if (should_track_changes_for_browser_type((*i)->type()) && |
1266 (*i)->profile()->GetOriginalProfile() == profile() && | 1266 (*i)->profile()->GetOriginalProfile() == profile() && |
1267 window_closing_ids_.find(window_id) == window_closing_ids_.end()) { | 1267 window_closing_ids_.find(window_id) == window_closing_ids_.end()) { |
1268 if (++window_count > 1) | 1268 if (++window_count > 1) |
1269 return false; | 1269 return false; |
1270 // By the time this is invoked the tab has been removed. As such, we use | 1270 // By the time this is invoked the tab has been removed. As such, we use |
1271 // > 0 here rather than > 1. | 1271 // > 0 here rather than > 1. |
1272 if ((*i)->tab_count() > 0) | 1272 if ((*i)->tab_count() > 0) |
1273 return false; | 1273 return false; |
1274 } | 1274 } |
1275 } | 1275 } |
1276 return true; | 1276 return true; |
1277 } | 1277 } |
1278 | 1278 |
1279 bool SessionService::HasOpenTrackableBrowsers(const SessionID& window_id) { | 1279 bool SessionService::HasOpenTrackableBrowsers(const SessionID& window_id) { |
1280 if (!profile()) { | 1280 if (!profile()) { |
1281 // We're testing, always return false. | 1281 // We're testing, always return false. |
1282 return true; | 1282 return true; |
1283 } | 1283 } |
1284 | 1284 |
1285 // NOTE: This uses the original profile so that closing the last non-off the | 1285 // NOTE: This uses the original profile so that closing the last non-off the |
1286 // record window while there are open off the record window resets state). | 1286 // record window while there are open incognito window resets state). |
1287 for (BrowserList::const_iterator i = BrowserList::begin(); | 1287 for (BrowserList::const_iterator i = BrowserList::begin(); |
1288 i != BrowserList::end(); ++i) { | 1288 i != BrowserList::end(); ++i) { |
1289 Browser* browser = *i; | 1289 Browser* browser = *i; |
1290 const SessionID::id_type browser_id = browser->session_id().id(); | 1290 const SessionID::id_type browser_id = browser->session_id().id(); |
1291 if (browser_id != window_id.id() && | 1291 if (browser_id != window_id.id() && |
1292 window_closing_ids_.find(browser_id) == window_closing_ids_.end() && | 1292 window_closing_ids_.find(browser_id) == window_closing_ids_.end() && |
1293 should_track_changes_for_browser_type(browser->type()) && | 1293 should_track_changes_for_browser_type(browser->type()) && |
1294 browser->profile()->GetOriginalProfile() == profile()) { | 1294 browser->profile()->GetOriginalProfile() == profile()) { |
1295 return true; | 1295 return true; |
1296 } | 1296 } |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1464 50); | 1464 50); |
1465 if (use_long_period) { | 1465 if (use_long_period) { |
1466 std::string long_name_("SessionRestore.SaveLongPeriod"); | 1466 std::string long_name_("SessionRestore.SaveLongPeriod"); |
1467 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, | 1467 UMA_HISTOGRAM_CUSTOM_TIMES(long_name_, |
1468 delta, | 1468 delta, |
1469 save_delay_in_mins_, | 1469 save_delay_in_mins_, |
1470 save_delay_in_hrs_, | 1470 save_delay_in_hrs_, |
1471 50); | 1471 50); |
1472 } | 1472 } |
1473 } | 1473 } |
OLD | NEW |