blob: f7fcf08f7230fc3266b36d1dc3031c8fbd0e0ceb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/ui/views/frame/system_menu_model_delegate.h"
#include "chrome/app/chrome_command_ids.h"
#include "chrome/browser/command_updater.h"
#include "chrome/browser/sessions/tab_restore_service.h"
#include "chrome/browser/sessions/tab_restore_service_factory.h"
#include "chrome/browser/ui/browser_commands.h"
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
SystemMenuModelDelegate::SystemMenuModelDelegate(
ui::AcceleratorProvider* provider,
Browser* browser)
: provider_(provider),
browser_(browser) {
}
SystemMenuModelDelegate::~SystemMenuModelDelegate() {
}
bool SystemMenuModelDelegate::IsCommandIdChecked(int command_id) const {
// TODO(beng): encoding menu.
// No items in our system menu are check-able.
return false;
}
bool SystemMenuModelDelegate::IsCommandIdEnabled(int command_id) const {
return chrome::IsCommandEnabled(browser_, command_id);
}
bool SystemMenuModelDelegate::GetAcceleratorForCommandId(int command_id,
ui::Accelerator* accelerator) {
return provider_->GetAcceleratorForCommandId(command_id, accelerator);
}
bool SystemMenuModelDelegate::IsItemForCommandIdDynamic(int command_id) const {
return command_id == IDC_RESTORE_TAB;
}
string16 SystemMenuModelDelegate::GetLabelForCommandId(int command_id) const {
DCHECK_EQ(command_id, IDC_RESTORE_TAB);
int string_id = IDS_RESTORE_TAB;
if (IsCommandIdEnabled(command_id)) {
TabRestoreService* trs =
TabRestoreServiceFactory::GetForProfile(browser_->profile());
if (trs && trs->entries().front()->type == TabRestoreService::WINDOW)
string_id = IDS_RESTORE_WINDOW;
}
return l10n_util::GetStringUTF16(string_id);
}
void SystemMenuModelDelegate::ExecuteCommand(int command_id) {
chrome::ExecuteCommand(browser_, command_id);
}
|