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

Side by Side Diff: chrome/browser/renderer_context_menu/spelling_menu_observer.cc

Issue 2848943002: Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Rebase Created 3 years, 6 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/browser/renderer_context_menu/spelling_menu_observer.h" 5 #include "chrome/browser/renderer_context_menu/spelling_menu_observer.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 297 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 // suggested words. If the replaced text is included in the suggestion list 308 // suggested words. If the replaced text is included in the suggestion list
309 // provided by the local spellchecker, we show a "No suggestions from Google" 309 // provided by the local spellchecker, we show a "No suggestions from Google"
310 // message. 310 // message.
311 succeeded_ = success; 311 succeeded_ = success;
312 if (results.empty()) { 312 if (results.empty()) {
313 succeeded_ = false; 313 succeeded_ = false;
314 } else { 314 } else {
315 typedef std::vector<SpellCheckResult> SpellCheckResults; 315 typedef std::vector<SpellCheckResult> SpellCheckResults;
316 for (SpellCheckResults::const_iterator it = results.begin(); 316 for (SpellCheckResults::const_iterator it = results.begin();
317 it != results.end(); ++it) { 317 it != results.end(); ++it) {
318 result_.replace(it->location, it->length, it->replacement); 318 // If there's more than one replacement, we can't automatically apply it
319 if (it->replacements.size() == 1)
320 result_.replace(it->location, it->length, it->replacements[0]);
319 } 321 }
320 base::string16 result = base::i18n::ToLower(result_); 322 base::string16 result = base::i18n::ToLower(result_);
321 for (std::vector<base::string16>::const_iterator it = suggestions_.begin(); 323 for (std::vector<base::string16>::const_iterator it = suggestions_.begin();
322 it != suggestions_.end(); ++it) { 324 it != suggestions_.end(); ++it) {
323 if (result == base::i18n::ToLower(*it)) { 325 if (result == base::i18n::ToLower(*it)) {
324 succeeded_ = false; 326 succeeded_ = false;
325 break; 327 break;
326 } 328 }
327 } 329 }
328 } 330 }
(...skipping 14 matching lines...) Expand all
343 // Append '.' characters to the end of "Checking". 345 // Append '.' characters to the end of "Checking".
344 loading_frame_ = (loading_frame_ + 1) & 3; 346 loading_frame_ = (loading_frame_ + 1) & 3;
345 base::string16 loading_message = 347 base::string16 loading_message =
346 loading_message_ + base::string16(loading_frame_,'.'); 348 loading_message_ + base::string16(loading_frame_,'.');
347 349
348 // Update the menu item with the text. We disable this item to prevent users 350 // Update the menu item with the text. We disable this item to prevent users
349 // from selecting it. 351 // from selecting it.
350 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, 352 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false,
351 loading_message); 353 loading_message);
352 } 354 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698