blob: a1ce91e0cfb0714834064469c98c2bc34a9870ab (
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
60
|
// Copyright (c) 2009 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/gtk/back_forward_menu_model_gtk.h"
#include "app/l10n_util.h"
#include "base/string_util.h"
#include "chrome/browser/gtk/back_forward_button_gtk.h"
// Might want to vary this by locale.
static const size_t kMaxChars = 50;
BackForwardMenuModelGtk::BackForwardMenuModelGtk(Browser* browser,
ModelType model_type,
BackForwardButtonGtk* button)
: BackForwardMenuModel(browser, model_type),
button_(button) {
}
int BackForwardMenuModelGtk::GetItemCount() const {
return GetTotalItemCount();
}
bool BackForwardMenuModelGtk::IsItemSeparator(int command_id) const {
return IsSeparator(command_id);
}
std::string BackForwardMenuModelGtk::GetLabel(int command_id) const {
std::wstring item_label_wstr = UTF16ToWideHack(GetItemLabel(command_id));
// This breaks on word boundaries. Ideally we would break on character
// boundaries.
item_label_wstr = l10n_util::TruncateString(item_label_wstr, kMaxChars);
return WideToUTF8(item_label_wstr);
}
bool BackForwardMenuModelGtk::HasIcon(int command_id) const {
return ItemHasIcon(command_id);
}
const SkBitmap* BackForwardMenuModelGtk::GetIcon(int command_id) const {
return &GetItemIcon(command_id);
}
bool BackForwardMenuModelGtk::IsCommandEnabled(int command_id) const {
return ItemHasCommand(command_id);
}
void BackForwardMenuModelGtk::ExecuteCommand(int command_id) {
ExecuteCommandById(command_id);
}
void BackForwardMenuModelGtk::StoppedShowing() {
if (button_)
button_->StoppedShowingMenu();
}
bool BackForwardMenuModelGtk::AlwaysShowImages() const {
return true;
}
|