OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "build/build_config.h" | 5 #include "build/build_config.h" |
6 | 6 |
7 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" | 7 #include "chrome/browser/ui/toolbar/back_forward_menu_model.h" |
8 | 8 |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "chrome/browser/metrics/user_metrics.h" | 10 #include "chrome/browser/metrics/user_metrics.h" |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
77 if (index == GetItemCount() - 1) | 77 if (index == GetItemCount() - 1) |
78 return l10n_util::GetStringUTF16(IDS_SHOWFULLHISTORY_LINK); | 78 return l10n_util::GetStringUTF16(IDS_SHOWFULLHISTORY_LINK); |
79 | 79 |
80 // Return an empty string for a separator. | 80 // Return an empty string for a separator. |
81 if (IsSeparator(index)) | 81 if (IsSeparator(index)) |
82 return string16(); | 82 return string16(); |
83 | 83 |
84 // Return the entry title, escaping any '&' characters and eliding it if it's | 84 // Return the entry title, escaping any '&' characters and eliding it if it's |
85 // super long. | 85 // super long. |
86 NavigationEntry* entry = GetNavigationEntry(index); | 86 NavigationEntry* entry = GetNavigationEntry(index); |
87 base::i18n::String16WithDirection menu_text(entry->GetTitleForDisplay( | 87 string16 menu_text(entry->GetTitleForDisplay( |
88 GetTabContents()->profile()->GetPrefs()-> | 88 GetTabContents()->profile()->GetPrefs()-> |
89 GetString(prefs::kAcceptLanguages))); | 89 GetString(prefs::kAcceptLanguages))); |
90 string16 elided = | 90 menu_text = ui::ElideText(menu_text, gfx::Font(), kMaxWidth, false); |
91 ui::ElideText(menu_text.string(), gfx::Font(), kMaxWidth, false); | |
92 | 91 |
93 #if !defined(OS_MACOSX) | 92 #if !defined(OS_MACOSX) |
94 for (size_t i = elided.find('&'); i != string16::npos; | 93 for (size_t i = menu_text.find('&'); i != string16::npos; |
95 i = elided.find('&', i + 2)) { | 94 i = menu_text.find('&', i + 2)) { |
96 elided.insert(i, 1, '&'); | 95 menu_text.insert(i, 1, '&'); |
97 } | 96 } |
98 #endif | 97 #endif |
99 | 98 |
100 // TODO(evan): use directionality of title. | 99 return menu_text; |
101 // http://code.google.com/p/chromium/issues/detail?id=27094 | |
102 return elided; | |
103 } | 100 } |
104 | 101 |
105 bool BackForwardMenuModel::IsItemDynamicAt(int index) const { | 102 bool BackForwardMenuModel::IsItemDynamicAt(int index) const { |
106 // This object is only used for a single showing of a menu. | 103 // This object is only used for a single showing of a menu. |
107 return false; | 104 return false; |
108 } | 105 } |
109 | 106 |
110 bool BackForwardMenuModel::GetAcceleratorAt( | 107 bool BackForwardMenuModel::GetAcceleratorAt( |
111 int index, | 108 int index, |
112 ui::Accelerator* accelerator) const { | 109 ui::Accelerator* accelerator) const { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 metric_string += "ForwardMenu_"; | 452 metric_string += "ForwardMenu_"; |
456 else | 453 else |
457 metric_string += "BackMenu_"; | 454 metric_string += "BackMenu_"; |
458 metric_string += action; | 455 metric_string += action; |
459 if (index != -1) { | 456 if (index != -1) { |
460 // +1 is for historical reasons (indices used to start at 1). | 457 // +1 is for historical reasons (indices used to start at 1). |
461 metric_string += base::IntToString(index + 1); | 458 metric_string += base::IntToString(index + 1); |
462 } | 459 } |
463 return metric_string; | 460 return metric_string; |
464 } | 461 } |
OLD | NEW |