| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "build/build_config.h" | 5 #include "build/build_config.h" |
| 6 | 6 |
| 7 #include "chrome/browser/sessions/session_service.h" | 7 #include "chrome/browser/sessions/session_service.h" |
| 8 | 8 |
| 9 #include <limits> | 9 #include <limits> |
| 10 | 10 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/sessions/session_backend.h" | 22 #include "chrome/browser/sessions/session_backend.h" |
| 23 #include "chrome/browser/sessions/session_command.h" | 23 #include "chrome/browser/sessions/session_command.h" |
| 24 #include "chrome/browser/sessions/session_restore.h" | 24 #include "chrome/browser/sessions/session_restore.h" |
| 25 #include "chrome/browser/sessions/session_types.h" | 25 #include "chrome/browser/sessions/session_types.h" |
| 26 #include "chrome/browser/tab_contents/navigation_controller.h" | 26 #include "chrome/browser/tab_contents/navigation_controller.h" |
| 27 #include "chrome/browser/tab_contents/navigation_entry.h" | 27 #include "chrome/browser/tab_contents/navigation_entry.h" |
| 28 #include "chrome/browser/tab_contents/tab_contents.h" | 28 #include "chrome/browser/tab_contents/tab_contents.h" |
| 29 #include "chrome/common/notification_details.h" | 29 #include "chrome/common/notification_details.h" |
| 30 #include "chrome/common/notification_service.h" | 30 #include "chrome/common/notification_service.h" |
| 31 | 31 |
| 32 #if defined(OS_MACOSX) |
| 33 #include "chrome/browser/app_controller_cppsafe_mac.h" |
| 34 #endif |
| 35 |
| 32 using base::Time; | 36 using base::Time; |
| 33 | 37 |
| 34 // Identifier for commands written to file. | 38 // Identifier for commands written to file. |
| 35 static const SessionCommand::id_type kCommandSetTabWindow = 0; | 39 static const SessionCommand::id_type kCommandSetTabWindow = 0; |
| 36 // kCommandSetWindowBounds is no longer used (it's superseded by | 40 // kCommandSetWindowBounds is no longer used (it's superseded by |
| 37 // kCommandSetWindowBounds2). I leave it here to document what it was. | 41 // kCommandSetWindowBounds2). I leave it here to document what it was. |
| 38 // static const SessionCommand::id_type kCommandSetWindowBounds = 1; | 42 // static const SessionCommand::id_type kCommandSetWindowBounds = 1; |
| 39 static const SessionCommand::id_type kCommandSetTabIndexInWindow = 2; | 43 static const SessionCommand::id_type kCommandSetTabIndexInWindow = 2; |
| 40 static const SessionCommand::id_type kCommandTabClosed = 3; | 44 static const SessionCommand::id_type kCommandTabClosed = 3; |
| 41 static const SessionCommand::id_type kCommandWindowClosed = 4; | 45 static const SessionCommand::id_type kCommandWindowClosed = 4; |
| (...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 const NotificationDetails& details) { | 406 const NotificationDetails& details) { |
| 403 // All of our messages have the NavigationController as the source. | 407 // All of our messages have the NavigationController as the source. |
| 404 switch (type.value) { | 408 switch (type.value) { |
| 405 case NotificationType::BROWSER_OPENED: { | 409 case NotificationType::BROWSER_OPENED: { |
| 406 Browser* browser = Source<Browser>(source).ptr(); | 410 Browser* browser = Source<Browser>(source).ptr(); |
| 407 if (browser->profile() != profile() || | 411 if (browser->profile() != profile() || |
| 408 !should_track_changes_for_browser_type(browser->type())) { | 412 !should_track_changes_for_browser_type(browser->type())) { |
| 409 return; | 413 return; |
| 410 } | 414 } |
| 411 | 415 |
| 412 if (!has_open_trackable_browsers_ && !BrowserInit::InProcessStartup()) { | 416 if (!has_open_trackable_browsers_ && !BrowserInit::InProcessStartup() |
| 417 #if defined(OS_MACOSX) |
| 418 // OSX has a fairly different idea of application lifetime than the |
| 419 // other platforms. We need to check that we aren't opening a window |
| 420 // from the dock or the menubar. |
| 421 && !app_controller_mac::IsOpeningNewWindow() |
| 422 #endif |
| 423 ) { |
| 413 // We're going from no tabbed browsers to a tabbed browser (and not in | 424 // We're going from no tabbed browsers to a tabbed browser (and not in |
| 414 // process startup), restore the last session. | 425 // process startup), restore the last session. |
| 415 if (move_on_new_browser_) { | 426 if (move_on_new_browser_) { |
| 416 // Make the current session the last. | 427 // Make the current session the last. |
| 417 MoveCurrentSessionToLastSession(); | 428 MoveCurrentSessionToLastSession(); |
| 418 move_on_new_browser_ = false; | 429 move_on_new_browser_ = false; |
| 419 } | 430 } |
| 420 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile()); | 431 SessionStartupPref pref = SessionStartupPref::GetStartupPref(profile()); |
| 421 if (pref.type == SessionStartupPref::LAST) { | 432 if (pref.type == SessionStartupPref::LAST) { |
| 422 SessionRestore::RestoreSession( | 433 SessionRestore::RestoreSession( |
| (...skipping 722 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 browser->profile()->GetOriginalProfile() == profile()) { | 1156 browser->profile()->GetOriginalProfile() == profile()) { |
| 1146 return true; | 1157 return true; |
| 1147 } | 1158 } |
| 1148 } | 1159 } |
| 1149 return false; | 1160 return false; |
| 1150 } | 1161 } |
| 1151 | 1162 |
| 1152 bool SessionService::ShouldTrackChangesToWindow(const SessionID& window_id) { | 1163 bool SessionService::ShouldTrackChangesToWindow(const SessionID& window_id) { |
| 1153 return windows_tracking_.find(window_id.id()) != windows_tracking_.end(); | 1164 return windows_tracking_.find(window_id.id()) != windows_tracking_.end(); |
| 1154 } | 1165 } |
| OLD | NEW |