| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/tab_restore_service.h" | 5 #include "chrome/browser/sessions/tab_restore_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <map> | 9 #include <map> |
| 10 | 10 |
| 11 #include "base/callback.h" | 11 #include "base/callback.h" |
| 12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/stl_util-inl.h" | 14 #include "base/stl_util-inl.h" |
| 15 #include "chrome/browser/extensions/extension_service.h" | 15 #include "chrome/browser/extensions/extension_service.h" |
| 16 #include "chrome/browser/extensions/extension_tab_helper.h" |
| 16 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 17 #include "chrome/browser/sessions/session_service.h" | 18 #include "chrome/browser/sessions/session_service.h" |
| 18 #include "chrome/browser/sessions/session_command.h" | 19 #include "chrome/browser/sessions/session_command.h" |
| 19 #include "chrome/browser/sessions/session_types.h" | 20 #include "chrome/browser/sessions/session_types.h" |
| 20 #include "chrome/browser/sessions/tab_restore_service_delegate.h" | 21 #include "chrome/browser/sessions/tab_restore_service_delegate.h" |
| 21 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 22 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 23 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 22 #include "chrome/common/extensions/extension.h" | 24 #include "chrome/common/extensions/extension.h" |
| 23 #include "chrome/common/extensions/extension_constants.h" | 25 #include "chrome/common/extensions/extension_constants.h" |
| 24 #include "content/browser/tab_contents/navigation_controller.h" | 26 #include "content/browser/tab_contents/navigation_controller.h" |
| 25 #include "content/browser/tab_contents/navigation_entry.h" | 27 #include "content/browser/tab_contents/navigation_entry.h" |
| 26 #include "content/browser/tab_contents/tab_contents.h" | 28 #include "content/browser/tab_contents/tab_contents.h" |
| 27 | 29 |
| 28 using base::Time; | 30 using base::Time; |
| 29 | 31 |
| 30 // TimeFactory----------------------------------------------------------------- | 32 // TimeFactory----------------------------------------------------------------- |
| 31 | 33 |
| (...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 485 NavigationEntry* entry = (i == pending_index) ? | 487 NavigationEntry* entry = (i == pending_index) ? |
| 486 controller->pending_entry() : controller->GetEntryAtIndex(i); | 488 controller->pending_entry() : controller->GetEntryAtIndex(i); |
| 487 tab->navigations[i].SetFromNavigationEntry(*entry); | 489 tab->navigations[i].SetFromNavigationEntry(*entry); |
| 488 } | 490 } |
| 489 tab->timestamp = TimeNow(); | 491 tab->timestamp = TimeNow(); |
| 490 tab->current_navigation_index = controller->GetCurrentEntryIndex(); | 492 tab->current_navigation_index = controller->GetCurrentEntryIndex(); |
| 491 if (tab->current_navigation_index == -1 && entry_count > 0) | 493 if (tab->current_navigation_index == -1 && entry_count > 0) |
| 492 tab->current_navigation_index = 0; | 494 tab->current_navigation_index = 0; |
| 493 tab->tabstrip_index = index; | 495 tab->tabstrip_index = index; |
| 494 | 496 |
| 495 const Extension* extension = controller->tab_contents()->extension_app(); | 497 TabContentsWrapper* wrapper = |
| 496 if (extension) | 498 TabContentsWrapper::GetCurrentWrapperForContents( |
| 497 tab->extension_app_id = extension->id(); | 499 controller->tab_contents()); |
| 500 // wrapper is NULL in some browser tests. |
| 501 if (wrapper) { |
| 502 const Extension* extension = |
| 503 wrapper->extension_tab_helper()->extension_app(); |
| 504 if (extension) |
| 505 tab->extension_app_id = extension->id(); |
| 506 } |
| 498 | 507 |
| 499 tab->session_storage_namespace = controller->session_storage_namespace(); | 508 tab->session_storage_namespace = controller->session_storage_namespace(); |
| 500 | 509 |
| 501 // Delegate may be NULL during unit tests. | 510 // Delegate may be NULL during unit tests. |
| 502 if (delegate) { | 511 if (delegate) { |
| 503 tab->browser_id = delegate->GetSessionID().id(); | 512 tab->browser_id = delegate->GetSessionID().id(); |
| 504 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index); | 513 tab->pinned = delegate->IsTabPinned(tab->tabstrip_index); |
| 505 } | 514 } |
| 506 } | 515 } |
| 507 | 516 |
| (...skipping 566 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1074 // correctly write out the entries when Save is invoked (Save starts from | 1083 // correctly write out the entries when Save is invoked (Save starts from |
| 1075 // the front, not the end and we just added the entries to the end). | 1084 // the front, not the end and we just added the entries to the end). |
| 1076 entries_to_write_ = staging_entries_.size(); | 1085 entries_to_write_ = staging_entries_.size(); |
| 1077 | 1086 |
| 1078 PruneAndNotify(); | 1087 PruneAndNotify(); |
| 1079 } | 1088 } |
| 1080 | 1089 |
| 1081 Time TabRestoreService::TimeNow() const { | 1090 Time TabRestoreService::TimeNow() const { |
| 1082 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); | 1091 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); |
| 1083 } | 1092 } |
| OLD | NEW |