OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 17 matching lines...) Expand all Loading... |
28 | 28 |
29 class TranslateManager { | 29 class TranslateManager { |
30 public: | 30 public: |
31 // |translate_client| is expected to outlive the TranslateManager. | 31 // |translate_client| is expected to outlive the TranslateManager. |
32 // |accept_language_pref_name| is the path for the preference for the | 32 // |accept_language_pref_name| is the path for the preference for the |
33 // accept-languages. | 33 // accept-languages. |
34 TranslateManager(TranslateClient* translate_client, | 34 TranslateManager(TranslateClient* translate_client, |
35 const std::string& accept_language_pref_name); | 35 const std::string& accept_language_pref_name); |
36 virtual ~TranslateManager(); | 36 virtual ~TranslateManager(); |
37 | 37 |
| 38 // Returns a weak pointer to this instance. |
| 39 base::WeakPtr<TranslateManager> GetWeakPtr(); |
| 40 |
| 41 // Cannot return NULL. |
| 42 TranslateClient* translate_client() { return translate_client_; } |
| 43 |
38 // Returns the language to translate to. The language returned is the | 44 // Returns the language to translate to. The language returned is the |
39 // first language found in the following list that is supported by the | 45 // first language found in the following list that is supported by the |
40 // translation service: | 46 // translation service: |
41 // the UI language | 47 // the UI language |
42 // the accept-language list | 48 // the accept-language list |
43 // If no language is found then an empty string is returned. | 49 // If no language is found then an empty string is returned. |
44 static std::string GetTargetLanguage( | 50 static std::string GetTargetLanguage( |
45 const std::vector<std::string>& accept_languages_list); | 51 const std::vector<std::string>& accept_languages_list); |
46 | 52 |
47 // Returns the language to automatically translate to. |original_language| is | 53 // Returns the language to automatically translate to. |original_language| is |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 | 107 |
102 TranslateClient* translate_client_; // Weak. | 108 TranslateClient* translate_client_; // Weak. |
103 TranslateDriver* translate_driver_; // Weak. | 109 TranslateDriver* translate_driver_; // Weak. |
104 | 110 |
105 base::WeakPtrFactory<TranslateManager> weak_method_factory_; | 111 base::WeakPtrFactory<TranslateManager> weak_method_factory_; |
106 | 112 |
107 DISALLOW_COPY_AND_ASSIGN(TranslateManager); | 113 DISALLOW_COPY_AND_ASSIGN(TranslateManager); |
108 }; | 114 }; |
109 | 115 |
110 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ | 116 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_MANAGER_H_ |
OLD | NEW |