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/background/background_mode_manager.h" | |
| 20 #include "chrome/browser/browser_process.h" | |
| 19 #include "chrome/browser/chrome_notification_types.h" | 21 #include "chrome/browser/chrome_notification_types.h" |
| 20 #include "chrome/browser/extensions/tab_helper.h" | 22 #include "chrome/browser/extensions/tab_helper.h" |
| 21 #include "chrome/browser/prefs/session_startup_pref.h" | 23 #include "chrome/browser/prefs/session_startup_pref.h" |
| 22 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
| 23 #include "chrome/browser/sessions/session_backend.h" | 25 #include "chrome/browser/sessions/session_backend.h" |
| 24 #include "chrome/browser/sessions/session_command.h" | 26 #include "chrome/browser/sessions/session_command.h" |
| 27 #include "chrome/browser/sessions/session_data_deleter.h" | |
| 25 #include "chrome/browser/sessions/session_restore.h" | 28 #include "chrome/browser/sessions/session_restore.h" |
| 26 #include "chrome/browser/sessions/session_tab_helper.h" | 29 #include "chrome/browser/sessions/session_tab_helper.h" |
| 27 #include "chrome/browser/sessions/session_types.h" | 30 #include "chrome/browser/sessions/session_types.h" |
| 28 #include "chrome/browser/ui/browser_iterator.h" | 31 #include "chrome/browser/ui/browser_iterator.h" |
| 29 #include "chrome/browser/ui/browser_list.h" | 32 #include "chrome/browser/ui/browser_list.h" |
| 30 #include "chrome/browser/ui/browser_tabstrip.h" | 33 #include "chrome/browser/ui/browser_tabstrip.h" |
| 31 #include "chrome/browser/ui/browser_window.h" | 34 #include "chrome/browser/ui/browser_window.h" |
| 32 #include "chrome/browser/ui/host_desktop.h" | 35 #include "chrome/browser/ui/host_desktop.h" |
| 33 #include "chrome/browser/ui/startup/startup_browser_creator.h" | 36 #include "chrome/browser/ui/startup/startup_browser_creator.h" |
| 34 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 37 #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())); | 334 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); |
| 332 } else if (pending_window_close_ids_.find(window_id.id()) == | 335 } else if (pending_window_close_ids_.find(window_id.id()) == |
| 333 pending_window_close_ids_.end()) { | 336 pending_window_close_ids_.end()) { |
| 334 // We'll hit this if user closed the last tab in a window. | 337 // We'll hit this if user closed the last tab in a window. |
| 335 has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id); | 338 has_open_trackable_browsers_ = HasOpenTrackableBrowsers(window_id); |
| 336 if (should_record_close_as_pending()) | 339 if (should_record_close_as_pending()) |
| 337 pending_window_close_ids_.insert(window_id.id()); | 340 pending_window_close_ids_.insert(window_id.id()); |
| 338 else | 341 else |
| 339 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); | 342 ScheduleCommand(CreateWindowClosedCommand(window_id.id())); |
| 340 } | 343 } |
| 344 #if !defined(OS_MACOSX) && !defined(OS_CHROMEOS) | |
|
marja
2013/10/16 14:18:08
Why not for mac and chromeos? Because of some "how
Sam McNally
2013/10/16 23:30:59
Correct. Switched to kBrowserAliveWithNoWindows an
| |
| 345 if (!has_open_trackable_browsers_ && | |
| 346 !g_browser_process->background_mode_manager()->IsBackgroundModeActive()) { | |
| 347 DeleteSessionOnlyData(profile()); | |
| 348 } | |
| 349 #endif | |
| 341 } | 350 } |
| 342 | 351 |
| 343 void SessionService::SetWindowType(const SessionID& window_id, | 352 void SessionService::SetWindowType(const SessionID& window_id, |
| 344 Browser::Type type, | 353 Browser::Type type, |
| 345 AppType app_type) { | 354 AppType app_type) { |
| 346 if (!should_track_changes_for_browser_type(type, app_type)) | 355 if (!should_track_changes_for_browser_type(type, app_type)) |
| 347 return; | 356 return; |
| 348 | 357 |
| 349 windows_tracking_.insert(window_id.id()); | 358 windows_tracking_.insert(window_id.id()); |
| 350 | 359 |
| (...skipping 1404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1755 contents->GetController().GetDefaultSessionStorageNamespace(); | 1764 contents->GetController().GetDefaultSessionStorageNamespace(); |
| 1756 session_storage_namespace->SetShouldPersist(false); | 1765 session_storage_namespace->SetShouldPersist(false); |
| 1757 SessionTabHelper* session_tab_helper = | 1766 SessionTabHelper* session_tab_helper = |
| 1758 SessionTabHelper::FromWebContents(contents); | 1767 SessionTabHelper::FromWebContents(contents); |
| 1759 TabClosed(session_tab_helper->window_id(), | 1768 TabClosed(session_tab_helper->window_id(), |
| 1760 session_tab_helper->session_id(), | 1769 session_tab_helper->session_id(), |
| 1761 contents->GetClosedByUserGesture()); | 1770 contents->GetClosedByUserGesture()); |
| 1762 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, | 1771 RecordSessionUpdateHistogramData(content::NOTIFICATION_WEB_CONTENTS_DESTROYED, |
| 1763 &last_updated_tab_closed_time_); | 1772 &last_updated_tab_closed_time_); |
| 1764 } | 1773 } |
| OLD | NEW |