Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / translate / translate_accept_languages.h
blobbce859e7d041b327e3d6272d7c6d41c4c3344791
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_
8 #include <map>
9 #include <set>
10 #include <string>
12 #include "base/basictypes.h"
13 #include "content/public/browser/notification_observer.h"
14 #include "content/public/browser/notification_registrar.h"
16 class PrefChangeRegistrar;
17 class PrefService;
18 class Profile;
20 class TranslateAcceptLanguages : public content::NotificationObserver {
21 public:
22 TranslateAcceptLanguages();
23 virtual ~TranslateAcceptLanguages();
25 // Returns true if |language| is available as Accept-Languages. |language|
26 // will be cnverted if it has the synonym of accept language.
27 static bool CanBeAcceptLanguage(const std::string& language);
29 // Returns true if the passed language has been configured by the user as an
30 // accept language. |language| will be converted if it has the synonym of
31 // accept languages.
32 bool IsAcceptLanguage(Profile* profile,
33 const std::string& language);
35 private:
36 // content::NotificationObserver implementation:
37 virtual void Observe(int type,
38 const content::NotificationSource& source,
39 const content::NotificationDetails& details) OVERRIDE;
41 // Initializes the |accept_languages_| language table based on the associated
42 // preference in |prefs|.
43 void InitAcceptLanguages(PrefService* prefs);
45 // A map that associates a profile with its parsed "accept languages".
46 typedef std::set<std::string> LanguageSet;
47 typedef std::map<PrefService*, LanguageSet> PrefServiceLanguagesMap;
48 PrefServiceLanguagesMap accept_languages_;
50 // Each PrefChangeRegistrar only tracks a single PrefService, so a map from
51 // each PrefService used to its registrar is needed.
52 typedef std::map<PrefService*, PrefChangeRegistrar*> PrefServiceRegistrarMap;
53 PrefServiceRegistrarMap pref_change_registrars_;
55 content::NotificationRegistrar notification_registrar_;
57 DISALLOW_COPY_AND_ASSIGN(TranslateAcceptLanguages);
60 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_ACCEPT_LANGUAGES_H_