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

Side by Side Diff: chrome/browser/translate/translate_manager.h

Issue 601069: Fix the TranslateManager and unit-tests.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/translate/translate_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/translate_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698