Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[translate] Stop checking Google Translate Extension #15110

Merged
merged 2 commits into from
Sep 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions browser/translate/brave_translate_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,4 @@ bool IsTranslateExtensionEnabled(content::BrowserContext* context) {
#endif // BUILDFLAG(ENABLE_EXTENSIONS)
}

bool IsInternalTranslationEnabled(content::BrowserContext* context) {
return !IsTranslateExtensionEnabled(context) && IsBraveTranslateGoAvailable();
}

} // namespace translate
2 changes: 0 additions & 2 deletions browser/translate/brave_translate_utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@ namespace translate {

bool IsTranslateExtensionEnabled(content::BrowserContext* context);

bool IsInternalTranslationEnabled(content::BrowserContext* context);

} // namespace translate

#endif // BRAVE_BROWSER_TRANSLATE_BRAVE_TRANSLATE_UTILS_H_
11 changes: 5 additions & 6 deletions browser/ui/views/frame/brave_browser_view.cc
Original file line number Diff line number Diff line change
Expand Up @@ -333,13 +333,12 @@ ShowTranslateBubbleResult BraveBrowserView::ShowTranslateBubble(
translate::TranslateErrors::Type error_type,
bool is_user_gesture) {
#if BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
if (translate::IsInternalTranslationEnabled(GetProfile())) {
return BrowserView::ShowTranslateBubble(web_contents, step, source_language,
target_language, error_type,
is_user_gesture);
}
#endif // BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
return BrowserView::ShowTranslateBubble(web_contents, step, source_language,
target_language, error_type,
is_user_gesture);
#else // BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
return ShowTranslateBubbleResult::BROWSER_WINDOW_NOT_VALID;
#endif // BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
}

speedreader::SpeedreaderBubbleView* BraveBrowserView::ShowSpeedreaderBubble(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "brave/browser/renderer_context_menu/brave_spelling_options_submenu_observer.h"
#include "brave/components/ipfs/buildflags/buildflags.h"
#include "brave/components/tor/buildflags/buildflags.h"
#include "brave/components/translate/core/common/buildflags.h"
#include "brave/grit/brave_theme_resources.h"
#include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h"
#include "chrome/browser/ui/browser_list.h"
Expand All @@ -37,10 +36,6 @@
#include "brave/components/ipfs/ipfs_utils.h"
#endif

#if BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
#include "brave/browser/translate/brave_translate_utils.h"
#endif

// Our .h file creates a masquerade for RenderViewContextMenu. Switch
// back to the Chromium one for the Chromium implementation.
#undef RenderViewContextMenu
Expand Down Expand Up @@ -404,20 +399,4 @@ void BraveRenderViewContextMenu::InitMenu() {
#if BUILDFLAG(ENABLE_IPFS)
BuildIPFSMenu();
#endif

#if BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)
const bool remove_translate =
!translate::IsInternalTranslationEnabled(GetProfile());
#else
const bool remove_translate = true;
#endif // BUILDFLAG(ENABLE_BRAVE_TRANSLATE_GO)

// Only show the translate item when go-translate is enabled.
// This removes menu item, but keeps the duplicated separator. The duplicated
// separator is removed in |BraveRenderViewContextMenuViews::Show|
if (remove_translate) {
index = menu_model_.GetIndexOfCommandId(IDC_CONTENT_CONTEXT_TRANSLATE);
if (index.has_value())
menu_model_.RemoveItemAt(index.value());
}
}