Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1540)

Unified Diff: chrome/browser/ui/views/frame/system_menu_model_delegate.cc

Issue 488643005: Fixes regression from changes to restore tabs (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/frame/system_menu_model_delegate.cc
diff --git a/chrome/browser/ui/views/frame/system_menu_model_delegate.cc b/chrome/browser/ui/views/frame/system_menu_model_delegate.cc
index 380dc81bbee3f52b312951b737a25878575948c6..9d5444bfdddfabfb68e506ca4a81729bdfb44ff5 100644
--- a/chrome/browser/ui/views/frame/system_menu_model_delegate.cc
+++ b/chrome/browser/ui/views/frame/system_menu_model_delegate.cc
@@ -37,7 +37,23 @@ 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;
+
+ // IDC_RESTORE_TAB is initially true while TabRestoreService loads. Return
+ // false if this is the case as we don't have a good way to dynamically update
+ // the menu.
pkotwicz 2014/08/19 21:12:14 Nit: chrome::IsCommandEnabled() returns true for I
sky 2014/08/19 21:35:08 Done.
+ // 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 +73,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);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698