diff options
author | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 15:39:21 +0000 |
---|---|---|
committer | sky@google.com <sky@google.com@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-10-17 15:39:21 +0000 |
commit | 0c03b4947c75f74b5704438d09a49e0b20e23972 (patch) | |
tree | ca88439681b7524066ea505093eb6964f3c8545b /chrome/browser/dom_ui | |
parent | e6cdd9290d582f685bcc17f2068f36c244241431 (diff) | |
download | chromium_src-0c03b4947c75f74b5704438d09a49e0b20e23972.zip chromium_src-0c03b4947c75f74b5704438d09a49e0b20e23972.tar.gz chromium_src-0c03b4947c75f74b5704438d09a49e0b20e23972.tar.bz2 |
Removes expiring of recently closed tabs from new tab page. Also makes
it so that if you restore a tab we remove from the tab restore service
(this is what control-shift-t does too).
BUG=2598
TEST=make sure closed tabs still show up on the new tab page.
Review URL: http://codereview.chromium.org/4016
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@3529 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/dom_ui')
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.cc | 36 | ||||
-rw-r--r-- | chrome/browser/dom_ui/new_tab_ui.h | 3 |
2 files changed, 5 insertions, 34 deletions
diff --git a/chrome/browser/dom_ui/new_tab_ui.cc b/chrome/browser/dom_ui/new_tab_ui.cc index dd2786a..3e36ab4 100644 --- a/chrome/browser/dom_ui/new_tab_ui.cc +++ b/chrome/browser/dom_ui/new_tab_ui.cc @@ -553,8 +553,7 @@ void RecentlyBookmarkedHandler::BookmarkNodeChanged(BookmarkModel* model, RecentlyClosedTabsHandler::RecentlyClosedTabsHandler(DOMUIHost* dom_ui_host) : dom_ui_host_(dom_ui_host), - tab_restore_service_(NULL), - handle_recently_closed_tab_factory_(this) { + tab_restore_service_(NULL) { dom_ui_host->RegisterMessageCallback("getRecentlyClosedTabs", NewCallback(this, &RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs)); @@ -597,8 +596,10 @@ void RecentlyClosedTabsHandler::HandleReopenTab(const Value* content) { for (TabRestoreService::Tabs::const_iterator it = tabs.begin(); it != tabs.end(); ++it) { if (it->id == session_to_restore) { + TabRestoreService* tab_restore_service = tab_restore_service_; browser->ReplaceRestoredTab( it->navigations, it->current_navigation_index); + tab_restore_service->RemoveHistoricalTabById(session_to_restore); // The current tab has been nuked at this point; // don't touch any member variables. break; @@ -626,31 +627,17 @@ void RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs( void RecentlyClosedTabsHandler::TabRestoreServiceChanged( TabRestoreService* service) { - handle_recently_closed_tab_factory_.RevokeAll(); - const TabRestoreService::Tabs& tabs = service->tabs(); ListValue list_value; int added_count = 0; - Time now = Time::Now(); - TimeDelta expire_delta = TimeDelta::FromMinutes(5); - Time five_minutes_ago = now - expire_delta; - Time oldest_item = now; - - // We filter the list of recently closed to only show 'interesting' - // tabs, where an interesting tab has navigations, was closed within - // the last five minutes and is not the new tab ui. + // We filter the list of recently closed to only show 'interesting' tabs, + // where an interesting tab navigation is not the new tab ui. for (TabRestoreService::Tabs::const_iterator it = tabs.begin(); it != tabs.end() && added_count < 3; ++it) { if (it->navigations.empty()) continue; - if (five_minutes_ago > it->close_time) - continue; - - if (it->close_time < oldest_item) - oldest_item = it->close_time; - const TabNavigation& navigator = it->navigations.at(it->current_navigation_index); if (navigator.url == NewTabUIURL()) @@ -663,19 +650,6 @@ void RecentlyClosedTabsHandler::TabRestoreServiceChanged( list_value.Append(dictionary); added_count++; } - - // If we displayed anything, we must schedule a redisplay when the - // oldest item expires. - if (added_count) { - TimeDelta next_run = (oldest_item + expire_delta) - now; - - MessageLoop::current()->PostDelayedTask(FROM_HERE, - handle_recently_closed_tab_factory_.NewRunnableMethod( - &RecentlyClosedTabsHandler::HandleGetRecentlyClosedTabs, - reinterpret_cast<const Value*>(NULL)), - static_cast<int>(next_run.InMilliseconds())); - } - dom_ui_host_->CallJavascriptFunction(L"recentlyClosedTabs", list_value); } diff --git a/chrome/browser/dom_ui/new_tab_ui.h b/chrome/browser/dom_ui/new_tab_ui.h index 092cdb4..702f06e 100644 --- a/chrome/browser/dom_ui/new_tab_ui.h +++ b/chrome/browser/dom_ui/new_tab_ui.h @@ -250,9 +250,6 @@ class RecentlyClosedTabsHandler : public DOMMessageHandler, /// TabRestoreService that we are observing. TabRestoreService* tab_restore_service_; - /// Controls the periodic calling of HandleRecentlyClosedTabs. - ScopedRunnableMethodFactory<RecentlyClosedTabsHandler> handle_recently_closed_tab_factory_; - DISALLOW_EVIL_CONSTRUCTORS(RecentlyClosedTabsHandler); }; |