Commit 7fcfeb7c authored by Daniel Bratell's avatar Daniel Bratell Committed by Commit Bot

Remove unused OptionMenuModel from components/translate

It was linked into some jumbo build experiments where it triggered
link errors.

If you include an object file, for instance options_menu_model.o, in
an archive, for instance libtranslate.a, and nothing references that
object file, then the linker won't care if options_menu_model.o is
referencing all kinds of undefined symbols. It's a feature or quirk
depending on who you asks.

With jumbo compilation this options_menu_model.o would be combined
with 7+ other .o files into translate_jumbo_1.o and since the .o file
is no longer completely unused, the linker will get upset about the
dangling references.

So something that used to be "just" dead code compilation with
dangling references becomes a linking error when compiling with jumbo.

Change-Id: Id15f7e15804efe2fdf959c4db7fdade061477102
Reviewed-on: https://chromium-review.googlesource.com/c/1256685
Commit-Queue: Daniel Bratell <bratell@opera.com>
Reviewed-by: default avatarTakashi Toyoshima <toyoshim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#596168}
parent 5a32141e
......@@ -78,13 +78,6 @@ static_library("browser") {
]
deps += [ "//components/infobars/core" ]
}
if (is_mac) {
sources += [
"options_menu_model.cc",
"options_menu_model.h",
]
}
}
source_set("unit_tests") {
......
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "components/translate/core/browser/options_menu_model.h"
#include "base/metrics/histogram.h"
#include "build/build_config.h"
#include "components/strings/grit/components_strings.h"
#include "components/translate/core/browser/translate_driver.h"
#include "components/translate/core/browser/translate_infobar_delegate.h"
#include "ui/base/l10n/l10n_util.h"
namespace translate {
namespace {
const char kAboutGoogleTranslateURL[] =
#if defined(OS_CHROMEOS)
"https://support.google.com/chromebook/?p=ib_translation_bar";
#else
"https://support.google.com/chrome/?p=ib_translation_bar";
#endif
} // namespace
OptionsMenuModel::OptionsMenuModel(TranslateInfoBarDelegate* translate_delegate)
: ui::SimpleMenuModel(this),
translate_infobar_delegate_(translate_delegate) {
// |translate_delegate| must already be owned.
DCHECK(translate_infobar_delegate_->GetTranslateDriver());
base::string16 original_language =
translate_delegate->original_language_name();
base::string16 target_language = translate_delegate->target_language_name();
bool autodetermined_source_language =
(translate_delegate->original_language_code() ==
translate::kUnknownLanguageCode);
// Populate the menu.
// Incognito mode does not get any preferences related items.
if (!translate_delegate->is_off_the_record()) {
if (!autodetermined_source_language) {
AddCheckItem(ALWAYS_TRANSLATE,
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_ALWAYS,
original_language, target_language));
AddCheckItem(NEVER_TRANSLATE_LANGUAGE,
l10n_util::GetStringFUTF16(
IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_LANG,
original_language));
}
AddCheckItem(NEVER_TRANSLATE_SITE,
l10n_util::GetStringUTF16(
IDS_TRANSLATE_INFOBAR_OPTIONS_NEVER_TRANSLATE_SITE));
AddSeparator(ui::NORMAL_SEPARATOR);
}
if (!autodetermined_source_language) {
AddItem(REPORT_BAD_DETECTION,
l10n_util::GetStringFUTF16(IDS_TRANSLATE_INFOBAR_OPTIONS_REPORT_ERROR,
original_language));
}
AddItemWithStringId(ABOUT_TRANSLATE, IDS_TRANSLATE_INFOBAR_OPTIONS_ABOUT);
}
OptionsMenuModel::~OptionsMenuModel() {
}
bool OptionsMenuModel::IsCommandIdChecked(int command_id) const {
switch (command_id) {
case NEVER_TRANSLATE_LANGUAGE:
return !translate_infobar_delegate_->IsTranslatableLanguageByPrefs();
case NEVER_TRANSLATE_SITE:
return translate_infobar_delegate_->IsSiteBlacklisted();
case ALWAYS_TRANSLATE:
return translate_infobar_delegate_->ShouldAlwaysTranslate();
default:
NOTREACHED() << "Invalid command_id from menu";
break;
}
return false;
}
bool OptionsMenuModel::IsCommandIdEnabled(int command_id) const {
switch (command_id) {
case NEVER_TRANSLATE_LANGUAGE:
case NEVER_TRANSLATE_SITE:
return !translate_infobar_delegate_->ShouldAlwaysTranslate();
case ALWAYS_TRANSLATE:
return (translate_infobar_delegate_->IsTranslatableLanguageByPrefs() &&
!translate_infobar_delegate_->IsSiteBlacklisted());
default:
break;
}
return true;
}
void OptionsMenuModel::ExecuteCommand(int command_id, int event_flags) {
switch (command_id) {
case NEVER_TRANSLATE_LANGUAGE:
translate_infobar_delegate_->ToggleTranslatableLanguageByPrefs();
break;
case NEVER_TRANSLATE_SITE:
translate_infobar_delegate_->ToggleSiteBlacklist();
break;
case ALWAYS_TRANSLATE:
translate_infobar_delegate_->ToggleAlwaysTranslate();
break;
case REPORT_BAD_DETECTION:
translate_infobar_delegate_->ReportLanguageDetectionError();
break;
case ABOUT_TRANSLATE: {
TranslateDriver* translate_driver =
translate_infobar_delegate_->GetTranslateDriver();
if (translate_driver)
translate_driver->OpenUrlInNewTab(GURL(kAboutGoogleTranslateURL));
break;
}
default:
NOTREACHED() << "Invalid command id from menu.";
break;
}
}
} // namespace translate
// Copyright 2014 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_OPTIONS_MENU_MODEL_H_
#define COMPONENTS_TRANSLATE_CORE_BROWSER_OPTIONS_MENU_MODEL_H_
#include "base/macros.h"
#include "ui/base/models/simple_menu_model.h"
namespace translate {
class TranslateInfoBarDelegate;
// A menu model that builds the contents of the options menu in the translate
// infobar. This menu has only one level (no submenus).
class OptionsMenuModel : public ui::SimpleMenuModel,
public ui::SimpleMenuModel::Delegate {
public:
// Command IDs of the items in this menu; exposed for testing.
enum CommandID {
ABOUT_TRANSLATE = 0,
ALWAYS_TRANSLATE,
NEVER_TRANSLATE_LANGUAGE,
NEVER_TRANSLATE_SITE,
REPORT_BAD_DETECTION
};
explicit OptionsMenuModel(TranslateInfoBarDelegate* translate_delegate);
~OptionsMenuModel() override;
// ui::SimpleMenuModel::Delegate implementation:
bool IsCommandIdChecked(int command_id) const override;
bool IsCommandIdEnabled(int command_id) const override;
void ExecuteCommand(int command_id, int event_flags) override;
private:
TranslateInfoBarDelegate* translate_infobar_delegate_;
DISALLOW_COPY_AND_ASSIGN(OptionsMenuModel);
};
} // namespace translate
#endif // COMPONENTS_TRANSLATE_CORE_BROWSER_OPTIONS_MENU_MODEL_H_
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment