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

Enable internal translate engine #10453

Merged
merged 35 commits into from Oct 20, 2021
Merged

Conversation

atuchin-m
Copy link
Collaborator

@atuchin-m atuchin-m commented Oct 11, 2021

Resolves brave/brave-browser#18593
Core:

  • A new base::Feature and a flag are added;
  • Both buildflags are enabled for desktop platforms, the decision of how to work (using the translate extension or the internal engine) is based on a new feature in runtime;

UI:

  • The original chromium translation bubble was restored, but the custom bubble (that suggests the extension installation) also works well.
  • context menu available when a user doesn't use the translate extension or we don't suggest installing it.

Network and the translate script:

  • C++ redirections for the script are replaced to js redirections. Thay way we can split them from the other requests.
  • Modified CSP for the translate isolated world is used to limit requests to *.brave.com
  • Translate urls in C++ code are changed to translate-relay.brave.com using chromium switches.
  • Language list requests are disabled by default.
  • the dummy translate fetcher and tests are removed, translate_script is patched by chromium_src instead.

Bowser tests for redirection will be added if anything is ok.

Submitter Checklist:

  • I confirm that no security/privacy review is needed, or that I have requested one
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally: npm run test -- brave_browser_tests, npm run test -- brave_unit_tests, npm run lint, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@atuchin-m atuchin-m requested review from iefremov and a team as code owners October 11, 2021 12:47
@atuchin-m atuchin-m force-pushed the enable-internal-translate-engine branch from 16c79cd to 5f10a7c Compare October 11, 2021 12:49
@atuchin-m atuchin-m requested a review from a team as a code owner October 12, 2021 14:38
@atuchin-m atuchin-m changed the title Draft: Enable internal translate engine Enable internal translate engine Oct 13, 2021
@atuchin-m
Copy link
Collaborator Author

@fmarier could you please take a look?
It's related to https://github.com/brave/security/issues/613
Moreover you could find the discussion about the other options in #machine-translation channel.

@atuchin-m atuchin-m requested a review from goodov October 13, 2021 15:00
@fmarier
Copy link
Member

fmarier commented Oct 14, 2021

Thanks @atuchin-m . I looked at the hostname replacement code and that looked fine to me.

@atuchin-m
Copy link
Collaborator Author

atuchin-m commented Oct 14, 2021

Thanks @atuchin-m . I looked at the hostname replacement code and that looked fine to me.

Thanks @fmarier.
Please take into account that it doesn't redirect all the requests (only useful for us). The rest (for example google telemetry) will be banned using CSP:

browser/translate/brave_translate_utils.h Outdated Show resolved Hide resolved
browser/ui/views/frame/brave_browser_view.cc Outdated Show resolved Hide resolved
browser/ui/views/translate/brave_translate_icon_view.h Outdated Show resolved Hide resolved
browser/brave_browser_main_parts.cc Outdated Show resolved Hide resolved
components/translate/core/browser/BUILD.gn Outdated Show resolved Hide resolved
@atuchin-m atuchin-m force-pushed the enable-internal-translate-engine branch from 1c72220 to 4c8281d Compare October 18, 2021 14:00
@atuchin-m
Copy link
Collaborator Author

@simonhong @yrliou @iefremov PTAL

Copy link
Member

@simonhong simonhong left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

views: ++ (not familiar with other core translate part)

@atuchin-m atuchin-m force-pushed the enable-internal-translate-engine branch from 38ce417 to 2c6a5e8 Compare October 20, 2021 06:24
@atuchin-m atuchin-m merged commit 293c569 into master Oct 20, 2021
@atuchin-m atuchin-m deleted the enable-internal-translate-engine branch October 20, 2021 13:26
@atuchin-m atuchin-m added this to the 1.33.x - Nightly milestone Oct 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants