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

Unified Diff: chrome/browser/translate/translate_infobar_delegate.h

Issue 23708029: Translate: Refactoring: Create TranslateUIDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: (rebasing) Created 7 years, 2 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 side-by-side diff with in-line comments
Download patch
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 5b21995637dc7b7b537a693860f735d984c41738..59abd9e5c5bd47051b1afccf880687edc20b7c7c 100644
--- a/chrome/browser/translate/translate_infobar_delegate.h
+++ b/chrome/browser/translate/translate_infobar_delegate.h
@@ -13,6 +13,7 @@
#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/chrome_constants.h"
#include "chrome/common/translate/translate_errors.h"
@@ -69,45 +70,41 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
const ShortcutConfiguration& shortcut_config);
// Returns the number of languages supported.
- size_t num_languages() const { return languages_.size(); }
+ size_t num_languages() const { return ui_delegate_.GetNumberOfLanguages(); }
// Returns the ISO code for the language at |index|.
std::string language_code_at(size_t index) const {
- DCHECK_LT(index, num_languages());
- return languages_[index].first;
+ return ui_delegate_.GetLanguageCodeAt(index);
}
// Returns the displayable name for the language at |index|.
string16 language_name_at(size_t index) const {
- if (index == kNoIndex)
- return string16();
- DCHECK_LT(index, num_languages());
- return languages_[index].second;
+ return ui_delegate_.GetLanguageNameAt(index);
}
Type infobar_type() const { return infobar_type_; }
TranslateErrors::Type error_type() const { return error_type_; }
- size_t original_language_index() const { return original_language_index_; }
+ size_t original_language_index() const {
+ return ui_delegate_.GetOriginalLanguageIndex();
+ }
void set_original_language_index(size_t language_index) {
- DCHECK_LT(language_index, num_languages());
- original_language_index_ = language_index;
+ ui_delegate_.SetOriginalLanguageIndex(language_index);
+ }
+ size_t target_language_index() const {
+ return ui_delegate_.GetTargetLanguageIndex();
}
- size_t target_language_index() const { return target_language_index_; }
void set_target_language_index(size_t language_index) {
- DCHECK_LT(language_index, num_languages());
- target_language_index_ = language_index;
+ ui_delegate_.SetTargetLanguageIndex(language_index);
}
// Convenience methods.
std::string original_language_code() const {
- return (original_language_index() == kNoIndex) ?
- chrome::kUnknownLanguageCode :
- language_code_at(original_language_index());
+ return ui_delegate_.GetOriginalLanguageCode();
}
std::string target_language_code() const {
- return language_code_at(target_language_index());
+ return ui_delegate_.GetTargetLanguageCode();
}
// Returns true if the current infobar indicates an error (in which case it
@@ -199,34 +196,13 @@ class TranslateInfoBarDelegate : public InfoBarDelegate {
const content::LoadCommittedDetails& details) const OVERRIDE;
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE;
- // Gets the host of the page being translated, or an empty string if no URL is
- // associated with the current page.
- std::string GetPageHost();
-
Type infobar_type_;
// The type of fading animation if any that should be used when showing this
// infobar.
BackgroundAnimationType background_animation_;
- // The list supported languages for translation.
- // The pair first string is the language ISO code (ex: en, fr...), the second
- // string is the displayable name on the current locale.
- // The languages are sorted alphabetically based on the displayable name.
- std::vector<LanguageNamePair> languages_;
-
- // The index for language the page is originally in.
- size_t original_language_index_;
-
- // The index for language the page is originally in that was originally
- // reported (original_language_index_ changes if the user selects a new
- // original language, but this one does not). This is necessary to report
- // language detection errors with the right original language even if the user
- // changed the original language.
- size_t initial_original_language_index_;
-
- // The index for language the page should be translated to.
- size_t target_language_index_;
+ TranslateUIDelegate ui_delegate_;
// The error that occurred when trying to translate (NONE if no error).
TranslateErrors::Type error_type_;

Powered by Google App Engine
This is Rietveld 408576698