OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 size_t num_languages() const { return languages_.size(); } | 72 size_t num_languages() const { return languages_.size(); } |
73 | 73 |
74 // Returns the ISO code for the language at |index|. | 74 // Returns the ISO code for the language at |index|. |
75 std::string language_code_at(size_t index) const { | 75 std::string language_code_at(size_t index) const { |
76 DCHECK_LT(index, num_languages()); | 76 DCHECK_LT(index, num_languages()); |
77 return languages_[index].first; | 77 return languages_[index].first; |
78 } | 78 } |
79 | 79 |
80 // Returns the displayable name for the language at |index|. | 80 // Returns the displayable name for the language at |index|. |
81 string16 language_name_at(size_t index) const { | 81 string16 language_name_at(size_t index) const { |
| 82 if (index == kNoIndex) |
| 83 return string16(); |
82 DCHECK_LT(index, num_languages()); | 84 DCHECK_LT(index, num_languages()); |
83 return languages_[index].second; | 85 return languages_[index].second; |
84 } | 86 } |
85 | 87 |
86 Type infobar_type() const { return infobar_type_; } | 88 Type infobar_type() const { return infobar_type_; } |
87 | 89 |
88 TranslateErrors::Type error_type() const { return error_type_; } | 90 TranslateErrors::Type error_type() const { return error_type_; } |
89 | 91 |
90 size_t original_language_index() const { return original_language_index_; } | 92 size_t original_language_index() const { return original_language_index_; } |
91 void set_original_language_index(size_t language_index) { | 93 void set_original_language_index(size_t language_index) { |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
168 // Adds the strings that should be displayed in the after translate infobar to | 170 // Adds the strings that should be displayed in the after translate infobar to |
169 // |strings|. The text in that infobar is: | 171 // |strings|. The text in that infobar is: |
170 // "The page has been translated from <lang1> to <lang2>." | 172 // "The page has been translated from <lang1> to <lang2>." |
171 // Because <lang1> and <lang2> are displayed in menu buttons, the text is | 173 // Because <lang1> and <lang2> are displayed in menu buttons, the text is |
172 // split in 3 chunks. |swap_languages| is set to true if <lang1> and <lang2> | 174 // split in 3 chunks. |swap_languages| is set to true if <lang1> and <lang2> |
173 // should be inverted (some languages express the sentense as "The page has | 175 // should be inverted (some languages express the sentense as "The page has |
174 // been translate to <lang2> from <lang1>."). | 176 // been translate to <lang2> from <lang1>."). |
175 static void GetAfterTranslateStrings(std::vector<string16>* strings, | 177 static void GetAfterTranslateStrings(std::vector<string16>* strings, |
176 bool* swap_languages); | 178 bool* swap_languages); |
177 | 179 |
| 180 // Adds the strings that should be displayed in the after translate infobar to |
| 181 // |strings|. When a source language is not determined by Chrome, Languages |
| 182 // are detected by a server automatically. And infobar doesn't show source |
| 183 // languages. The text in the infobar is: |
| 184 // "The page has been translated to <lang1>." |
| 185 // Because <lang1> is displayed in a menu button, the text is split in 2 |
| 186 // chunks. |
| 187 static void GetAfterTranslateWithAutoStrings(std::vector<string16>* strings); |
| 188 |
178 protected: | 189 protected: |
179 // For testing. | 190 // For testing. |
180 TranslateInfoBarDelegate(Type infobar_type, | 191 TranslateInfoBarDelegate(Type infobar_type, |
181 TranslateErrors::Type error_type, | 192 TranslateErrors::Type error_type, |
182 InfoBarService* infobar_service, | 193 InfoBarService* infobar_service, |
183 PrefService* prefs, | 194 PrefService* prefs, |
184 ShortcutConfiguration shortcut_config, | 195 ShortcutConfiguration shortcut_config, |
185 const std::string& original_language, | 196 const std::string& original_language, |
186 const std::string& target_language); | 197 const std::string& target_language); |
187 Type infobar_type_; | 198 Type infobar_type_; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 | 241 |
231 // The translation related preferences. | 242 // The translation related preferences. |
232 TranslatePrefs prefs_; | 243 TranslatePrefs prefs_; |
233 | 244 |
234 // Translation shortcut configuration | 245 // Translation shortcut configuration |
235 ShortcutConfiguration shortcut_config_; | 246 ShortcutConfiguration shortcut_config_; |
236 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); | 247 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); |
237 }; | 248 }; |
238 | 249 |
239 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 250 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
OLD | NEW |