diff options
author | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 09:50:51 +0000 |
---|---|---|
committer | jeremy@chromium.org <jeremy@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-15 09:50:51 +0000 |
commit | 11c77115e78a080bfb954ef5e92b13bce42c824a (patch) | |
tree | 9280d6a28e45d1bc36141d3dbd814dbc2b26cefb /chrome/browser/translate | |
parent | a2ec1c5ab77e17e3022d651630fe59e24ae71f4c (diff) | |
download | chromium_src-11c77115e78a080bfb954ef5e92b13bce42c824a.zip chromium_src-11c77115e78a080bfb954ef5e92b13bce42c824a.tar.gz chromium_src-11c77115e78a080bfb954ef5e92b13bce42c824a.tar.bz2 |
Revert "Reland translate toolbar unit tests (originally landed as r41274, rolled back at r41284)."
Revert r41569 - 10.6 unit tests not passing.
Review URL: http://codereview.chromium.org/959001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41570 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/translate')
4 files changed, 29 insertions, 33 deletions
diff --git a/chrome/browser/translate/languages_menu_model.cc b/chrome/browser/translate/languages_menu_model.cc index 5231ce0..ba749df 100644 --- a/chrome/browser/translate/languages_menu_model.cc +++ b/chrome/browser/translate/languages_menu_model.cc @@ -24,7 +24,7 @@ LanguagesMenuModel::LanguagesMenuModel( } std::vector<std::string>::const_iterator iter = languages.begin(); for (int i = base_command_id; iter != languages.end(); ++i, ++iter) { - AddItem(i, translate_delegate->GetDisplayNameForLocale(*iter)); + AddItem(i, TranslateInfoBarDelegate::GetDisplayNameForLocale(*iter)); } } diff --git a/chrome/browser/translate/options_menu_model.cc b/chrome/browser/translate/options_menu_model.cc index 4364e07..376e2cb 100644 --- a/chrome/browser/translate/options_menu_model.cc +++ b/chrome/browser/translate/options_menu_model.cc @@ -13,7 +13,7 @@ OptionsMenuModel::OptionsMenuModel(menus::SimpleMenuModel::Delegate* delegate, TranslateInfoBarDelegate* translate_delegate) : menus::SimpleMenuModel(delegate) { string16 original_language = - translate_delegate->GetDisplayNameForLocale( + TranslateInfoBarDelegate::GetDisplayNameForLocale( translate_delegate->original_lang_code()); TranslateInfoBarDelegate::TranslateState state = translate_delegate->state(); if (state == TranslateInfoBarDelegate::kBeforeTranslate) { @@ -26,7 +26,7 @@ OptionsMenuModel::OptionsMenuModel(menus::SimpleMenuModel::Delegate* delegate, IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE)); } else if (state == TranslateInfoBarDelegate::kAfterTranslate) { string16 target_language = - translate_delegate->GetDisplayNameForLocale( + TranslateInfoBarDelegate::GetDisplayNameForLocale( translate_delegate->target_lang_code()); AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS, l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS, diff --git a/chrome/browser/translate/translate_infobars_delegates.cc b/chrome/browser/translate/translate_infobars_delegates.cc index 062eba8..948e337 100644 --- a/chrome/browser/translate/translate_infobars_delegates.cc +++ b/chrome/browser/translate/translate_infobars_delegates.cc @@ -41,12 +41,6 @@ void TranslateInfoBarDelegate::InfoBarClosed() { // TranslateInfoBarDelegate: public: ------------------------------------------- -string16 TranslateInfoBarDelegate::GetDisplayNameForLocale( - const std::string& language_code) { - return l10n_util::GetDisplayNameForLocale( - language_code, g_browser_process->GetApplicationLocale(), true); -} - void TranslateInfoBarDelegate::UpdateState(TranslateState new_state) { if (state_ != new_state) state_ = new_state; @@ -90,7 +84,7 @@ void TranslateInfoBarDelegate::TranslationDeclined() { bool TranslateInfoBarDelegate::IsLanguageBlacklisted() { if (state_ == kBeforeTranslate) { never_translate_language_ = - prefs_->IsLanguageBlacklisted(original_lang_code()); + prefs_.IsLanguageBlacklisted(original_lang_code()); return never_translate_language_; } NOTREACHED() << "Invalid mehod called for translate state"; @@ -99,7 +93,7 @@ bool TranslateInfoBarDelegate::IsLanguageBlacklisted() { bool TranslateInfoBarDelegate::IsSiteBlacklisted() { if (state_ == kBeforeTranslate) { - never_translate_site_ = prefs_->IsSiteBlacklisted(site_); + never_translate_site_ = prefs_.IsSiteBlacklisted(site_); return never_translate_site_; } NOTREACHED() << "Invalid mehod called for translate state"; @@ -108,7 +102,7 @@ bool TranslateInfoBarDelegate::IsSiteBlacklisted() { bool TranslateInfoBarDelegate::ShouldAlwaysTranslate() { if (state_ == kAfterTranslate) { - always_translate_ = prefs_->IsLanguagePairWhitelisted(original_lang_code(), + always_translate_ = prefs_.IsLanguagePairWhitelisted(original_lang_code(), target_lang_code()); return always_translate_; } @@ -120,9 +114,9 @@ void TranslateInfoBarDelegate::ToggleLanguageBlacklist() { if (state_ == kBeforeTranslate) { never_translate_language_ = !never_translate_language_; if (never_translate_language_) - prefs_->BlacklistLanguage(original_lang_code()); + prefs_.BlacklistLanguage(original_lang_code()); else - prefs_->RemoveLanguageFromBlacklist(original_lang_code()); + prefs_.RemoveLanguageFromBlacklist(original_lang_code()); } else { NOTREACHED() << "Invalid method called for translate state"; } @@ -132,9 +126,9 @@ void TranslateInfoBarDelegate::ToggleSiteBlacklist() { if (state_ == kBeforeTranslate) { never_translate_site_ = !never_translate_site_; if (never_translate_site_) - prefs_->BlacklistSite(site_); + prefs_.BlacklistSite(site_); else - prefs_->RemoveSiteFromBlacklist(site_); + prefs_.RemoveSiteFromBlacklist(site_); } else { NOTREACHED() << "Invalid mehod called for translate state"; } @@ -144,9 +138,9 @@ void TranslateInfoBarDelegate::ToggleAlwaysTranslate() { if (state_ == kAfterTranslate) { always_translate_ = !always_translate_; if (always_translate_) - prefs_->WhitelistLanguagePair(original_lang_code(), target_lang_code()); + prefs_.WhitelistLanguagePair(original_lang_code(), target_lang_code()); else - prefs_->RemoveLanguagePairFromWhitelist(original_lang_code(), + prefs_.RemoveLanguagePairFromWhitelist(original_lang_code(), target_lang_code()); } else { NOTREACHED() << "Invalid mehod called for translate state"; @@ -215,6 +209,12 @@ TranslateInfoBarDelegate* TranslateInfoBarDelegate::Create( original_lang_index, target_lang_index); } +string16 TranslateInfoBarDelegate::GetDisplayNameForLocale( + const std::string& language_code) { + return l10n_util::GetDisplayNameForLocale( + language_code, g_browser_process->GetApplicationLocale(), true); +} + // TranslateInfoBarDelegate: private: ------------------------------------------ TranslateInfoBarDelegate::TranslateInfoBarDelegate(TabContents* tab_contents, @@ -222,7 +222,7 @@ TranslateInfoBarDelegate::TranslateInfoBarDelegate(TabContents* tab_contents, int original_lang_index, int target_lang_index) : InfoBarDelegate(tab_contents), tab_contents_(tab_contents), - prefs_(new TranslatePrefs(user_prefs)), + prefs_(user_prefs), state_(state), site_(url.HostNoBrackets()), original_lang_index_(original_lang_index), diff --git a/chrome/browser/translate/translate_infobars_delegates.h b/chrome/browser/translate/translate_infobars_delegates.h index 02d905d..ce8cede 100644 --- a/chrome/browser/translate/translate_infobars_delegates.h +++ b/chrome/browser/translate/translate_infobars_delegates.h @@ -35,14 +35,14 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { void GetAvailableTargetLanguages(std::vector<std::string>* languages); void ModifyOriginalLanguage(int lang_index); void ModifyTargetLanguage(int lang_index); - virtual void Translate(); - virtual void TranslationDeclined(); - virtual bool IsLanguageBlacklisted(); - virtual void ToggleLanguageBlacklist(); - virtual bool IsSiteBlacklisted(); - virtual void ToggleSiteBlacklist(); - virtual bool ShouldAlwaysTranslate(); - virtual void ToggleAlwaysTranslate(); + void Translate(); + void TranslationDeclined(); + bool IsLanguageBlacklisted(); + void ToggleLanguageBlacklist(); + bool IsSiteBlacklisted(); + void ToggleSiteBlacklist(); + bool ShouldAlwaysTranslate(); + void ToggleAlwaysTranslate(); int original_lang_index() const { return original_lang_index_; @@ -94,15 +94,11 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { virtual void InfoBarClosed(); // Returns the printable version of the language code |language_code|. - virtual string16 GetDisplayNameForLocale(const std::string& language_code); + static string16 GetDisplayNameForLocale(const std::string& language_code); // Overridden from InfoBarDelegate: virtual InfoBar* CreateInfoBar(); - protected: - // For testing. - TranslateInfoBarDelegate() : InfoBarDelegate(NULL) {} - private: TranslateInfoBarDelegate(TabContents* contents, PrefService* user_prefs, @@ -112,7 +108,7 @@ class TranslateInfoBarDelegate : public InfoBarDelegate { int target_language_index); TabContents* tab_contents_; // Weak. - scoped_ptr<TranslatePrefs> prefs_; + TranslatePrefs prefs_; TranslateState state_; std::string site_; int original_lang_index_; |