Index: components/translate/core/browser/options_menu_model.cc |
diff --git a/chrome/browser/translate/options_menu_model.cc b/components/translate/core/browser/options_menu_model.cc |
similarity index 77% |
rename from chrome/browser/translate/options_menu_model.cc |
rename to components/translate/core/browser/options_menu_model.cc |
index 9b16323ce65869bc059537b180527a349776bc15..f3a5bd230841101e02b369f63cf890028ed60b3f 100644 |
--- a/chrome/browser/translate/options_menu_model.cc |
+++ b/components/translate/core/browser/options_menu_model.cc |
@@ -2,14 +2,12 @@ |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
-#include "chrome/browser/translate/options_menu_model.h" |
+#include "components/translate/core/browser/options_menu_model.h" |
#include "base/metrics/histogram.h" |
-#include "chrome/app/chrome_command_ids.h" |
-#include "chrome/browser/translate/translate_infobar_delegate.h" |
#include "components/translate/core/browser/translate_driver.h" |
+#include "components/translate/core/browser/translate_infobar_delegate.h" |
#include "grit/component_strings.h" |
-#include "grit/locale_settings.h" |
#include "ui/base/l10n/l10n_util.h" |
namespace { |
@@ -23,6 +21,12 @@ const char kAboutGoogleTranslateURL[] = |
} // namespace |
+const int OptionsMenuModel::kOptionsAboutTranslate = 0; |
+const int OptionsMenuModel::kOptionsAlwaysTranslate = 1; |
+const int OptionsMenuModel::kOptionsNeverTranslateLanguage = 2; |
+const int OptionsMenuModel::kOptionsNeverTranslateSite = 3; |
+const int OptionsMenuModel::kOptionsReportBadDetection = 4; |
Peter Kasting
2014/05/21 20:38:24
Hmm, looks like maybe these should be an enum rath
droger
2014/05/22 12:33:37
I agree, the enum was also my first idea.
I used t
|
+ |
OptionsMenuModel::OptionsMenuModel( |
TranslateInfoBarDelegate* translate_delegate) |
: ui::SimpleMenuModel(this), |
@@ -43,25 +47,25 @@ OptionsMenuModel::OptionsMenuModel( |
// Incognito mode does not get any preferences related items. |
if (!translate_delegate->is_off_the_record()) { |
if (!autodetermined_source_language) { |
- AddCheckItem(IDC_TRANSLATE_OPTIONS_ALWAYS, |
+ AddCheckItem(kOptionsAlwaysTranslate, |
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS, |
original_language, target_language)); |
- AddCheckItem(IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG, |
+ AddCheckItem(kOptionsNeverTranslateLanguage, |
l10n_util::GetStringFUTF16( |
IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_LANG, |
original_language)); |
} |
- AddCheckItem(IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE, |
+ AddCheckItem(kOptionsNeverTranslateSite, |
l10n_util::GetStringUTF16( |
IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE)); |
AddSeparator(ui::NORMAL_SEPARATOR); |
} |
if (!autodetermined_source_language) { |
- AddItem(IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION, |
+ AddItem(kOptionsReportBadDetection, |
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_REPORT_ERROR, |
original_language)); |
} |
- AddItemWithStringId(IDC_TRANSLATE_OPTIONS_ABOUT, |
+ AddItemWithStringId(kOptionsAboutTranslate, |
IDS_TRANSLATE_INFOBAR_OPTIONS_ABOUT); |
} |
@@ -70,13 +74,13 @@ OptionsMenuModel::~OptionsMenuModel() { |
bool OptionsMenuModel::IsCommandIdChecked(int command_id) const { |
switch (command_id) { |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG: |
+ case kOptionsNeverTranslateLanguage: |
return !translate_infobar_delegate_->IsTranslatableLanguageByPrefs(); |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE: |
+ case kOptionsNeverTranslateSite: |
return translate_infobar_delegate_->IsSiteBlacklisted(); |
- case IDC_TRANSLATE_OPTIONS_ALWAYS: |
+ case kOptionsAlwaysTranslate: |
return translate_infobar_delegate_->ShouldAlwaysTranslate(); |
default: |
@@ -88,11 +92,11 @@ bool OptionsMenuModel::IsCommandIdChecked(int command_id) const { |
bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const { |
switch (command_id) { |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG : |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE : |
+ case kOptionsNeverTranslateLanguage : |
+ case kOptionsNeverTranslateSite : |
return !translate_infobar_delegate_->ShouldAlwaysTranslate(); |
- case IDC_TRANSLATE_OPTIONS_ALWAYS : |
+ case kOptionsAlwaysTranslate : |
return (translate_infobar_delegate_->IsTranslatableLanguageByPrefs() && |
!translate_infobar_delegate_->IsSiteBlacklisted()); |
@@ -109,23 +113,23 @@ bool OptionsMenuModel::GetAcceleratorForCommandId( |
void OptionsMenuModel::ExecuteCommand(int command_id, int event_flags) { |
switch (command_id) { |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG: |
+ case kOptionsNeverTranslateLanguage: |
translate_infobar_delegate_->ToggleTranslatableLanguageByPrefs(); |
break; |
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE: |
+ case kOptionsNeverTranslateSite: |
translate_infobar_delegate_->ToggleSiteBlacklist(); |
break; |
- case IDC_TRANSLATE_OPTIONS_ALWAYS: |
+ case kOptionsAlwaysTranslate: |
translate_infobar_delegate_->ToggleAlwaysTranslate(); |
break; |
- case IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION: |
+ case kOptionsReportBadDetection: |
translate_infobar_delegate_->ReportLanguageDetectionError(); |
break; |
- case IDC_TRANSLATE_OPTIONS_ABOUT: { |
+ case kOptionsAboutTranslate: { |
TranslateDriver* translate_driver = |
translate_infobar_delegate_->GetTranslateDriver(); |
if (translate_driver) |