Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(310)

Side by Side Diff: chrome/browser/sessions/tab_restore_service.cc

Issue 8983010: Convert WebContents to return a content::NavigationController instead of the implementation. Upda... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: fix mac Created 8 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/bind.h" 11 #include "base/bind.h"
12 #include "base/bind_helpers.h" 12 #include "base/bind_helpers.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/memory/scoped_vector.h" 14 #include "base/memory/scoped_vector.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "base/stl_util.h" 16 #include "base/stl_util.h"
17 #include "chrome/browser/extensions/extension_service.h" 17 #include "chrome/browser/extensions/extension_service.h"
18 #include "chrome/browser/extensions/extension_tab_helper.h" 18 #include "chrome/browser/extensions/extension_tab_helper.h"
19 #include "chrome/browser/profiles/profile.h" 19 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/sessions/session_service.h" 20 #include "chrome/browser/sessions/session_service.h"
21 #include "chrome/browser/sessions/session_service_factory.h" 21 #include "chrome/browser/sessions/session_service_factory.h"
22 #include "chrome/browser/sessions/session_command.h" 22 #include "chrome/browser/sessions/session_command.h"
23 #include "chrome/browser/sessions/session_types.h" 23 #include "chrome/browser/sessions/session_types.h"
24 #include "chrome/browser/sessions/tab_restore_service_delegate.h" 24 #include "chrome/browser/sessions/tab_restore_service_delegate.h"
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/navigation_controller.h"
31 #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"
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::NavigationEntry; 35 using content::NavigationEntry;
36 using content::WebContents; 36 using content::WebContents;
37 37
38 // TimeFactory----------------------------------------------------------------- 38 // TimeFactory-----------------------------------------------------------------
39 39
40 TabRestoreService::TimeFactory::~TimeFactory() {} 40 TabRestoreService::TimeFactory::~TimeFactory() {}
41 41
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 211 }
212 212
213 void TabRestoreService::AddObserver(TabRestoreServiceObserver* observer) { 213 void TabRestoreService::AddObserver(TabRestoreServiceObserver* observer) {
214 observer_list_.AddObserver(observer); 214 observer_list_.AddObserver(observer);
215 } 215 }
216 216
217 void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) { 217 void TabRestoreService::RemoveObserver(TabRestoreServiceObserver* observer) {
218 observer_list_.RemoveObserver(observer); 218 observer_list_.RemoveObserver(observer);
219 } 219 }
220 220
221 void TabRestoreService::CreateHistoricalTab(NavigationController* tab, 221 void TabRestoreService::CreateHistoricalTab(content::NavigationController* tab,
222 int index) { 222 int index) {
223 if (restoring_) 223 if (restoring_)
224 return; 224 return;
225 225
226 TabRestoreServiceDelegate* delegate = 226 TabRestoreServiceDelegate* delegate =
227 TabRestoreServiceDelegate::FindDelegateForController(tab, NULL); 227 TabRestoreServiceDelegate::FindDelegateForController(tab, NULL);
228 if (closing_delegates_.find(delegate) != closing_delegates_.end()) 228 if (closing_delegates_.find(delegate) != closing_delegates_.end())
229 return; 229 return;
230 230
231 scoped_ptr<Tab> local_tab(new Tab()); 231 scoped_ptr<Tab> local_tab(new Tab());
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
479 } 479 }
480 } 480 }
481 if (pending_reset()) 481 if (pending_reset())
482 entries_written_ = 0; 482 entries_written_ = 0;
483 BaseSessionService::Save(); 483 BaseSessionService::Save();
484 } 484 }
485 485
486 void TabRestoreService::PopulateTab(Tab* tab, 486 void TabRestoreService::PopulateTab(Tab* tab,
487 int index, 487 int index,
488 TabRestoreServiceDelegate* delegate, 488 TabRestoreServiceDelegate* delegate,
489 NavigationController* controller) { 489 content::NavigationController* controller) {
490 const int pending_index = controller->GetPendingEntryIndex(); 490 const int pending_index = controller->GetPendingEntryIndex();
491 int entry_count = controller->GetEntryCount(); 491 int entry_count = controller->GetEntryCount();
492 if (entry_count == 0 && pending_index == 0) 492 if (entry_count == 0 && pending_index == 0)
493 entry_count++; 493 entry_count++;
494 tab->navigations.resize(static_cast<int>(entry_count)); 494 tab->navigations.resize(static_cast<int>(entry_count));
495 for (int i = 0; i < entry_count; ++i) { 495 for (int i = 0; i < entry_count; ++i) {
496 NavigationEntry* entry = (i == pending_index) ? 496 NavigationEntry* entry = (i == pending_index) ?
497 controller->GetPendingEntry() : controller->GetEntryAtIndex(i); 497 controller->GetPendingEntry() : controller->GetEntryAtIndex(i);
498 tab->navigations[i].SetFromNavigationEntry(*entry); 498 tab->navigations[i].SetFromNavigationEntry(*entry);
499 } 499 }
(...skipping 666 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 // the front, not the end and we just added the entries to the end). 1166 // the front, not the end and we just added the entries to the end).
1167 entries_to_write_ = staging_entries_.size(); 1167 entries_to_write_ = staging_entries_.size();
1168 1168
1169 PruneEntries(); 1169 PruneEntries();
1170 NotifyTabsChanged(); 1170 NotifyTabsChanged();
1171 } 1171 }
1172 1172
1173 Time TabRestoreService::TimeNow() const { 1173 Time TabRestoreService::TimeNow() const {
1174 return time_factory_ ? time_factory_->TimeNow() : Time::Now(); 1174 return time_factory_ ? time_factory_->TimeNow() : Time::Now();
1175 } 1175 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698