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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck.cc

Issue 10388178: Disable retrieving suggestions in the background. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 7 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
« no previous file with comments | « no previous file | no next file » | 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/renderer/spellchecker/spellcheck.h" 5 #include "chrome/renderer/spellchecker/spellcheck.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/metrics/histogram.h" 9 #include "base/metrics/histogram.h"
10 #include "base/message_loop_proxy.h" 10 #include "base/message_loop_proxy.h"
(...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 size_t offset = 0; 229 size_t offset = 0;
230 230
231 // Spellcheck::SpellCheckWord() automatically breaks text into words and 231 // Spellcheck::SpellCheckWord() automatically breaks text into words and
232 // checks the spellings of the extracted words. This function sets the 232 // checks the spellings of the extracted words. This function sets the
233 // position and length of the first misspelled word and returns false when 233 // position and length of the first misspelled word and returns false when
234 // the text includes misspelled words. Therefore, we just repeat calling the 234 // the text includes misspelled words. Therefore, we just repeat calling the
235 // function until it returns true to check the whole text. 235 // function until it returns true to check the whole text.
236 int misspelling_start = 0; 236 int misspelling_start = 0;
237 int misspelling_length = 0; 237 int misspelling_length = 0;
238 while (offset <= length) { 238 while (offset <= length) {
239 std::vector<string16> suggestions;
240 if (SpellCheckWord(&text[offset], 239 if (SpellCheckWord(&text[offset],
241 length - offset, 240 length - offset,
242 0, 241 0,
243 &misspelling_start, 242 &misspelling_start,
244 &misspelling_length, 243 &misspelling_length,
245 &suggestions)) { 244 NULL)) {
246 return true; 245 return true;
247 } 246 }
248 247
249 string16 replacement; 248 string16 replacement;
250 if (!suggestions.empty())
251 replacement = JoinString(suggestions, '\n');
252 results->push_back(SpellCheckResult( 249 results->push_back(SpellCheckResult(
253 SpellCheckResult::SPELLING, 250 SpellCheckResult::SPELLING,
254 misspelling_start + offset, 251 misspelling_start + offset,
255 misspelling_length, 252 misspelling_length,
256 replacement)); 253 replacement));
257 offset += misspelling_start + misspelling_length; 254 offset += misspelling_start + misspelling_length;
258 } 255 }
259 256
260 return false; 257 return false;
261 #else 258 #else
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
503 500
504 string16 word; 501 string16 word;
505 int word_start; 502 int word_start;
506 int word_length; 503 int word_length;
507 while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) { 504 while (contraction_iterator_.GetNextWord(&word, &word_start, &word_length)) {
508 if (!CheckSpelling(word, tag)) 505 if (!CheckSpelling(word, tag))
509 return false; 506 return false;
510 } 507 }
511 return true; 508 return true;
512 } 509 }
OLDNEW
« 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