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

Side by Side Diff: components/translate/core/browser/translate_prefs.cc

Issue 2919313003: Reset counters for all language when reset translate settings (Closed)
Patch Set: Created 3 years, 6 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/translate/core/browser/translate_prefs.h" 5 #include "components/translate/core/browser/translate_prefs.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/memory/ptr_util.h" 10 #include "base/memory/ptr_util.h"
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
173 173
174 std::string TranslatePrefs::GetCountry() const { 174 std::string TranslatePrefs::GetCountry() const {
175 return country_; 175 return country_;
176 } 176 }
177 177
178 void TranslatePrefs::ResetToDefaults() { 178 void TranslatePrefs::ResetToDefaults() {
179 ClearBlockedLanguages(); 179 ClearBlockedLanguages();
180 ClearBlacklistedSites(); 180 ClearBlacklistedSites();
181 ClearWhitelistedLanguagePairs(); 181 ClearWhitelistedLanguagePairs();
182 182
183 std::vector<std::string> languages; 183 prefs_->ClearPref(kPrefTranslateDeniedCount);
Leo 2017/06/07 00:21:23 I think it's better to figure out the root cause w
Marti Wong 2017/06/07 01:06:42 In the repro case of crbug.com/728930, Japanese is
groby-ooo-7-16 2017/06/07 16:43:49 Hm. It might be worth digging through history for
Marti Wong 2017/06/08 03:30:50 In case there is any reason we need to use For-loo
184 GetLanguageList(&languages); 184 prefs_->ClearPref(kPrefTranslateIgnoredCount);
185 for (std::vector<std::string>::const_iterator it = languages.begin(); 185 prefs_->ClearPref(kPrefTranslateAcceptedCount);
186 it != languages.end(); ++it) {
187 const std::string& language = *it;
188 ResetTranslationAcceptedCount(language);
189 ResetTranslationDeniedCount(language);
190 ResetTranslationIgnoredCount(language);
191 }
192
193 prefs_->ClearPref(kPrefTranslateLastDeniedTimeForLanguage); 186 prefs_->ClearPref(kPrefTranslateLastDeniedTimeForLanguage);
194 prefs_->ClearPref(kPrefTranslateTooOftenDeniedForLanguage); 187 prefs_->ClearPref(kPrefTranslateTooOftenDeniedForLanguage);
195 } 188 }
196 189
197 bool TranslatePrefs::IsBlockedLanguage( 190 bool TranslatePrefs::IsBlockedLanguage(
198 const std::string& original_language) const { 191 const std::string& original_language) const {
199 return IsValueBlacklisted(kPrefTranslateBlockedLanguages, original_language); 192 return IsValueBlacklisted(kPrefTranslateBlockedLanguages, original_language);
200 } 193 }
201 194
202 void TranslatePrefs::BlockLanguage(const std::string& original_language) { 195 void TranslatePrefs::BlockLanguage(const std::string& original_language) {
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
638 out_value->push_back(it); 631 out_value->push_back(it);
639 std::sort(out_value->begin(), out_value->end(), 632 std::sort(out_value->begin(), out_value->end(),
640 [](const LanguageAndProbability& left, 633 [](const LanguageAndProbability& left,
641 const LanguageAndProbability& right) { 634 const LanguageAndProbability& right) {
642 return left.second > right.second; 635 return left.second > right.second;
643 }); 636 });
644 return confidence; 637 return confidence;
645 } 638 }
646 639
647 } // namespace translate 640 } // namespace translate
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698