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/strings/string_split.h" | 10 #include "base/strings/string_split.h" |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 | 120 |
121 #if !defined(OS_MACOSX) | 121 #if !defined(OS_MACOSX) |
122 // static | 122 // static |
123 void SpellcheckService::GetDictionaries(base::SupportsUserData* browser_context, | 123 void SpellcheckService::GetDictionaries(base::SupportsUserData* browser_context, |
124 std::vector<Dictionary>* dictionaries) { | 124 std::vector<Dictionary>* dictionaries) { |
125 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); | 125 PrefService* prefs = user_prefs::UserPrefs::Get(browser_context); |
126 std::set<std::string> spellcheck_dictionaries; | 126 std::set<std::string> spellcheck_dictionaries; |
127 for (const auto& value : | 127 for (const auto& value : |
128 *prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries)) { | 128 *prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries)) { |
129 std::string dictionary; | 129 std::string dictionary; |
130 if (value.GetAsString(&dictionary)) | 130 if (value->GetAsString(&dictionary)) |
131 spellcheck_dictionaries.insert(dictionary); | 131 spellcheck_dictionaries.insert(dictionary); |
132 } | 132 } |
133 | 133 |
134 dictionaries->clear(); | 134 dictionaries->clear(); |
135 std::vector<std::string> accept_languages = | 135 std::vector<std::string> accept_languages = |
136 base::SplitString(prefs->GetString(prefs::kAcceptLanguages), ",", | 136 base::SplitString(prefs->GetString(prefs::kAcceptLanguages), ",", |
137 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); | 137 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); |
138 for (const auto& accept_language : accept_languages) { | 138 for (const auto& accept_language : accept_languages) { |
139 Dictionary dictionary; | 139 Dictionary dictionary; |
140 dictionary.language = | 140 dictionary.language = |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
209 hunspell_dictionaries_.clear(); | 209 hunspell_dictionaries_.clear(); |
210 | 210 |
211 PrefService* prefs = user_prefs::UserPrefs::Get(context_); | 211 PrefService* prefs = user_prefs::UserPrefs::Get(context_); |
212 DCHECK(prefs); | 212 DCHECK(prefs); |
213 | 213 |
214 const base::ListValue* dictionary_values = | 214 const base::ListValue* dictionary_values = |
215 prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries); | 215 prefs->GetList(spellcheck::prefs::kSpellCheckDictionaries); |
216 | 216 |
217 for (const auto& dictionary_value : *dictionary_values) { | 217 for (const auto& dictionary_value : *dictionary_values) { |
218 std::string dictionary; | 218 std::string dictionary; |
219 dictionary_value.GetAsString(&dictionary); | 219 dictionary_value->GetAsString(&dictionary); |
220 hunspell_dictionaries_.push_back( | 220 hunspell_dictionaries_.push_back( |
221 base::MakeUnique<SpellcheckHunspellDictionary>( | 221 base::MakeUnique<SpellcheckHunspellDictionary>( |
222 dictionary, | 222 dictionary, |
223 content::BrowserContext::GetDefaultStoragePartition(context_) | 223 content::BrowserContext::GetDefaultStoragePartition(context_) |
224 ->GetURLRequestContext(), | 224 ->GetURLRequestContext(), |
225 this)); | 225 this)); |
226 hunspell_dictionaries_.back()->AddObserver(this); | 226 hunspell_dictionaries_.back()->AddObserver(this); |
227 hunspell_dictionaries_.back()->Load(); | 227 hunspell_dictionaries_.back()->Load(); |
228 } | 228 } |
229 } | 229 } |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 | 342 |
343 for (const auto& dictionary : dictionaries) { | 343 for (const auto& dictionary : dictionaries) { |
344 if (std::find(accept_languages.begin(), accept_languages.end(), | 344 if (std::find(accept_languages.begin(), accept_languages.end(), |
345 dictionary) != accept_languages.end()) { | 345 dictionary) != accept_languages.end()) { |
346 filtered_dictionaries.push_back(dictionary); | 346 filtered_dictionaries.push_back(dictionary); |
347 } | 347 } |
348 } | 348 } |
349 | 349 |
350 dictionaries_pref.SetValue(filtered_dictionaries); | 350 dictionaries_pref.SetValue(filtered_dictionaries); |
351 } | 351 } |
OLD | NEW |