summaryrefslogtreecommitdiffstats
path: root/chrome/browser/tab_contents
diff options
context:
space:
mode:
authorasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 15:08:41 +0000
committerasvitkine@chromium.org <asvitkine@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-11-10 15:08:41 +0000
commit531e034c4256147c7edd37f5404eaaeb8fe3b0cd (patch)
tree71ea8a6f2b5d71bc00a104b176a2917a8335fe13 /chrome/browser/tab_contents
parent23efbcbf7bc712ea22ad731aaa852c1a4763a0ea (diff)
downloadchromium_src-531e034c4256147c7edd37f5404eaaeb8fe3b0cd.zip
chromium_src-531e034c4256147c7edd37f5404eaaeb8fe3b0cd.tar.gz
chromium_src-531e034c4256147c7edd37f5404eaaeb8fe3b0cd.tar.bz2
Fix AutocompleteMatch DCHECK() triggered by |RenderViewContextMenu::AppendSearchProvider()|.
Makes |AppendSearchProvider()| sanitize the text by replacing unwanted whitespace characters with spaces. Do this instead of calling |AutocompleteMatch::SanitizeString()|, since we want to preserve the whitespace between words separated by newlines here, rather than appending such words together. Added |ReplaceChars()| to base/string_util to support replacing any occurence of the given characters with a replacement string. BUG=103338 TEST=Right click on multiline text in a text area in a Debug build. A DCHECK() shouldn't trigger. Review URL: http://codereview.chromium.org/8502027 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@109430 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents')
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 491a4a4..180fece 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -4,6 +4,7 @@
#include <algorithm>
#include <set>
+#include <utility>
#include "chrome/browser/tab_contents/render_view_context_menu.h"
@@ -398,7 +399,7 @@ void RenderViewContextMenu::RecursivelyAppendExtensionItems(
const ExtensionMenuItem::List& items,
bool can_cross_incognito,
ui::SimpleMenuModel* menu_model,
- int *index) {
+ int* index) {
string16 selection_text = PrintableSelectionText();
ExtensionMenuItem::Type last_type = ExtensionMenuItem::NORMAL;
int radio_group_id = 1;
@@ -799,6 +800,9 @@ void RenderViewContextMenu::AppendSearchProvider() {
if (params_.selection_text.empty())
return;
+ ReplaceChars(params_.selection_text, AutocompleteMatch::kInvalidChars,
+ ASCIIToUTF16(" "), &params_.selection_text);
+
AutocompleteMatch match;
profile_->GetAutocompleteClassifier()->Classify(
params_.selection_text, string16(), false, false, &match, NULL);