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

Unified Diff: chrome/renderer/resources/extensions/schema_generated_bindings.js

Issue 8824018: Fixed regression with extension omnibox API where whitespace would get trimmed (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: comment Created 9 years 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/renderer/resources/extensions/schema_generated_bindings.js
diff --git a/chrome/renderer/resources/extensions/schema_generated_bindings.js b/chrome/renderer/resources/extensions/schema_generated_bindings.js
index 012e99f708c8ca014dea14bddce4ab39906fa015..c50d33bc6ca2fdd87e14347e09ac9e6feec31741 100644
--- a/chrome/renderer/resources/extensions/schema_generated_bindings.js
+++ b/chrome/renderer/resources/extensions/schema_generated_bindings.js
@@ -472,11 +472,13 @@ var chrome = chrome || {};
// Remove invalid characters from |text| so that it is suitable to use
// for |AutocompleteMatch::contents|.
- function sanitizeString(text) {
+ function sanitizeString(text, shouldTrim) {
// NOTE: This logic mirrors |AutocompleteMatch::SanitizeString()|.
// 0x2028 = line separator; 0x2029 = paragraph separator.
var kRemoveChars = /(\r|\n|\t|\u2028|\u2029)/gm;
- return text.trimLeft().replace(kRemoveChars, '');
+ if (shouldTrim)
+ text = text.trimLeft();
+ return text.replace(kRemoveChars, '');
}
// Parses the xml syntax supported by omnibox suggestion results. Returns an
@@ -510,7 +512,8 @@ var chrome = chrome || {};
for (var i = 0, child; child = node.childNodes[i]; i++) {
// Append text nodes to our description.
if (child.nodeType == Node.TEXT_NODE) {
- result.description += sanitizeString(child.nodeValue);
+ var shouldTrim = result.description.length == 0;
+ result.description += sanitizeString(child.nodeValue, shouldTrim);
continue;
}
« 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