diff options
author | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 15:23:43 +0000 |
---|---|---|
committer | idanan@chromium.org <idanan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-04-14 15:23:43 +0000 |
commit | a8eff106de173d7b5b20946ad497198a0eefec8d (patch) | |
tree | 6c0da9d71f912d00101410d9d0d00b55757b131b /chrome/browser/tabs | |
parent | 6420421e6f15f25891c88661431ce9483ccfdba7 (diff) | |
download | chromium_src-a8eff106de173d7b5b20946ad497198a0eefec8d.zip chromium_src-a8eff106de173d7b5b20946ad497198a0eefec8d.tar.gz chromium_src-a8eff106de173d7b5b20946ad497198a0eefec8d.tar.bz2 |
Added undo tab closing item to Tab menu.
Review URL: http://codereview.chromium.org/62151
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@13662 0039d316-1c4b-4281-b951-d872f2087c98
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 |