Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Side by Side Diff: chrome/browser/extensions/extension_menu_manager.cc

Issue 3035053: Merge 54514 - Set a max limit on extension items' labels in context menus.... (Closed) Base URL: svn://svn.chromium.org/chrome/branches/479/src/
Patch Set: Created 10 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 "app/l10n_util.h"
9 #include "base/logging.h" 10 #include "base/logging.h"
10 #include "base/stl_util-inl.h" 11 #include "base/stl_util-inl.h"
11 #include "base/string_util.h" 12 #include "base/string_util.h"
12 #include "base/utf_string_conversions.h" 13 #include "base/utf_string_conversions.h"
13 #include "base/values.h" 14 #include "base/values.h"
14 #include "base/json/json_writer.h" 15 #include "base/json/json_writer.h"
15 #include "chrome/browser/extensions/extension_message_service.h" 16 #include "chrome/browser/extensions/extension_message_service.h"
16 #include "chrome/browser/extensions/extension_tabs_module.h" 17 #include "chrome/browser/extensions/extension_tabs_module.h"
17 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
18 #include "chrome/common/extensions/extension.h" 19 #include "chrome/common/extensions/extension.h"
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 ExtensionMenuItem* child = *i; 70 ExtensionMenuItem* child = *i;
70 result.insert(child->id()); 71 result.insert(child->id());
71 std::set<Id> removed = child->RemoveAllDescendants(); 72 std::set<Id> removed = child->RemoveAllDescendants();
72 result.insert(removed.begin(), removed.end()); 73 result.insert(removed.begin(), removed.end());
73 } 74 }
74 STLDeleteElements(&children_); 75 STLDeleteElements(&children_);
75 return result; 76 return result;
76 } 77 }
77 78
78 string16 ExtensionMenuItem::TitleWithReplacement( 79 string16 ExtensionMenuItem::TitleWithReplacement(
79 const string16& selection) const { 80 const string16& selection, size_t max_length) const {
80 string16 result = UTF8ToUTF16(title_); 81 string16 result = UTF8ToUTF16(title_);
81 // TODO(asargent) - Change this to properly handle %% escaping so you can 82 // TODO(asargent) - Change this to properly handle %% escaping so you can
82 // put "%s" in titles that won't get substituted. 83 // put "%s" in titles that won't get substituted.
83 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16("%s"), selection); 84 ReplaceSubstringsAfterOffset(&result, 0, ASCIIToUTF16("%s"), selection);
85
86 if (result.length() > max_length) {
87 result = WideToUTF16(l10n_util::TruncateString(UTF16ToWideHack(result),
88 max_length));
89 }
84 return result; 90 return result;
85 } 91 }
86 92
87 bool ExtensionMenuItem::SetChecked(bool checked) { 93 bool ExtensionMenuItem::SetChecked(bool checked) {
88 if (type_ != CHECKBOX && type_ != RADIO) 94 if (type_ != CHECKBOX && type_ != RADIO)
89 return false; 95 return false;
90 checked_ = checked; 96 checked_ = checked;
91 return true; 97 return true;
92 } 98 }
93 99
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
448 const SkBitmap& ExtensionMenuManager::GetIconForExtension( 454 const SkBitmap& ExtensionMenuManager::GetIconForExtension(
449 const std::string& extension_id) { 455 const std::string& extension_id) {
450 return icon_manager_.GetIcon(extension_id); 456 return icon_manager_.GetIcon(extension_id);
451 } 457 }
452 458
453 // static 459 // static
454 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) { 460 bool ExtensionMenuManager::HasAllowedScheme(const GURL& url) {
455 URLPattern pattern(kAllowedSchemes); 461 URLPattern pattern(kAllowedSchemes);
456 return pattern.SetScheme(url.scheme()); 462 return pattern.SetScheme(url.scheme());
457 } 463 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_menu_manager.h ('k') | chrome/browser/extensions/extension_test_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698