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

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

Issue 1525203003: [Translate] Factor out access to Accept-Languages (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@translate-manager-unit
Patch Set: Created 5 years 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 | « components/translate/core/browser/translate_prefs.h ('k') | 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 8
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/prefs/scoped_user_pref_update.h" 10 #include "base/prefs/scoped_user_pref_update.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 #if defined(OS_CHROMEOS) 365 #if defined(OS_CHROMEOS)
366 const char* key = preferred_languages_pref_.c_str(); 366 const char* key = preferred_languages_pref_.c_str();
367 #else 367 #else
368 const char* key = accept_languages_pref_.c_str(); 368 const char* key = accept_languages_pref_.c_str();
369 #endif 369 #endif
370 370
371 *languages = base::SplitString(prefs_->GetString(key), ",", 371 *languages = base::SplitString(prefs_->GetString(key), ",",
372 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL); 372 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
373 } 373 }
374 374
375 void TranslatePrefs::GetAcceptLanguageList(
groby-ooo-7-16 2015/12/16 02:48:26 Since GetAcceptLanguageList is only used by Transl
376 std::vector<std::string>* languages) const {
377 DCHECK(languages);
378 DCHECK(languages->empty());
379
380 *languages = base::SplitString(prefs_->GetString(accept_languages_pref_), ",",
381 base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
382 }
383
375 void TranslatePrefs::UpdateLanguageList( 384 void TranslatePrefs::UpdateLanguageList(
376 const std::vector<std::string>& languages) { 385 const std::vector<std::string>& languages) {
377 #if defined(OS_CHROMEOS) 386 #if defined(OS_CHROMEOS)
378 std::string languages_str = base::JoinString(languages, ","); 387 std::string languages_str = base::JoinString(languages, ",");
379 prefs_->SetString(preferred_languages_pref_.c_str(), languages_str); 388 prefs_->SetString(preferred_languages_pref_.c_str(), languages_str);
380 #endif 389 #endif
381 390
382 // Save the same language list as accept languages preference as well, but we 391 // Save the same language list as accept languages preference as well, but we
383 // need to expand the language list, to make it more acceptable. For instance, 392 // need to expand the language list, to make it more acceptable. For instance,
384 // some web sites don't understand 'en-US' but 'en'. See crosbug.com/9884. 393 // some web sites don't understand 'en-US' but 'en'. See crosbug.com/9884.
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
624 const base::ListValue* blacklist = prefs_->GetList(pref_id); 633 const base::ListValue* blacklist = prefs_->GetList(pref_id);
625 return (blacklist == NULL || blacklist->empty()); 634 return (blacklist == NULL || blacklist->empty());
626 } 635 }
627 636
628 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const { 637 bool TranslatePrefs::IsDictionaryEmpty(const char* pref_id) const {
629 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id); 638 const base::DictionaryValue* dict = prefs_->GetDictionary(pref_id);
630 return (dict == NULL || dict->empty()); 639 return (dict == NULL || dict->empty());
631 } 640 }
632 641
633 } // namespace translate 642 } // namespace translate
OLDNEW
« no previous file with comments | « components/translate/core/browser/translate_prefs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698