OLD | NEW |
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 Loading... |
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 // If there's more than one replacement, we can't automatically apply it | 318 result_.replace(it->location, it->length, it->replacement); |
319 if (it->replacements.size() == 1) | |
320 result_.replace(it->location, it->length, it->replacements[0]); | |
321 } | 319 } |
322 base::string16 result = base::i18n::ToLower(result_); | 320 base::string16 result = base::i18n::ToLower(result_); |
323 for (std::vector<base::string16>::const_iterator it = suggestions_.begin(); | 321 for (std::vector<base::string16>::const_iterator it = suggestions_.begin(); |
324 it != suggestions_.end(); ++it) { | 322 it != suggestions_.end(); ++it) { |
325 if (result == base::i18n::ToLower(*it)) { | 323 if (result == base::i18n::ToLower(*it)) { |
326 succeeded_ = false; | 324 succeeded_ = false; |
327 break; | 325 break; |
328 } | 326 } |
329 } | 327 } |
330 } | 328 } |
(...skipping 14 matching lines...) Expand all Loading... |
345 // Append '.' characters to the end of "Checking". | 343 // Append '.' characters to the end of "Checking". |
346 loading_frame_ = (loading_frame_ + 1) & 3; | 344 loading_frame_ = (loading_frame_ + 1) & 3; |
347 base::string16 loading_message = | 345 base::string16 loading_message = |
348 loading_message_ + base::string16(loading_frame_,'.'); | 346 loading_message_ + base::string16(loading_frame_,'.'); |
349 | 347 |
350 // Update the menu item with the text. We disable this item to prevent users | 348 // Update the menu item with the text. We disable this item to prevent users |
351 // from selecting it. | 349 // from selecting it. |
352 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, | 350 proxy_->UpdateMenuItem(IDC_CONTENT_CONTEXT_SPELLING_SUGGESTION, false, false, |
353 loading_message); | 351 loading_message); |
354 } | 352 } |
OLD | NEW |