Chromium Code Reviews| Index: chrome/browser/translate/translate_infobar_delegate.h |
| diff --git a/chrome/browser/translate/translate_infobar_delegate.h b/chrome/browser/translate/translate_infobar_delegate.h |
| index dde0aa541669710723b421780e8f803d4b02aedf..c8be04e6abc711123a4777da353c1a389659d321 100644 |
| --- a/chrome/browser/translate/translate_infobar_delegate.h |
| +++ b/chrome/browser/translate/translate_infobar_delegate.h |
| @@ -13,7 +13,6 @@ |
| #include "base/logging.h" |
| #include "chrome/browser/infobars/infobar_delegate.h" |
| #include "chrome/browser/translate/translate_prefs.h" |
| -#include "chrome/browser/translate/translate_ui_delegate.h" |
| #include "chrome/common/translate/translate_errors.h" |
| #include "components/translate/common/translate_constants.h" |
| @@ -70,38 +69,54 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { |
| const ShortcutConfiguration& shortcut_config); |
| // Returns the number of languages supported. |
| - size_t num_languages() const { return ui_delegate_.GetNumberOfLanguages(); } |
| + size_t num_languages() const { |
| + // Note: TranslateUIDelegate should be updated if this implementation is |
| + // updated. |
|
Peter Kasting
2013/11/08 23:47:47
Let's not put these comments into every function i
hajimehoshi
2013/11/11 04:01:02
Done.
|
| + return languages_.size(); |
| + } |
| // Returns the ISO code for the language at |index|. |
| std::string language_code_at(size_t index) const { |
| - return ui_delegate_.GetLanguageCodeAt(index); |
| + // Note: TranslateUIDelegate should be updated if this implementation is |
| + // updated. |
| + DCHECK_LT(index, num_languages()); |
| + return languages_[index].first; |
| } |
| // Returns the displayable name for the language at |index|. |
| string16 language_name_at(size_t index) const { |
| - return ui_delegate_.GetLanguageNameAt(index); |
| + // Note: TranslateUIDelegate should be updated if this implementation is |
| + // updated. |
| + if (index == static_cast<size_t>(kNoIndex)) |
| + return string16(); |
| + DCHECK_LT(index, num_languages()); |
| + return languages_[index].second; |
| } |
| Type infobar_type() const { return infobar_type_; } |
| TranslateErrors::Type error_type() const { return error_type_; } |
| - size_t original_language_index() const { |
| - return ui_delegate_.GetOriginalLanguageIndex(); |
| - } |
| + size_t original_language_index() const { return original_language_index_; } |
| + |
| void UpdateOriginalLanguageIndex(size_t language_index); |
| - size_t target_language_index() const { |
| - return ui_delegate_.GetTargetLanguageIndex(); |
| - } |
| + size_t target_language_index() const { return target_language_index_; } |
| + |
| void UpdateTargetLanguageIndex(size_t language_index); |
| // Convenience methods. |
| std::string original_language_code() const { |
| - return ui_delegate_.GetOriginalLanguageCode(); |
| + // Note: TranslateUIDelegate should be updated if this implementation is |
| + // updated. |
| + return (original_language_index() == static_cast<size_t>(kNoIndex)) ? |
| + translate::kUnknownLanguageCode : |
| + language_code_at(original_language_index()); |
| } |
| std::string target_language_code() const { |
| - return ui_delegate_.GetTargetLanguageCode(); |
| + // Note: TranslateUIDelegate should be updated if this implementation is |
| + // updated. |
| + return language_code_at(target_language_index()); |
| } |
| // Returns true if the current infobar indicates an error (in which case it |
| @@ -199,7 +214,14 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { |
| // infobar. |
| BackgroundAnimationType background_animation_; |
| - TranslateUIDelegate ui_delegate_; |
| + // The list supported languages for translation. |
|
Peter Kasting
2013/11/08 23:47:47
Nit: All three of these comments have grammar issu
hajimehoshi
2013/11/11 04:01:02
Done. They were original.: https://codereview.chro
|
| + std::vector<LanguageNamePair> languages_; |
| + |
| + // The index for language the page is originally in. |
| + size_t original_language_index_; |
| + |
| + // The index for language the page should be translated to. |
| + size_t target_language_index_; |
| // The error that occurred when trying to translate (NONE if no error). |
| TranslateErrors::Type error_type_; |