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

Unified Diff: components/translate/core/browser/translate_prefs.h

Issue 159883002: Move TranslatePrefs to the Translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@acceptLanguages
Patch Set: Fix typo Created 6 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 side-by-side diff with in-line comments
Download patch
Index: components/translate/core/browser/translate_prefs.h
diff --git a/chrome/browser/translate/translate_prefs.h b/components/translate/core/browser/translate_prefs.h
similarity index 74%
rename from chrome/browser/translate/translate_prefs.h
rename to components/translate/core/browser/translate_prefs.h
index 6b2f680f86510817f10a6237c4e938f76c17bf7c..307f80a560793c26cd663bd8fdfd381ed58302b8 100644
--- a/chrome/browser/translate/translate_prefs.h
+++ b/components/translate/core/browser/translate_prefs.h
@@ -1,9 +1,9 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
-#ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_
-#define CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_
+#ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_
+#define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_
#include <string>
#include <vector>
@@ -35,7 +35,11 @@ class TranslatePrefs {
static const char kPrefTranslateAcceptedCount[];
static const char kPrefTranslateBlockedLanguages[];
- explicit TranslatePrefs(PrefService* user_prefs);
+ TranslatePrefs(PrefService* user_prefs,
+#if defined(OS_CHROMEOS)
+ const char* preferred_languages_pref,
+#endif
+ const char* accept_languages_pref);
// Resets the blocked languages list, the sites blacklist, the languages
// whitelist, and the accepted/denied counts.
@@ -45,9 +49,8 @@ class TranslatePrefs {
void BlockLanguage(const std::string& original_language);
void UnblockLanguage(const std::string& original_language);
- // Removes a language from the old blacklist. This method is for
- // chrome://translate-internals/. Don't use this if there is no special
- // reason.
+ // Removes a language from the old blacklist. Only used internally for
+ // diagnostics. Don't use this if there is no special reason.
void RemoveLanguageFromLegacyBlacklist(const std::string& original_language);
bool IsSiteBlacklisted(const std::string& site) const;
@@ -57,11 +60,11 @@ class TranslatePrefs {
bool HasWhitelistedLanguagePairs() const;
bool IsLanguagePairWhitelisted(const std::string& original_language,
- const std::string& target_language);
+ const std::string& target_language);
void WhitelistLanguagePair(const std::string& original_language,
- const std::string& target_language);
+ const std::string& target_language);
void RemoveLanguagePairFromWhitelist(const std::string& original_language,
- const std::string& target_language);
+ const std::string& target_language);
// Will return true if at least one language has been blacklisted.
bool HasBlockedLanguages() const;
@@ -83,24 +86,25 @@ class TranslatePrefs {
void IncrementTranslationAcceptedCount(const std::string& language);
void ResetTranslationAcceptedCount(const std::string& language);
- // Sets the language list of chrome://settings/languages.
+ // Sets the language list of the language settings.
blundell 2014/02/12 14:01:43 This comment reads oddly now: The method is called
void GetLanguageList(std::vector<std::string>* languages);
- // Updates the language list of chrome://settings/languages.
+ // Updates the language list of the language settings.
void UpdateLanguageList(const std::vector<std::string>& languages);
- static bool CanTranslateLanguage(
- Profile* profile, const std::string& language);
- static bool ShouldAutoTranslate(PrefService* user_prefs,
- const std::string& original_language, std::string* target_language);
+ bool CanTranslateLanguage(bool is_accept_language,
+ const std::string& language);
+ bool ShouldAutoTranslate(const std::string& original_language,
+ std::string* target_language);
static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
- static void MigrateUserPrefs(PrefService* user_prefs);
+ static void MigrateUserPrefs(PrefService* user_prefs,
+ const char* accept_languages_pref);
// Converts the language code for Translate. This removes the sub code (like
// -US) except for Chinese, and converts the synonyms.
// The same logic exists at language_options.js, and please keep consistency
// with the JavaScript file.
- static std::string ConvertLangCodeForTranslation(const std::string &lang);
+ static std::string ConvertLangCodeForTranslation(const std::string& lang);
private:
friend class TranslatePrefsTest;
@@ -120,13 +124,19 @@ class TranslatePrefs {
bool IsValueBlacklisted(const char* pref_id, const std::string& value) const;
void BlacklistValue(const char* pref_id, const std::string& value);
void RemoveValueFromBlacklist(const char* pref_id, const std::string& value);
- bool IsValueInList(
- const base::ListValue* list, const std::string& value) const;
- bool IsLanguageWhitelisted(const std::string& original_language,
- std::string* target_language) const;
+ bool IsValueInList(const base::ListValue* list,
+ const std::string& value) const;
bool IsListEmpty(const char* pref_id) const;
bool IsDictionaryEmpty(const char* pref_id) const;
+ // Path to the preference storing the accept languages.
+ const std::string accept_languages_pref_;
+#if defined(OS_CHROMEOS)
+ // Path to the preference storing the preferred languages.
+ // Only used on ChromeOS.
+ const std::string preferred_languages_pref_;
+#endif
+
// Retrieves the dictionary mapping the number of times translation has been
// denied for a language, creating it if necessary.
base::DictionaryValue* GetTranslationDeniedCountDictionary();
@@ -140,4 +150,4 @@ class TranslatePrefs {
DISALLOW_COPY_AND_ASSIGN(TranslatePrefs);
};
-#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_
+#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_

Powered by Google App Engine
This is Rietveld 408576698