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

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

Issue 1715683002: chrome: Use base's ContainsValue helper function instead of std::find (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Updated as per latest code Created 4 years, 10 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 <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/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"
17 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h" 18 #include "chrome/browser/spellchecker/spellcheck_hunspell_dictionary.h"
18 #include "chrome/browser/spellchecker/spellcheck_platform.h" 19 #include "chrome/browser/spellchecker/spellcheck_platform.h"
19 #include "chrome/browser/spellchecker/spelling_service_client.h" 20 #include "chrome/browser/spellchecker/spelling_service_client.h"
(...skipping 326 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 for (const auto& dictionary : dictionaries) {
sky 2016/03/02 17:19:34 Isn't this std::set_intersection?
chakshu 2016/03/07 08:10:46 Yes, probably it is. Made the changes using set_in
357 if (std::find(accept_languages.begin(), accept_languages.end(), 358 if (ContainsValue(accept_languages, dictionary)) {
sky 2016/03/02 17:19:34 nit: no {}
chakshu 2016/03/07 08:10:46 Done.
358 dictionary) != accept_languages.end()) {
359 filtered_dictionaries.push_back(dictionary); 359 filtered_dictionaries.push_back(dictionary);
360 } 360 }
361 } 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