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 |
(...skipping 14 matching lines...) Expand all Loading... |
25 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 25 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 26 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
27 #include "chrome/common/extensions/extension.h" | 27 #include "chrome/common/extensions/extension.h" |
28 #include "chrome/common/extensions/extension_constants.h" | 28 #include "chrome/common/extensions/extension_constants.h" |
29 #include "chrome/common/url_constants.h" | 29 #include "chrome/common/url_constants.h" |
30 #include "content/browser/tab_contents/tab_contents.h" | 30 #include "content/browser/tab_contents/tab_contents.h" |
31 #include "content/public/browser/navigation_controller.h" | 31 #include "content/public/browser/navigation_controller.h" |
32 #include "content/public/browser/navigation_entry.h" | 32 #include "content/public/browser/navigation_entry.h" |
33 | 33 |
34 using base::Time; | 34 using base::Time; |
| 35 using content::NavigationController; |
35 using content::NavigationEntry; | 36 using content::NavigationEntry; |
36 using content::WebContents; | 37 using content::WebContents; |
37 | 38 |
38 // TimeFactory----------------------------------------------------------------- | 39 // TimeFactory----------------------------------------------------------------- |
39 | 40 |
40 TabRestoreService::TimeFactory::~TimeFactory() {} | 41 TabRestoreService::TimeFactory::~TimeFactory() {} |
41 | 42 |
42 // Entry ---------------------------------------------------------------------- | 43 // Entry ---------------------------------------------------------------------- |
43 | 44 |
44 // ID of the next Entry. | 45 // ID of the next Entry. |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
211 } | 212 } |
212 | 213 |
213 void TabRestoreService::AddObserver(TabRestoreServiceObserver* observer) { | 214 void TabRestoreService::AddObserver(TabRestoreServiceObserver* observer) { |
214 observer_list_.AddObserver(observer); | 215 observer_list_.AddObserver(observer); |
215 } | 216 } |
216 | 217 |
217 void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) { | 218 void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) { |
218 observer_list_.RemoveObserver(observer); | 219 observer_list_.RemoveObserver(observer); |
219 } | 220 } |
220 | 221 |
221 void TabRestoreService::CreateHistoricalTab(content::NavigationController* tab, | 222 void TabRestoreService::CreateHistoricalTab(NavigationController* tab, |
222 int index) { | 223 int index) { |
223 if (restoring_) | 224 if (restoring_) |
224 return; | 225 return; |
225 | 226 |
226 TabRestoreServiceDelegate* delegate = | 227 TabRestoreServiceDelegate* delegate = |
227 TabRestoreServiceDelegate::FindDelegateForController(tab, NULL); | 228 TabRestoreServiceDelegate::FindDelegateForController(tab, NULL); |
228 if (closing_delegates_.find(delegate) != closing_delegates_.end()) | 229 if (closing_delegates_.find(delegate) != closing_delegates_.end()) |
229 return; | 230 return; |
230 | 231 |
231 scoped_ptr<Tab> local_tab(new Tab()); | 232 scoped_ptr<Tab> local_tab(new Tab()); |
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 } | 480 } |
480 } | 481 } |
481 if (pending_reset()) | 482 if (pending_reset()) |
482 entries_written_ = 0; | 483 entries_written_ = 0; |
483 BaseSessionService::Save(); | 484 BaseSessionService::Save(); |
484 } | 485 } |
485 | 486 |
486 void TabRestoreService::PopulateTab(Tab* tab, | 487 void TabRestoreService::PopulateTab(Tab* tab, |
487 int index, | 488 int index, |
488 TabRestoreServiceDelegate* delegate, | 489 TabRestoreServiceDelegate* delegate, |
489 content::NavigationController* controller) { | 490 NavigationController* controller) { |
490 const int pending_index = controller->GetPendingEntryIndex(); | 491 const int pending_index = controller->GetPendingEntryIndex(); |
491 int entry_count = controller->GetEntryCount(); | 492 int entry_count = controller->GetEntryCount(); |
492 if (entry_count == 0 && pending_index == 0) | 493 if (entry_count == 0 && pending_index == 0) |
493 entry_count++; | 494 entry_count++; |
494 tab->navigations.resize(static_cast<int>(entry_count)); | 495 tab->navigations.resize(static_cast<int>(entry_count)); |
495 for (int i = 0; i < entry_count; ++i) { | 496 for (int i = 0; i < entry_count; ++i) { |
496 NavigationEntry* entry = (i == pending_index) ? | 497 NavigationEntry* entry = (i == pending_index) ? |
497 controller->GetPendingEntry() : controller->GetEntryAtIndex(i); | 498 controller->GetPendingEntry() : controller->GetEntryAtIndex(i); |
498 tab->navigations[i].SetFromNavigationEntry(*entry); | 499 tab->navigations[i].SetFromNavigationEntry(*entry); |
499 } | 500 } |
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1166 // the front, not the end and we just added the entries to the end). | 1167 // the front, not the end and we just added the entries to the end). |
1167 entries_to_write_ = staging_entries_.size(); | 1168 entries_to_write_ = staging_entries_.size(); |
1168 | 1169 |
1169 PruneEntries(); | 1170 PruneEntries(); |
1170 NotifyTabsChanged(); | 1171 NotifyTabsChanged(); |
1171 } | 1172 } |
1172 | 1173 |
1173 Time TabRestoreService::TimeNow() const { | 1174 Time TabRestoreService::TimeNow() const { |
1174 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); | 1175 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); |
1175 } | 1176 } |
OLD | NEW |