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

Unified Diff: chrome/browser/tab_contents/render_view_context_menu.cc

Issue 12294022: Simplify Ampersand escaping logic in RenderViewContextMenu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/tab_contents/render_view_context_menu.cc
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index fdc406fe5b69d11cb045c003061153e9474c9b6e..66e20a9d82e92ce55863f784b9d4005129996bf8 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -389,10 +389,8 @@ void RenderViewContextMenu::AppendAllExtensionItems() {
i != sorted_ids.end(); ++i) {
string16 printable_selection_text = PrintableSelectionText();
// Escape "&" as "&&".
- for (size_t position = printable_selection_text.find('&');
- position != string16::npos;
- position = printable_selection_text.find('&', position + 2))
- printable_selection_text.insert(position, 1, '&');
+ ReplaceChars(printable_selection_text, ASCIIToUTF16("&").c_str(),
Yoyo Zhou 2013/02/19 18:34:01 Try L"&" and L"&&" here.
Joe Thomas 2013/02/19 19:17:50 This works only on platforms like windows where wc
Joe Thomas 2013/02/19 21:32:11 Looks like my above explanation is not fully clear
Yoyo Zhou 2013/02/19 21:57:02 Bummer. I guess C++11 initializer lists would be r
Joe Thomas 2013/02/19 22:39:05 That can be done. Patch updated.
+ ASCIIToUTF16("&&"), &printable_selection_text);
extension_items_.AppendExtensionItems(i->second, printable_selection_text,
&index);
@@ -830,9 +828,9 @@ void RenderViewContextMenu::AppendSearchProvider() {
string16 printable_selection_text = PrintableSelectionText();
// Escape "&" as "&&".
- for (size_t i = printable_selection_text.find('&'); i != string16::npos;
- i = printable_selection_text.find('&', i + 2))
- printable_selection_text.insert(i, 1, '&');
+ ReplaceChars(printable_selection_text, ASCIIToUTF16("&").c_str(),
+ ASCIIToUTF16("&&"), &printable_selection_text);
+
if (AutocompleteMatch::IsSearchType(match.type)) {
const TemplateURL* const default_provider =
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698