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

Side by Side Diff: chrome/browser/autocomplete/autocomplete_match.cc

Issue 8540012: Enable extension APIs for content scripts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 9 years, 1 month 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
« no previous file with comments | « no previous file | chrome/browser/extensions/content_script_apitest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/string_util.h" 6 #include "base/string_util.h"
7 #include "chrome/browser/autocomplete/autocomplete_match.h" 7 #include "chrome/browser/autocomplete/autocomplete_match.h"
8 #include "grit/theme_resources.h" 8 #include "grit/theme_resources.h"
9 9
10 // AutocompleteMatch ---------------------------------------------------------- 10 // AutocompleteMatch ----------------------------------------------------------
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after
161 // Mark post-match portion of string (if any). 161 // Mark post-match portion of string (if any).
162 const size_t after_match(match_location + match_length); 162 const size_t after_match(match_location + match_length);
163 if (after_match < overall_length) { 163 if (after_match < overall_length) {
164 classification->push_back(ACMatchClassification(after_match, style)); 164 classification->push_back(ACMatchClassification(after_match, style));
165 } 165 }
166 } 166 }
167 167
168 // static 168 // static
169 string16 AutocompleteMatch::SanitizeString(const string16& text) { 169 string16 AutocompleteMatch::SanitizeString(const string16& text) {
170 // NOTE: This logic is mirrored by |sanitizeString()| in 170 // NOTE: This logic is mirrored by |sanitizeString()| in
171 // extension_process_bindings.js. 171 // schema_generated_bindings.js.
172 string16 result; 172 string16 result;
173 TrimWhitespace(text, TRIM_LEADING, &result); 173 TrimWhitespace(text, TRIM_LEADING, &result);
174 RemoveChars(result, kInvalidChars, &result); 174 RemoveChars(result, kInvalidChars, &result);
175 return result; 175 return result;
176 } 176 }
177 177
178 #ifndef NDEBUG 178 #ifndef NDEBUG
179 void AutocompleteMatch::Validate() const { 179 void AutocompleteMatch::Validate() const {
180 ValidateClassifications(contents, contents_class); 180 ValidateClassifications(contents, contents_class);
181 ValidateClassifications(description, description_class); 181 ValidateClassifications(description, description_class);
(...skipping 16 matching lines...) Expand all
198 // The classifications should always be sorted. 198 // The classifications should always be sorted.
199 size_t last_offset = classifications[0].offset; 199 size_t last_offset = classifications[0].offset;
200 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1); 200 for (ACMatchClassifications::const_iterator i(classifications.begin() + 1);
201 i != classifications.end(); ++i) { 201 i != classifications.end(); ++i) {
202 DCHECK(i->offset > last_offset) << "Classification unsorted"; 202 DCHECK(i->offset > last_offset) << "Classification unsorted";
203 DCHECK(i->offset < text.length()) << "Classification out of bounds"; 203 DCHECK(i->offset < text.length()) << "Classification out of bounds";
204 last_offset = i->offset; 204 last_offset = i->offset;
205 } 205 }
206 } 206 }
207 #endif 207 #endif
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/content_script_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698