Commit e9f5f3bf authored by pkasting@chromium.org's avatar pkasting@chromium.org

Make "Reopen closed tab" be "Reopen closed window" when a window is the top...

Make "Reopen closed tab" be "Reopen closed window" when a window is the top item on the closed tabs stack.

Original patch by Miranda Callahan (see http://codereview.chromium.org/100054 ), r=me.

BUG=11183

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@14910 0039d316-1c4b-4281-b951-d872f2087c98
parent 756e2592
This diff is collapsed.
...@@ -474,9 +474,18 @@ void BrowserView::PrepareToRunSystemMenu(HMENU menu) { ...@@ -474,9 +474,18 @@ void BrowserView::PrepareToRunSystemMenu(HMENU menu) {
// IDS_ZOOM) and on separators. // IDS_ZOOM) and on separators.
if (command != 0) { if (command != 0) {
bool enabled = browser_->command_updater()->IsCommandEnabled(command); bool enabled = browser_->command_updater()->IsCommandEnabled(command);
if (enabled && command == IDC_RESTORE_TAB) if (enabled && command == IDC_RESTORE_TAB) {
enabled = browser_->profile()->GetTabRestoreService() && TabRestoreService* tab_restore_service =
!browser_->profile()->GetTabRestoreService()->entries().empty(); browser_->profile()->GetTabRestoreService();
if (tab_restore_service && !tab_restore_service->entries().empty()) {
system_menu_->SetMenuLabel(command, l10n_util::GetString(
tab_restore_service->entries().front()->type ==
TabRestoreService::WINDOW ? IDS_RESTORE_WINDOW :
IDS_RESTORE_TAB));
} else {
enabled = false;
}
}
system_menu_->EnableMenuItemByID(command, enabled); system_menu_->EnableMenuItemByID(command, enabled);
} }
} }
......
...@@ -450,6 +450,15 @@ void Menu::EnableMenuItemAt(int index, bool enabled) { ...@@ -450,6 +450,15 @@ void Menu::EnableMenuItemAt(int index, bool enabled) {
EnableMenuItem(menu_, index, MF_BYPOSITION | enable_flags); EnableMenuItem(menu_, index, MF_BYPOSITION | enable_flags);
} }
void Menu::SetMenuLabel(int item_id, const std::wstring& label) {
MENUITEMINFO mii = {0};
mii.cbSize = sizeof(mii);
mii.fMask = MIIM_STRING;
mii.dwTypeData = const_cast<wchar_t*>(label.c_str());
mii.cch = static_cast<UINT>(label.size());
SetMenuItemInfo(menu_, item_id, false, &mii);
}
DWORD Menu::GetTPMAlignFlags() const { DWORD Menu::GetTPMAlignFlags() const {
// The manner in which we handle the menu alignment depends on whether or not // The manner in which we handle the menu alignment depends on whether or not
// the menu is displayed within a mirrored view. If the UI is mirrored, the // the menu is displayed within a mirrored view. If the UI is mirrored, the
......
...@@ -268,6 +268,9 @@ class Menu { ...@@ -268,6 +268,9 @@ class Menu {
void EnableMenuItemByID(int item_id, bool enabled); void EnableMenuItemByID(int item_id, bool enabled);
void EnableMenuItemAt(int index, bool enabled); void EnableMenuItemAt(int index, bool enabled);
// Sets menu label at specified index.
void SetMenuLabel(int item_id, const std::wstring& label);
// Sets an icon for an item with a given item_id. Calling this function // Sets an icon for an item with a given item_id. Calling this function
// also forces the Menu class to draw the menu, instead of relying on Windows. // also forces the Menu class to draw the menu, instead of relying on Windows.
// Returns false if the item with |item_id| is not found. // Returns false if the item with |item_id| is not found.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment