Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / views / frame / system_menu_model_delegate.cc
blob0bfc61ad767c5141f86c07be005e8d7a0ef369ac
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
3 // found in the LICENSE file.
5 #include "chrome/browser/ui/views/frame/system_menu_model_delegate.h"
7 #include "chrome/app/chrome_command_ids.h"
8 #include "chrome/browser/command_updater.h"
9 #include "chrome/browser/sessions/tab_restore_service.h"
10 #include "chrome/browser/sessions/tab_restore_service_factory.h"
11 #include "chrome/browser/ui/browser_commands.h"
12 #include "grit/generated_resources.h"
13 #include "ui/base/l10n/l10n_util.h"
15 SystemMenuModelDelegate::SystemMenuModelDelegate(
16 ui::AcceleratorProvider* provider,
17 Browser* browser)
18 : provider_(provider),
19 browser_(browser) {
22 SystemMenuModelDelegate::~SystemMenuModelDelegate() {
25 bool SystemMenuModelDelegate::IsCommandIdChecked(int command_id) const {
26 // TODO(beng): encoding menu.
27 // No items in our system menu are check-able.
28 return false;
31 bool SystemMenuModelDelegate::IsCommandIdEnabled(int command_id) const {
32 return chrome::IsCommandEnabled(browser_, command_id);
35 bool SystemMenuModelDelegate::GetAcceleratorForCommandId(int command_id,
36 ui::Accelerator* accelerator) {
37 return provider_->GetAcceleratorForCommandId(command_id, accelerator);
40 bool SystemMenuModelDelegate::IsItemForCommandIdDynamic(int command_id) const {
41 return command_id == IDC_RESTORE_TAB;
44 base::string16 SystemMenuModelDelegate::GetLabelForCommandId(
45 int command_id) const {
46 DCHECK_EQ(command_id, IDC_RESTORE_TAB);
48 int string_id = IDS_RESTORE_TAB;
49 if (IsCommandIdEnabled(command_id)) {
50 TabRestoreService* trs =
51 TabRestoreServiceFactory::GetForProfile(browser_->profile());
52 if (trs && trs->entries().front()->type == TabRestoreService::WINDOW)
53 string_id = IDS_RESTORE_WINDOW;
55 return l10n_util::GetStringUTF16(string_id);
58 void SystemMenuModelDelegate::ExecuteCommand(int command_id, int event_flags) {
59 chrome::ExecuteCommand(browser_, command_id);