| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| 7 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 #include <set> | 9 #include <set> |
| 10 #include <string> | 10 #include <string> |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 class TranslateManager : public NotificationObserver { | 24 class TranslateManager : public NotificationObserver { |
| 25 public: | 25 public: |
| 26 virtual ~TranslateManager(); | 26 virtual ~TranslateManager(); |
| 27 | 27 |
| 28 // NotificationObserver implementation: | 28 // NotificationObserver implementation: |
| 29 virtual void Observe(NotificationType type, | 29 virtual void Observe(NotificationType type, |
| 30 const NotificationSource& source, | 30 const NotificationSource& source, |
| 31 const NotificationDetails& details); | 31 const NotificationDetails& details); |
| 32 | 32 |
| 33 // Used by unit-test to enable the TranslateManager for testing purpose. |
| 34 static void set_test_enabled(bool enabled) { test_enabled_ = enabled; } |
| 35 |
| 33 protected: | 36 protected: |
| 34 // Overriden by unit-tests to enable the TranslateManager. | |
| 35 virtual bool TestEnabled() { return false; } | |
| 36 | |
| 37 TranslateManager(); | 37 TranslateManager(); |
| 38 | 38 |
| 39 private: | 39 private: |
| 40 friend struct DefaultSingletonTraits<TranslateManager>; | 40 friend struct DefaultSingletonTraits<TranslateManager>; |
| 41 | 41 |
| 42 // Starts the translation process on |tab| containing the page in the | 42 // Starts the translation process on |tab| containing the page in the |
| 43 // |page_lang| language. | 43 // |page_lang| language. |
| 44 void InitiateTranslation(TabContents* tab, const std::string& page_lang); | 44 void InitiateTranslation(TabContents* tab, const std::string& page_lang); |
| 45 | 45 |
| 46 // Returns true if the passed language has been configured by the user as an | 46 // Returns true if the passed language has been configured by the user as an |
| 47 // accept language. | 47 // accept language. |
| 48 bool IsAcceptLanguage(TabContents* tab, const std::string& language); | 48 bool IsAcceptLanguage(TabContents* tab, const std::string& language); |
| 49 | 49 |
| 50 // Initializes the |accept_languages_| language table based on the associated | 50 // Initializes the |accept_languages_| language table based on the associated |
| 51 // preference in |prefs|. | 51 // preference in |prefs|. |
| 52 void InitAcceptLanguages(PrefService* prefs); | 52 void InitAcceptLanguages(PrefService* prefs); |
| 53 | 53 |
| 54 NotificationRegistrar notification_registrar_; | 54 NotificationRegistrar notification_registrar_; |
| 55 | 55 |
| 56 // A map that associates a profile with its parsed "accept languages". | 56 // A map that associates a profile with its parsed "accept languages". |
| 57 typedef std::set<std::string> LanguageSet; | 57 typedef std::set<std::string> LanguageSet; |
| 58 typedef std::map<PrefService*, LanguageSet> PrefServiceLanguagesMap; | 58 typedef std::map<PrefService*, LanguageSet> PrefServiceLanguagesMap; |
| 59 PrefServiceLanguagesMap accept_languages_; | 59 PrefServiceLanguagesMap accept_languages_; |
| 60 | 60 |
| 61 static bool test_enabled_; |
| 62 |
| 61 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 63 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
| 62 }; | 64 }; |
| 63 | 65 |
| 64 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ | 66 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ |
| OLD | NEW |