Chromium Code Reviews| 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/sessions/session_service.h" | 5 #include "chrome/browser/sessions/session_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/bind.h" | 12 #include "base/bind.h" |
| 13 #include "base/bind_helpers.h" | 13 #include "base/bind_helpers.h" |
| 14 #include "base/command_line.h" | 14 #include "base/command_line.h" |
| 15 #include "base/message_loop/message_loop.h" | 15 #include "base/message_loop/message_loop.h" |
| 16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
| 17 #include "base/pickle.h" | 17 #include "base/pickle.h" |
| 18 #include "base/threading/thread.h" | 18 #include "base/threading/thread.h" |
| 19 #include "chrome/browser/chrome_notification_types.h" | 19 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/extensions/tab_helper.h" | 20 #include "chrome/browser/extensions/tab_helper.h" |
| 21 #include "chrome/browser/prefs/session_startup_pref.h" | 21 #include "chrome/browser/prefs/session_startup_pref.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 22 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sessions/session_backend.h" | 23 #include "chrome/browser/sessions/session_backend.h" |
| 24 #include "chrome/browser/sessions/session_command.h" | 24 #include "chrome/browser/sessions/session_command.h" |
| 25 #include "chrome/browser/sessions/session_data_deleter.h" | |
| 25 #include "chrome/browser/sessions/session_restore.h" | 26 #include "chrome/browser/sessions/session_restore.h" |
| 26 #include "chrome/browser/sessions/session_tab_helper.h" | 27 #include "chrome/browser/sessions/session_tab_helper.h" |
| 27 #include "chrome/browser/sessions/session_types.h" | 28 #include "chrome/browser/sessions/session_types.h" |
| 28 #include "chrome/browser/ui/browser_iterator.h" | 29 #include "chrome/browser/ui/browser_iterator.h" |
| 29 #include "chrome/browser/ui/browser_list.h" | 30 #include "chrome/browser/ui/browser_list.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" | 31 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 32 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/host_desktop.h" | 33 #include "chrome/browser/ui/host_desktop.h" |
| 33 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 34 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 35 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 331 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); | 332 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); |
| 332 } else if (pending_window_close_ids_.find(window_id.id()) == | 333 } else if (pending_window_close_ids_.find(window_id.id()) == |
| 333 pending_window_close_ids_.end()) { | 334 pending_window_close_ids_.end()) { |
| 334 // We'll hit this if user closed the last tab in a window. | 335 // We'll hit this if user closed the last tab in a window. |
| 335 has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id); | 336 has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id); |
| 336 if (should_record_close_as_pending()) | 337 if (should_record_close_as_pending()) |
| 337 pending_window_close_ids_.insert(window_id.id()); | 338 pending_window_close_ids_.insert(window_id.id()); |
| 338 else | 339 else |
| 339 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); | 340 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); |
| 340 } | 341 } |
| 342 if (!has_open_trackable_browsers_) | |
|
benwells
2013/10/09 00:38:06
How does this interact with background mode? Backg
Sam McNally
2013/10/14 01:44:24
Done.
| |
| 343 DeleteSessionOnlyData(profile()); | |
| 341 } | 344 } |
| 342 | 345 |
| 343 void SessionService::SetWindowType(const SessionID& window_id, | 346 void SessionService::SetWindowType(const SessionID& window_id, |
| 344 Browser::Type type, | 347 Browser::Type type, |
| 345 AppType app_type) { | 348 AppType app_type) { |
| 346 if (!should_track_changes_for_browser_type(type, app_type)) | 349 if (!should_track_changes_for_browser_type(type, app_type)) |
| 347 return; | 350 return; |
| 348 | 351 |
| 349 windows_tracking_.insert(window_id.id()); | 352 windows_tracking_.insert(window_id.id()); |
| 350 | 353 |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1755 contents->GetController().GetDefaultSessionStorageNamespace(); | 1758 contents->GetController().GetDefaultSessionStorageNamespace(); |
| 1756 session_storage_namespace->SetShouldPersist(false); | 1759 session_storage_namespace->SetShouldPersist(false); |
| 1757 SessionTabHelper* session_tab_helper = | 1760 SessionTabHelper* session_tab_helper = |
| 1758 SessionTabHelper::FromWebContents(contents); | 1761 SessionTabHelper::FromWebContents(contents); |
| 1759 TabClosed(session_tab_helper->window_id(), | 1762 TabClosed(session_tab_helper->window_id(), |
| 1760 session_tab_helper->session_id(), | 1763 session_tab_helper->session_id(), |
| 1761 contents->GetClosedByUserGesture()); | 1764 contents->GetClosedByUserGesture()); |
| 1762 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1765 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1763 &last_updated_tab_closed_time_); | 1766 &last_updated_tab_closed_time_); |
| 1764 } | 1767 } |
| OLD | NEW |