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 string16 menu_text(entry->GetTitleForDisplay( | 87 base::i18n::String16WithDirection menu_text(entry->GetTitleForDisplay( |
88 GetTabContents()->profile()->GetPrefs()-> | 88 GetTabContents()->profile()->GetPrefs()-> |
89 GetString(prefs::kAcceptLanguages))); | 89 GetString(prefs::kAcceptLanguages))); |
90 menu_text = ui::ElideText(menu_text, gfx::Font(), kMaxWidth, false); | 90 string16 elided = |
| 91 ui::ElideText(menu_text.string(), gfx::Font(), kMaxWidth, false); |
91 | 92 |
92 #if !defined(OS_MACOSX) | 93 #if !defined(OS_MACOSX) |
93 for (size_t i = menu_text.find('&'); i != string16::npos; | 94 for (size_t i = elided.find('&'); i != string16::npos; |
94 i = menu_text.find('&', i + 2)) { | 95 i = elided.find('&', i + 2)) { |
95 menu_text.insert(i, 1, '&'); | 96 elided.insert(i, 1, '&'); |
96 } | 97 } |
97 #endif | 98 #endif |
98 | 99 |
99 return menu_text; | 100 // TODO(evan): use directionality of title. |
| 101 // http://code.google.com/p/chromium/issues/detail?id=27094 |
| 102 return elided; |
100 } | 103 } |
101 | 104 |
102 bool BackForwardMenuModel::IsItemDynamicAt(int index) const { | 105 bool BackForwardMenuModel::IsItemDynamicAt(int index) const { |
103 // This object is only used for a single showing of a menu. | 106 // This object is only used for a single showing of a menu. |
104 return false; | 107 return false; |
105 } | 108 } |
106 | 109 |
107 bool BackForwardMenuModel::GetAcceleratorAt( | 110 bool BackForwardMenuModel::GetAcceleratorAt( |
108 int index, | 111 int index, |
109 ui::Accelerator* accelerator) const { | 112 ui::Accelerator* accelerator) const { |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 metric_string += "ForwardMenu_"; | 455 metric_string += "ForwardMenu_"; |
453 else | 456 else |
454 metric_string += "BackMenu_"; | 457 metric_string += "BackMenu_"; |
455 metric_string += action; | 458 metric_string += action; |
456 if (index != -1) { | 459 if (index != -1) { |
457 // +1 is for historical reasons (indices used to start at 1). | 460 // +1 is for historical reasons (indices used to start at 1). |
458 metric_string += base::IntToString(index + 1); | 461 metric_string += base::IntToString(index + 1); |
459 } | 462 } |
460 return metric_string; | 463 return metric_string; |
461 } | 464 } |
OLD | NEW |