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 "chrome/browser/extensions/extension_menu_manager.h" | 5 #include "chrome/browser/extensions/extension_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" |
11 #include "base/stl_util.h" | 11 #include "base/stl_util.h" |
12 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/utf_string_conversions.h" | 13 #include "base/utf_string_conversions.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "chrome/browser/extensions/extension_event_router.h" | 15 #include "chrome/browser/extensions/extension_event_router.h" |
16 #include "chrome/browser/extensions/extension_tabs_module.h" | 16 #include "chrome/browser/extensions/extension_tabs_module.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/common/chrome_notification_types.h" | 18 #include "chrome/common/chrome_notification_types.h" |
19 #include "chrome/common/extensions/extension.h" | 19 #include "chrome/common/extensions/extension.h" |
20 #include "content/common/notification_service.h" | 20 #include "content/common/notification_service.h" |
21 #include "ui/base/l10n/l10n_util.h" | 21 #include "ui/base/text/text_elider.h" |
22 #include "ui/gfx/favicon_size.h" | 22 #include "ui/gfx/favicon_size.h" |
23 #include "webkit/glue/context_menu.h" | 23 #include "webkit/glue/context_menu.h" |
24 | 24 |
25 ExtensionMenuItem::ExtensionMenuItem(const Id& id, | 25 ExtensionMenuItem::ExtensionMenuItem(const Id& id, |
26 const std::string& title, | 26 const std::string& title, |
27 bool checked, | 27 bool checked, |
28 Type type, | 28 Type type, |
29 const ContextList& contexts) | 29 const ContextList& contexts) |
30 : id_(id), | 30 : id_(id), |
31 title_(title), | 31 title_(title), |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 } | 69 } |
70 | 70 |
71 string16 ExtensionMenuItem::TitleWithReplacement( | 71 string16 ExtensionMenuItem::TitleWithReplacement( |
72 const string16& selection, size_t max_length) const { | 72 const string16& selection, size_t max_length) const { |
73 string16 result = UTF8ToUTF16(title_); | 73 string16 result = UTF8ToUTF16(title_); |
74 // TODO(asargent) - Change this to properly handle %% escaping so you can | 74 // TODO(asargent) - Change this to properly handle %% escaping so you can |
75 // put "%s" in titles that won't get substituted. | 75 // put "%s" in titles that won't get substituted. |
76 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16("%s"), selection); | 76 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16("%s"), selection); |
77 | 77 |
78 if (result.length() > max_length) | 78 if (result.length() > max_length) |
79 result = l10n_util::TruncateString(result, max_length); | 79 result = ui::TruncateString(result, max_length); |
80 return result; | 80 return result; |
81 } | 81 } |
82 | 82 |
83 bool ExtensionMenuItem::SetChecked(bool checked) { | 83 bool ExtensionMenuItem::SetChecked(bool checked) { |
84 if (type_ != CHECKBOX && type_ != RADIO) | 84 if (type_ != CHECKBOX && type_ != RADIO) |
85 return false; | 85 return false; |
86 checked_ = checked; | 86 checked_ = checked; |
87 return true; | 87 return true; |
88 } | 88 } |
89 | 89 |
(...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 if (profile < other.profile) | 493 if (profile < other.profile) |
494 return true; | 494 return true; |
495 if (profile == other.profile) { | 495 if (profile == other.profile) { |
496 if (extension_id < other.extension_id) | 496 if (extension_id < other.extension_id) |
497 return true; | 497 return true; |
498 if (extension_id == other.extension_id) | 498 if (extension_id == other.extension_id) |
499 return uid < other.uid; | 499 return uid < other.uid; |
500 } | 500 } |
501 return false; | 501 return false; |
502 } | 502 } |
OLD | NEW |