Commit d46a6643 authored by Orin Jaworski's avatar Orin Jaworski Committed by Commit Bot

[omnibox] Fix translate page Pedal sometimes not prompting

This CL causes the translation prompt to show when triggered from
an omnibox Pedal, even when the page is in user's primary language.
The language state logic usually prevents it, but in the case of
Pedal activation, the user is explicitly requesting translation.

Bug: 893183
Change-Id: Id3e99268a759d97dd148b5ddb2d32f36d5f51a3f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2350230
Commit-Queue: Orin Jaworski <orinj@chromium.org>
Reviewed-by: default avatarmanuk hovanesian <manukh@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797033}
parent 410b0463
......@@ -400,12 +400,16 @@ void ChromeOmniboxClient::PromptPageTranslation() {
ChromeTranslateClient* translate_client =
ChromeTranslateClient::FromWebContents(contents);
if (translate_client) {
const translate::LanguageState& state =
translate_client->GetLanguageState();
translate::LanguageState& state = translate_client->GetLanguageState();
const std::string original_language = state.original_language();
// Since the user is explicitly requesting the translation prompt, here
// we invalidate state that prevents prompt in some other circumstances.
state.SetTranslateEnabled(true);
state.LanguageDetermined("", true);
// Here we pass triggered_from_menu as true because that is meant to
// capture whether the user explicitly requested the translation.
translate_client->ShowTranslateUI(
translate::TRANSLATE_STEP_BEFORE_TRANSLATE, state.original_language(),
translate::TRANSLATE_STEP_BEFORE_TRANSLATE, original_language,
state.AutoTranslateTo(), translate::TranslateErrors::NONE,
/*triggered_from_menu=*/true);
}
......
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