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

Side by Side Diff: chrome/browser/ui/views/frame/system_menu_model_delegate.cc

Issue 1350653004: [sessions] Properly namespace recently-componentized TabRestore code (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac Created 5 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h" 5 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "chrome/app/chrome_command_ids.h" 8 #include "chrome/app/chrome_command_ids.h"
9 #include "chrome/browser/command_updater.h" 9 #include "chrome/browser/command_updater.h"
10 #include "chrome/browser/profiles/profile.h" 10 #include "chrome/browser/profiles/profile.h"
(...skipping 30 matching lines...) Expand all
41 return false; 41 return false;
42 42
43 if (command_id != IDC_RESTORE_TAB) 43 if (command_id != IDC_RESTORE_TAB)
44 return true; 44 return true;
45 45
46 // chrome::IsCommandEnabled(IDC_RESTORE_TAB) returns true if TabRestoreService 46 // chrome::IsCommandEnabled(IDC_RESTORE_TAB) returns true if TabRestoreService
47 // hasn't been loaded yet. Return false if this is the case as we don't have 47 // hasn't been loaded yet. Return false if this is the case as we don't have
48 // a good way to dynamically update the menu when TabRestoreService finishes 48 // a good way to dynamically update the menu when TabRestoreService finishes
49 // loading. 49 // loading.
50 // TODO(sky): add a way to update menu. 50 // TODO(sky): add a way to update menu.
51 TabRestoreService* trs = 51 sessions::TabRestoreService* trs =
52 TabRestoreServiceFactory::GetForProfile(browser_->profile()); 52 TabRestoreServiceFactory::GetForProfile(browser_->profile());
53 if (!trs->IsLoaded()) { 53 if (!trs->IsLoaded()) {
54 trs->LoadTabsFromLastSession(); 54 trs->LoadTabsFromLastSession();
55 return false; 55 return false;
56 } 56 }
57 return true; 57 return true;
58 } 58 }
59 59
60 bool SystemMenuModelDelegate::GetAcceleratorForCommandId(int command_id, 60 bool SystemMenuModelDelegate::GetAcceleratorForCommandId(int command_id,
61 ui::Accelerator* accelerator) { 61 ui::Accelerator* accelerator) {
62 return provider_->GetAcceleratorForCommandId(command_id, accelerator); 62 return provider_->GetAcceleratorForCommandId(command_id, accelerator);
63 } 63 }
64 64
65 bool SystemMenuModelDelegate::IsItemForCommandIdDynamic(int command_id) const { 65 bool SystemMenuModelDelegate::IsItemForCommandIdDynamic(int command_id) const {
66 return command_id == IDC_RESTORE_TAB; 66 return command_id == IDC_RESTORE_TAB;
67 } 67 }
68 68
69 base::string16 SystemMenuModelDelegate::GetLabelForCommandId( 69 base::string16 SystemMenuModelDelegate::GetLabelForCommandId(
70 int command_id) const { 70 int command_id) const {
71 DCHECK_EQ(command_id, IDC_RESTORE_TAB); 71 DCHECK_EQ(command_id, IDC_RESTORE_TAB);
72 72
73 int string_id = IDS_RESTORE_TAB; 73 int string_id = IDS_RESTORE_TAB;
74 if (IsCommandIdEnabled(command_id)) { 74 if (IsCommandIdEnabled(command_id)) {
75 TabRestoreService* trs = 75 sessions::TabRestoreService* trs =
76 TabRestoreServiceFactory::GetForProfile(browser_->profile()); 76 TabRestoreServiceFactory::GetForProfile(browser_->profile());
77 trs->LoadTabsFromLastSession(); 77 trs->LoadTabsFromLastSession();
78 if (trs && !trs->entries().empty() && 78 if (trs && !trs->entries().empty() &&
79 trs->entries().front()->type == TabRestoreService::WINDOW) 79 trs->entries().front()->type == sessions::TabRestoreService::WINDOW)
80 string_id = IDS_RESTORE_WINDOW; 80 string_id = IDS_RESTORE_WINDOW;
81 } 81 }
82 return l10n_util::GetStringUTF16(string_id); 82 return l10n_util::GetStringUTF16(string_id);
83 } 83 }
84 84
85 void SystemMenuModelDelegate::ExecuteCommand(int command_id, int event_flags) { 85 void SystemMenuModelDelegate::ExecuteCommand(int command_id, int event_flags) {
86 chrome::ExecuteCommand(browser_, command_id); 86 chrome::ExecuteCommand(browser_, command_id);
87 } 87 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/global_menu_bar_x11.cc ('k') | components/sessions/base_session_service_commands.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698