diff options
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 8 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.h | 7 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model_unittest.cc | 2 |
3 files changed, 17 insertions, 0 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 43ec063..52c056d 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -9,6 +9,7 @@ #include "base/string_util.h" #include "chrome/browser/metrics/user_metrics.h" #include "chrome/browser/profile.h" +#include "chrome/browser/sessions/tab_restore_service.h" #include "chrome/browser/tabs/tab_strip_model_order_controller.h" #include "chrome/browser/tab_contents/navigation_controller.h" #include "chrome/browser/tab_contents/tab_contents.h" @@ -422,6 +423,8 @@ bool TabStripModel::IsContextMenuCommandEnabled( } case CommandDuplicate: return delegate_->CanDuplicateContentsAt(context_index); + case CommandRestoreTab: + return delegate_->CanRestoreTab(); default: NOTREACHED(); } @@ -475,6 +478,11 @@ void TabStripModel::ExecuteContextMenuCommand( break; } + case CommandRestoreTab: { + UserMetrics::RecordAction(L"TabContextMenu_RestoreTab", profile_); + delegate_->RestoreTab(); + break; + } default: NOTREACHED(); } diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 3386954..5530f8b 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -165,6 +165,12 @@ class TabStripModelDelegate { // TabContents. If it returns false, there are no unload listeners and the // TabStripModel can close the TabContents immediately. virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) = 0; + + // Returns true if a tab can be restored. + virtual bool CanRestoreTab() = 0; + + // Restores the last closed tab if CanRestoreTab would return true. + virtual void RestoreTab() = 0; }; //////////////////////////////////////////////////////////////////////////////// @@ -403,6 +409,7 @@ class TabStripModel : public NotificationObserver { CommandCloseOtherTabs, CommandCloseTabsToRight, CommandCloseTabsOpenedBy, + CommandRestoreTab, CommandLast }; diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc index 2ff6db6..056ff5f 100644 --- a/chrome/browser/tabs/tab_strip_model_unittest.cc +++ b/chrome/browser/tabs/tab_strip_model_unittest.cc @@ -54,6 +54,8 @@ class TabStripDummyDelegate : public TabStripModelDelegate { virtual bool RunUnloadListenerBeforeClosing(TabContents* contents) { return false; } + virtual bool CanRestoreTab() { return false; } + virtual void RestoreTab() {} private: // A dummy TabContents we give to callers that expect us to actually build a |