summaryrefslogtreecommitdiffstats
path: root/chrome/browser/translate/translate_prefs.h
blob: 5cd334d46c4a204f9264b2d751ee6c87a0b9769f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright (c) 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_

#include <string>
#include <vector>

#include "googleurl/src/gurl.h"

class ListValue;
class PrefService;

class TranslatePrefs {
 public:
  static const wchar_t kPrefTranslateLanguageBlacklist[];
  static const wchar_t kPrefTranslateSiteBlacklist[];
  static const wchar_t kPrefTranslateWhitelists[];

  explicit TranslatePrefs(PrefService* user_prefs);

  bool IsLanguageBlacklisted(const std::string& original_language);
  void BlacklistLanguage(const std::string& original_language);
  void RemoveLanguageFromBlacklist(const std::string& original_language);

  bool IsSiteBlacklisted(const std::string& site);
  void BlacklistSite(const std::string& site);
  void RemoveSiteFromBlacklist(const std::string& site);

  bool IsLanguagePairWhitelisted(const std::string& original_language,
      const std::string& target_language);
  void WhitelistLanguagePair(const std::string& original_language,
      const std::string& target_language);
  void RemoveLanguagePairFromWhitelist(const std::string& original_language,
      const std::string& target_language);

  static bool CanTranslate(PrefService* user_prefs,
      const std::string& original_language, const GURL& url);
  static bool ShouldAutoTranslate(PrefService* user_prefs,
      const std::string& original_language,
      const std::string& target_language);
  static void RegisterUserPrefs(PrefService* user_prefs);

 private:
  bool IsValueBlacklisted(const wchar_t* pref_id, const std::string& value);
  void BlacklistValue(const wchar_t* pref_id, const std::string& value);
  void RemoveValueFromBlacklist(const wchar_t* pref_id,
      const std::string& value);
  bool IsValueInList(const ListValue* list, const std::string& value);

  PrefService* prefs_;  // Weak.
};

#endif  // CHROME_BROWSER_TRANSLATE_TRANSLATE_PREFS_H_