Commit d9e358e5 authored by sky@chromium.org's avatar sky@chromium.org

Fixes regression from changes to restore tabs

The code was assuming that if IDC_RESTORE_TAB returned true that the
TabRestoreService had non-empty entries. This is no longer a valid
assumpion.

BUG=404407
TEST=see bug
R=pkotwicz@chromium.org

Review URL: https://codereview.chromium.org/488643005

Cr-Commit-Position: refs/heads/master@{#290772}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@290772 0039d316-1c4b-4281-b951-d872f2087c98
parent f90b9a4c
......@@ -37,7 +37,24 @@ bool SystemMenuModelDelegate::IsCommandIdChecked(int command_id) const {
}
bool SystemMenuModelDelegate::IsCommandIdEnabled(int command_id) const {
return chrome::IsCommandEnabled(browser_, command_id);
if (!chrome::IsCommandEnabled(browser_, command_id))
return false;
if (command_id != IDC_RESTORE_TAB)
return true;
// chrome::IsCommandEnabled(IDC_RESTORE_TAB) returns true if TabRestoreService
// hasn't been loaded yet. Return false if this is the case as we don't have
// a good way to dynamically update the menu when TabRestoreService finishes
// loading.
// TODO(sky): add a way to update menu.
TabRestoreService* trs =
TabRestoreServiceFactory::GetForProfile(browser_->profile());
if (!trs->IsLoaded()) {
trs->LoadTabsFromLastSession();
return false;
}
return true;
}
bool SystemMenuModelDelegate::GetAcceleratorForCommandId(int command_id,
......@@ -57,7 +74,9 @@ base::string16 SystemMenuModelDelegate::GetLabelForCommandId(
if (IsCommandIdEnabled(command_id)) {
TabRestoreService* trs =
TabRestoreServiceFactory::GetForProfile(browser_->profile());
if (trs && trs->entries().front()->type == TabRestoreService::WINDOW)
trs->LoadTabsFromLastSession();
if (trs && !trs->entries().empty() &&
trs->entries().front()->type == TabRestoreService::WINDOW)
string_id = IDS_RESTORE_WINDOW;
}
return l10n_util::GetStringUTF16(string_id);
......
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