OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/extensions/menu_manager.h" | 5 #include "chrome/browser/extensions/menu_manager.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/json/json_writer.h" | 9 #include "base/json/json_writer.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
171 } | 171 } |
172 | 172 |
173 base::string16 MenuItem::TitleWithReplacement(const base::string16& selection, | 173 base::string16 MenuItem::TitleWithReplacement(const base::string16& selection, |
174 size_t max_length) const { | 174 size_t max_length) const { |
175 base::string16 result = base::UTF8ToUTF16(title_); | 175 base::string16 result = base::UTF8ToUTF16(title_); |
176 // TODO(asargent) - Change this to properly handle %% escaping so you can | 176 // TODO(asargent) - Change this to properly handle %% escaping so you can |
177 // put "%s" in titles that won't get substituted. | 177 // put "%s" in titles that won't get substituted. |
178 ReplaceSubstringsAfterOffset(&result, 0, base::ASCIIToUTF16("%s"), selection); | 178 ReplaceSubstringsAfterOffset(&result, 0, base::ASCIIToUTF16("%s"), selection); |
179 | 179 |
180 if (result.length() > max_length) | 180 if (result.length() > max_length) |
181 result = gfx::TruncateString(result, max_length); | 181 result = gfx::TruncateString(result, max_length, gfx::WORD_BREAK); |
182 return result; | 182 return result; |
183 } | 183 } |
184 | 184 |
185 bool MenuItem::SetChecked(bool checked) { | 185 bool MenuItem::SetChecked(bool checked) { |
186 if (type_ != CHECKBOX && type_ != RADIO) | 186 if (type_ != CHECKBOX && type_ != RADIO) |
187 return false; | 187 return false; |
188 checked_ = checked; | 188 checked_ = checked; |
189 return true; | 189 return true; |
190 } | 190 } |
191 | 191 |
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
943 if (uid < other.uid) | 943 if (uid < other.uid) |
944 return true; | 944 return true; |
945 if (uid == other.uid) | 945 if (uid == other.uid) |
946 return string_uid < other.string_uid; | 946 return string_uid < other.string_uid; |
947 } | 947 } |
948 } | 948 } |
949 return false; | 949 return false; |
950 } | 950 } |
951 | 951 |
952 } // namespace extensions | 952 } // namespace extensions |
OLD | NEW |