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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_service.cc

Issue 1830543003: Using STL to implement functionality in input_method_util.cc (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 9 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 (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 <algorithm>
7 #include <set> 8 #include <set>
8 9
9 #include "base/logging.h" 10 #include "base/logging.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/feedback_sender.h" 15 #include "chrome/browser/spellchecker/feedback_sender.h"
15 #include "chrome/browser/spellchecker/spellcheck_factory.h" 16 #include "chrome/browser/spellchecker/spellcheck_factory.h"
16 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h" 17 #include "chrome/browser/spellchecker/spellcheck_host_metrics.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 std::transform( 347 std::transform(
347 accept_languages.begin(), accept_languages.end(), 348 accept_languages.begin(), accept_languages.end(),
348 accept_languages.begin(), 349 accept_languages.begin(),
349 &chrome::spellcheck_common::GetCorrespondingSpellCheckLanguage); 350 &chrome::spellcheck_common::GetCorrespondingSpellCheckLanguage);
350 351
351 StringListPrefMember dictionaries_pref; 352 StringListPrefMember dictionaries_pref;
352 dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs); 353 dictionaries_pref.Init(prefs::kSpellCheckDictionaries, prefs);
353 std::vector<std::string> dictionaries = dictionaries_pref.GetValue(); 354 std::vector<std::string> dictionaries = dictionaries_pref.GetValue();
354 std::vector<std::string> filtered_dictionaries; 355 std::vector<std::string> filtered_dictionaries;
355 356
356 for (const auto& dictionary : dictionaries) { 357 std::sort(dictionaries.begin(), dictionaries.end());
groby-ooo-7-16 2016/04/04 22:30:40 Before modifying things, please check the history
chakshu 2016/04/11 06:54:37 Thank you for the review. Using unordered_set wil
357 if (std::find(accept_languages.begin(), accept_languages.end(), 358 std::sort(accept_languages.begin(), accept_languages.end());
358 dictionary) != accept_languages.end()) { 359 std::set_intersection(dictionaries.begin(), dictionaries.end(),
359 filtered_dictionaries.push_back(dictionary); 360 accept_languages.begin(), accept_languages.end(),
360 } 361 std::back_inserter(filtered_dictionaries));
361 }
362 362
363 dictionaries_pref.SetValue(filtered_dictionaries); 363 dictionaries_pref.SetValue(filtered_dictionaries);
364 } 364 }
365 365
366 void SpellcheckService::UpdateFeedbackSenderState() { 366 void SpellcheckService::UpdateFeedbackSenderState() {
367 std::string feedback_language; 367 std::string feedback_language;
368 if (!hunspell_dictionaries_.empty()) 368 if (!hunspell_dictionaries_.empty())
369 feedback_language = hunspell_dictionaries_.front()->GetLanguage(); 369 feedback_language = hunspell_dictionaries_.front()->GetLanguage();
370 std::string language_code; 370 std::string language_code;
371 std::string country_code; 371 std::string country_code;
372 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale( 372 chrome::spellcheck_common::GetISOLanguageCountryCodeFromLocale(
373 feedback_language, &language_code, &country_code); 373 feedback_language, &language_code, &country_code);
374 feedback_sender_->OnLanguageCountryChange(language_code, country_code); 374 feedback_sender_->OnLanguageCountryChange(language_code, country_code);
375 if (SpellingServiceClient::IsAvailable( 375 if (SpellingServiceClient::IsAvailable(
376 context_, SpellingServiceClient::SPELLCHECK)) { 376 context_, SpellingServiceClient::SPELLCHECK)) {
377 feedback_sender_->StartFeedbackCollection(); 377 feedback_sender_->StartFeedbackCollection();
378 } else { 378 } else {
379 feedback_sender_->StopFeedbackCollection(); 379 feedback_sender_->StopFeedbackCollection();
380 } 380 }
381 } 381 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698