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

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

Issue 107303002: Make the TranslateInfoBarDelegate once again use the TranslateUIDelegate. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years 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
===================================================================
--- chrome/browser/translate/translate_infobar_delegate.h (revision 239110)
+++ chrome/browser/translate/translate_infobar_delegate.h (working copy)
@@ -13,6 +13,7 @@
#include "base/memory/scoped_ptr.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"
@@ -25,8 +26,6 @@
int never_translate_min_count;
};
-// NOTE: TranslateUIDelegate should be updated if this implementation is
-// updated.
class TranslateInfoBarDelegate : public InfoBarDelegate {
public:
// The different types of infobars that can be shown for translation.
@@ -71,23 +70,16 @@
const ShortcutConfiguration& shortcut_config);
// Returns the number of languages supported.
- size_t num_languages() const {
+ size_t num_languages() const { return ui_delegate_.GetNumberOfLanguages(); }
- return languages_.size();
- }
-
// 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 == static_cast<size_t>(kNoIndex))
- return string16();
- DCHECK_LT(index, num_languages());
- return languages_[index].second;
+ return ui_delegate_.GetLanguageNameAt(index);
}
Type infobar_type() const { return infobar_type_; }
@@ -94,22 +86,22 @@
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 UpdateOriginalLanguageIndex(size_t language_index);
- size_t target_language_index() const { return target_language_index_; }
-
+ size_t target_language_index() const {
+ return ui_delegate_.GetTargetLanguageIndex();
+ }
void UpdateTargetLanguageIndex(size_t language_index);
// Convenience methods.
std::string original_language_code() const {
- return (original_language_index() == static_cast<size_t>(kNoIndex)) ?
- translate::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
@@ -180,7 +172,8 @@
bool autodetermined_source_language);
protected:
- TranslateInfoBarDelegate(Type infobar_type,
+ TranslateInfoBarDelegate(content::WebContents* web_contents,
+ Type infobar_type,
TranslateInfoBarDelegate* old_delegate,
const std::string& original_language,
const std::string& target_language,
@@ -210,15 +203,8 @@
// infobar.
BackgroundAnimationType background_animation_;
- // The list of the languages supported for translation.
- std::vector<LanguageNamePair> languages_;
+ TranslateUIDelegate ui_delegate_;
- // The index of the webpage's original language.
- size_t original_language_index_;
-
- // The index of the language the webpage will be translated into.
- size_t target_language_index_;
-
// The error that occurred when trying to translate (NONE if no error).
TranslateErrors::Type error_type_;
« no previous file with comments | « chrome/browser/translate/translate_browser_metrics.cc ('k') | chrome/browser/translate/translate_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698