| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2009 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. | |
| 4 | |
| 5 #include "chrome/browser/gtk/back_forward_menu_model_gtk.h" | |
| 6 | |
| 7 #include "app/l10n_util.h" | |
| 8 #include "base/string_util.h" | |
| 9 #include "chrome/browser/gtk/back_forward_button_gtk.h" | |
| 10 | |
| 11 // Might want to vary this by locale. | |
| 12 static const size_t kMaxChars = 50; | |
| 13 | |
| 14 BackForwardMenuModelGtk::BackForwardMenuModelGtk(Browser* browser, | |
| 15 ModelType model_type, | |
| 16 BackForwardButtonGtk* button) | |
| 17 : BackForwardMenuModel(browser, model_type), | |
| 18 button_(button) { | |
| 19 } | |
| 20 | |
| 21 int BackForwardMenuModelGtk::GetItemCount() const { | |
| 22 return GetTotalItemCount(); | |
| 23 } | |
| 24 | |
| 25 bool BackForwardMenuModelGtk::IsItemSeparator(int command_id) const { | |
| 26 return IsSeparator(command_id); | |
| 27 } | |
| 28 | |
| 29 std::string BackForwardMenuModelGtk::GetLabel(int command_id) const { | |
| 30 std::wstring item_label_wstr = UTF16ToWideHack(GetItemLabel(command_id)); | |
| 31 // This breaks on word boundaries. Ideally we would break on character | |
| 32 // boundaries. | |
| 33 item_label_wstr = l10n_util::TruncateString(item_label_wstr, kMaxChars); | |
| 34 return WideToUTF8(item_label_wstr); | |
| 35 } | |
| 36 | |
| 37 bool BackForwardMenuModelGtk::HasIcon(int command_id) const { | |
| 38 return ItemHasIcon(command_id); | |
| 39 } | |
| 40 | |
| 41 const SkBitmap* BackForwardMenuModelGtk::GetIcon(int command_id) const { | |
| 42 return &GetItemIcon(command_id); | |
| 43 } | |
| 44 | |
| 45 bool BackForwardMenuModelGtk::IsCommandEnabled(int command_id) const { | |
| 46 return ItemHasCommand(command_id); | |
| 47 } | |
| 48 | |
| 49 void BackForwardMenuModelGtk::ExecuteCommand(int command_id) { | |
| 50 ExecuteCommandById(command_id); | |
| 51 } | |
| 52 | |
| 53 void BackForwardMenuModelGtk::StoppedShowing() { | |
| 54 if (button_) | |
| 55 button_->StoppedShowingMenu(); | |
| 56 } | |
| 57 | |
| 58 bool BackForwardMenuModelGtk::AlwaysShowImages() const { | |
| 59 return true; | |
| 60 } | |
| OLD | NEW |