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

Unified Diff: components/translate/core/browser/options_menu_model.cc

Issue 284313008: Move TranslateInfoBarDelegate and OptionsMenuModel to the Translate component. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase + review comments Created 6 years, 7 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: 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 69%
rename from chrome/browser/translate/options_menu_model.cc
rename to components/translate/core/browser/options_menu_model.cc
index 19fc5c298f045e2a68fc30196abb0f722f96f337..42a3bda9ff1c29c840b39d7661b47264d2eb7146 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/components_strings.h"
-#include "grit/locale_settings.h"
#include "ui/base/l10n/l10n_util.h"
namespace {
@@ -23,8 +21,7 @@ const char kAboutGoogleTranslateURL[] =
} // namespace
-OptionsMenuModel::OptionsMenuModel(
- TranslateInfoBarDelegate* translate_delegate)
+OptionsMenuModel::OptionsMenuModel(TranslateInfoBarDelegate* translate_delegate)
: ui::SimpleMenuModel(this),
translate_infobar_delegate_(translate_delegate) {
// |translate_delegate| must already be owned.
@@ -43,26 +40,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(ALWAYS_TRANSLATE,
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS,
original_language, target_language));
- AddCheckItem(IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG,
- l10n_util::GetStringFUTF16(
- IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_LANG,
- original_language));
+ AddCheckItem(NEVER_TRANSLATE_LANGUAGE,
+ l10n_util::GetStringFUTF16(
+ IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_LANG,
+ original_language));
}
- AddCheckItem(IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE,
- l10n_util::GetStringUTF16(
- IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE));
+ AddCheckItem(NEVER_TRANSLATE_SITE,
+ 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(REPORT_BAD_DETECTION,
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_REPORT_ERROR,
original_language));
}
- AddItemWithStringId(IDC_TRANSLATE_OPTIONS_ABOUT,
- IDS_TRANSLATE_INFOBAR_OPTIONS_ABOUT);
+ AddItemWithStringId(ABOUT_TRANSLATE, IDS_TRANSLATE_INFOBAR_OPTIONS_ABOUT);
}
OptionsMenuModel::~OptionsMenuModel() {
@@ -70,13 +66,13 @@ OptionsMenuModel::~OptionsMenuModel() {
bool OptionsMenuModel::IsCommandIdChecked(int command_id) const {
switch (command_id) {
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG:
+ case NEVER_TRANSLATE_LANGUAGE:
return !translate_infobar_delegate_->IsTranslatableLanguageByPrefs();
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE:
+ case NEVER_TRANSLATE_SITE:
return translate_infobar_delegate_->IsSiteBlacklisted();
- case IDC_TRANSLATE_OPTIONS_ALWAYS:
+ case ALWAYS_TRANSLATE:
return translate_infobar_delegate_->ShouldAlwaysTranslate();
default:
@@ -88,11 +84,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 NEVER_TRANSLATE_LANGUAGE:
+ case NEVER_TRANSLATE_SITE:
return !translate_infobar_delegate_->ShouldAlwaysTranslate();
- case IDC_TRANSLATE_OPTIONS_ALWAYS :
+ case ALWAYS_TRANSLATE:
return (translate_infobar_delegate_->IsTranslatableLanguageByPrefs() &&
!translate_infobar_delegate_->IsSiteBlacklisted());
@@ -103,29 +99,30 @@ bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const {
}
bool OptionsMenuModel::GetAcceleratorForCommandId(
- int command_id, ui::Accelerator* accelerator) {
+ int command_id,
+ ui::Accelerator* accelerator) {
return false;
}
void OptionsMenuModel::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_LANG:
+ case NEVER_TRANSLATE_LANGUAGE:
translate_infobar_delegate_->ToggleTranslatableLanguageByPrefs();
break;
- case IDC_TRANSLATE_OPTIONS_NEVER_TRANSLATE_SITE:
+ case NEVER_TRANSLATE_SITE:
translate_infobar_delegate_->ToggleSiteBlacklist();
break;
- case IDC_TRANSLATE_OPTIONS_ALWAYS:
+ case ALWAYS_TRANSLATE:
translate_infobar_delegate_->ToggleAlwaysTranslate();
break;
- case IDC_TRANSLATE_REPORT_BAD_LANGUAGE_DETECTION:
+ case REPORT_BAD_DETECTION:
translate_infobar_delegate_->ReportLanguageDetectionError();
break;
- case IDC_TRANSLATE_OPTIONS_ABOUT: {
+ case ABOUT_TRANSLATE: {
TranslateDriver* translate_driver =
translate_infobar_delegate_->GetTranslateDriver();
if (translate_driver)
« no previous file with comments | « components/translate/core/browser/options_menu_model.h ('k') | components/translate/core/browser/translate_client.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698