| OLD | NEW |
| 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 "components/spellcheck/renderer/spellcheck.h" | 5 #include "components/spellcheck/renderer/spellcheck.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 188 | 188 |
| 189 for (size_t count = 0; count < (max_suggestions * num_languages); ++count) { | 189 for (size_t count = 0; count < (max_suggestions * num_languages); ++count) { |
| 190 size_t language = count % num_languages; | 190 size_t language = count % num_languages; |
| 191 size_t index = count / num_languages; | 191 size_t index = count / num_languages; |
| 192 | 192 |
| 193 if (suggestions_list[language].size() <= index) | 193 if (suggestions_list[language].size() <= index) |
| 194 continue; | 194 continue; |
| 195 | 195 |
| 196 const base::string16& suggestion = suggestions_list[language][index]; | 196 const base::string16& suggestion = suggestions_list[language][index]; |
| 197 // Only add the suggestion if it's unique. | 197 // Only add the suggestion if it's unique. |
| 198 if (!ContainsValue(*optional_suggestions, suggestion)) { | 198 if (!base::ContainsValue(*optional_suggestions, suggestion)) { |
| 199 optional_suggestions->push_back(suggestion); | 199 optional_suggestions->push_back(suggestion); |
| 200 } | 200 } |
| 201 if (optional_suggestions->size() >= spellcheck::kMaxSuggestions) { | 201 if (optional_suggestions->size() >= spellcheck::kMaxSuggestions) { |
| 202 break; | 202 break; |
| 203 } | 203 } |
| 204 } | 204 } |
| 205 } | 205 } |
| 206 | 206 |
| 207 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { | 207 bool SpellCheck::OnControlMessageReceived(const IPC::Message& message) { |
| 208 bool handled = true; | 208 bool handled = true; |
| 209 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) | 209 IPC_BEGIN_MESSAGE_MAP(SpellCheck, message) |
| (...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 | 538 |
| 539 bool SpellCheck::IsSpellcheckEnabled() { | 539 bool SpellCheck::IsSpellcheckEnabled() { |
| 540 #if defined(OS_ANDROID) | 540 #if defined(OS_ANDROID) |
| 541 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( | 541 if (!base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 542 spellcheck::switches::kEnableAndroidSpellChecker)) { | 542 spellcheck::switches::kEnableAndroidSpellChecker)) { |
| 543 return false; | 543 return false; |
| 544 } | 544 } |
| 545 #endif | 545 #endif |
| 546 return spellcheck_enabled_; | 546 return spellcheck_enabled_; |
| 547 } | 547 } |
| OLD | NEW |