| 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 "chrome/browser/spellchecker/spellcheck_service.h" | 5 #include "chrome/browser/spellchecker/spellcheck_service.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/stl_util.h" |
| 10 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
| 11 #include "base/supports_user_data.h" | 12 #include "base/supports_user_data.h" |
| 12 #include "base/synchronization/waitable_event.h" | 13 #include "base/synchronization/waitable_event.h" |
| 13 #include "build/build_config.h" | 14 #include "build/build_config.h" |
| 14 #include "chrome/browser/spellchecker/spellcheck_factory.h" | 15 #include "chrome/browser/spellchecker/spellcheck_factory.h" |
| 15 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" | 16 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" |
| 16 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| 17 #include "components/prefs/pref_member.h" | 18 #include "components/prefs/pref_member.h" |
| 18 #include "components/prefs/pref_service.h" | 19 #include "components/prefs/pref_service.h" |
| 19 #include "components/spellcheck/browser/pref_names.h" | 20 #include "components/spellcheck/browser/pref_names.h" |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 339 std::transform(accept_languages.begin(), accept_languages.end(), | 340 std::transform(accept_languages.begin(), accept_languages.end(), |
| 340 accept_languages.begin(), | 341 accept_languages.begin(), |
| 341 &spellcheck::GetCorrespondingSpellCheckLanguage); | 342 &spellcheck::GetCorrespondingSpellCheckLanguage); |
| 342 | 343 |
| 343 StringListPrefMember dictionaries_pref; | 344 StringListPrefMember dictionaries_pref; |
| 344 dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, prefs); | 345 dictionaries_pref.Init(spellcheck::prefs::kSpellCheckDictionaries, prefs); |
| 345 std::vector<std::string> dictionaries = dictionaries_pref.GetValue(); | 346 std::vector<std::string> dictionaries = dictionaries_pref.GetValue(); |
| 346 std::vector<std::string> filtered_dictionaries; | 347 std::vector<std::string> filtered_dictionaries; |
| 347 | 348 |
| 348 for (const auto& dictionary : dictionaries) { | 349 for (const auto& dictionary : dictionaries) { |
| 349 if (std::find(accept_languages.begin(), accept_languages.end(), | 350 if (base::ContainsValue(accept_languages, dictionary)) { |
| 350 dictionary) != accept_languages.end()) { | |
| 351 filtered_dictionaries.push_back(dictionary); | 351 filtered_dictionaries.push_back(dictionary); |
| 352 } | 352 } |
| 353 } | 353 } |
| 354 | 354 |
| 355 dictionaries_pref.SetValue(filtered_dictionaries); | 355 dictionaries_pref.SetValue(filtered_dictionaries); |
| 356 } | 356 } |
| OLD | NEW |