diff options
author | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 18:58:07 +0000 |
---|---|---|
committer | sadrul@chromium.org <sadrul@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-11-24 18:58:07 +0000 |
commit | 23214631f9f132f7f08c8e13f2137b7334dd6aea (patch) | |
tree | 69981d81034b03bbdd239355e005d8d54bc45af1 /chrome/browser/tabs | |
parent | 93dbabaadefbfc5750e5b7284c1ebd005e006182 (diff) | |
download | chromium_src-23214631f9f132f7f08c8e13f2137b7334dd6aea.zip chromium_src-23214631f9f132f7f08c8e13f2137b7334dd6aea.tar.gz chromium_src-23214631f9f132f7f08c8e13f2137b7334dd6aea.tar.bz2 |
views: Show accelerators in tabstrip context menu.
As it happens, the command-id is a TabStripModel::ContextMenuCommand. So it
needs to be converted into a browser command first, before the accelerator is
looked up.
BUG=None
TEST=Right click on a tab. The context menu should have proper accelerators
displayed (e.g. Ctrl+T for the 'New Tab' option).
Review URL: http://codereview.chromium.org/5331005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@67289 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tabs')
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.cc | 34 | ||||
-rw-r--r-- | chrome/browser/tabs/tab_strip_model.h | 4 |
2 files changed, 38 insertions, 0 deletions
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc index 1341578..51582ad 100644 --- a/chrome/browser/tabs/tab_strip_model.cc +++ b/chrome/browser/tabs/tab_strip_model.cc @@ -10,6 +10,7 @@ #include "base/stl_util-inl.h" #include "base/string_util.h" #include "build/build_config.h" +#include "chrome/app/chrome_command_ids.h" #include "chrome/browser/bookmarks/bookmark_model.h" #include "chrome/browser/browser_shutdown.h" #include "chrome/browser/defaults.h" @@ -795,6 +796,39 @@ void TabStripModel::Observe(NotificationType type, } } +// static +bool TabStripModel::ContextMenuCommandToBrowserCommand(int cmd_id, + int* browser_cmd) { + switch (cmd_id) { + case CommandNewTab: + *browser_cmd = IDC_NEW_TAB; + break; + case CommandReload: + *browser_cmd = IDC_RELOAD; + break; + case CommandDuplicate: + *browser_cmd = IDC_DUPLICATE_TAB; + break; + case CommandCloseTab: + *browser_cmd = IDC_CLOSE_TAB; + break; + case CommandRestoreTab: + *browser_cmd = IDC_RESTORE_TAB; + break; + case CommandBookmarkAllTabs: + *browser_cmd = IDC_BOOKMARK_ALL_TABS; + break; + case CommandUseVerticalTabs: + *browser_cmd = IDC_TOGGLE_VERTICAL_TABS; + break; + default: + *browser_cmd = 0; + return false; + } + + return true; +} + /////////////////////////////////////////////////////////////////////////////// // TabStripModel, private: diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h index 8d385cb..2aae16e 100644 --- a/chrome/browser/tabs/tab_strip_model.h +++ b/chrome/browser/tabs/tab_strip_model.h @@ -411,6 +411,10 @@ class TabStripModel : public NotificationObserver { const NotificationSource& source, const NotificationDetails& details); + // Convert a ContextMenuCommand into a browser command. Returns true if a + // corresponding browser command exists, false otherwise. + static bool ContextMenuCommandToBrowserCommand(int cmd_id, int* browser_cmd); + private: // We cannot be constructed without a delegate. TabStripModel(); |