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

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: Review comments 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
« no previous file with comments | « components/translate/DEPS ('k') | components/translate/core/browser/translate_prefs.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 73%
rename from chrome/browser/translate/translate_prefs.h
rename to components/translate/core/browser/translate_prefs.h
index 6b2f680f86510817f10a6237c4e938f76c17bf7c..ffa9ecdaaebe7ee949a233ba29cc7266071591bb 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>
@@ -13,6 +13,7 @@
class PrefService;
class Profile;
+class TranslateAcceptLanguages;
namespace base {
class DictionaryValue;
@@ -35,7 +36,11 @@ class TranslatePrefs {
static const char kPrefTranslateAcceptedCount[];
static const char kPrefTranslateBlockedLanguages[];
- explicit TranslatePrefs(PrefService* user_prefs);
+ TranslatePrefs(PrefService* user_prefs,
+#if defined(OS_CHROMEOS)
MAD 2014/02/13 03:11:11 I don't really like this idea of a different signa
droger 2014/02/13 09:38:39 Done.
+ 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 +50,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 +61,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 +87,25 @@ class TranslatePrefs {
void IncrementTranslationAcceptedCount(const std::string& language);
void ResetTranslationAcceptedCount(const std::string& language);
- // Sets the language list of chrome://settings/languages.
+ // Gets the language list of the language settings.
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(TranslateAcceptLanguages* accept_languages,
+ 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 +125,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 +151,4 @@ class TranslatePrefs {
DISALLOW_COPY_AND_ASSIGN(TranslatePrefs);
};
-#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_
+#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_PREFS_H_
« no previous file with comments | « components/translate/DEPS ('k') | components/translate/core/browser/translate_prefs.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698