-
Notifications
You must be signed in to change notification settings - Fork 879
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
Offer google translate installation in translate bubbles #3103
Conversation
42ccc16
to
0657843
Compare
…ogle Translate extension.
…d of patching TranslateService::IsTranslatableURL.
…mpt setting in all channels.
0657843
to
78dc52a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, works as described.
#endif | ||
|
||
private: | ||
#if !BUILDFLAG(ENABLE_BRAVE_TRANSLATE) && BUILDFLAG(ENABLE_EXTENSIONS) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want ENABLE_EXTENSIONS
here. If translate is dependent on extensions then we should set enable_brave_translate = enable_extensions
in gn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
separate the build flags in 6acee43
void BraveTranslateBubbleView::Init() { | ||
TranslateBubbleView::Init(); | ||
RemoveChildView(before_translate_view_); | ||
before_translate_view_ = AddChildView(BraveCreateViewBeforeTranslate()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is going to fail on android because it has a guard above
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems like in general this needs to work differently for android
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this google extension approach won't work in android unless we have extensions supported, so this code block shouldn't be built on android atm.
std::unique_ptr<TranslateBubbleModel> model( | ||
new TranslateBubbleModelImpl(step, std::move(ui_delegate))); | ||
- TranslateBubbleView* view = new TranslateBubbleView( | ||
+ TranslateBubbleView* view = new BraveTranslateBubbleView( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rather than change this line, I think it's better to add BRAVE_SHOW_BUBBLE_ after it. Then if ENABLE_BRAVE_TRANSLATE is false
BRAVE_SHOW_BUBBLE_
does nothing. If it's true then it replaces view
with BraveTranslateBubbleView. This also eliminates all the guards inside BraveTranslateBubbleView
and any issues with android. brave_translate_bubble_view.h/.cc should also go inside enable_brave_translate guards in gn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we keep this patch line but replace BraveTranslateBubbleView back to TranslateBubbleView in the chromium_src override instead if ENABLE_BRAVE_TRANSLATE_EXTENSION
is false?
This would also eliminates the guards inside BraveTranslateBubbleView
and guard brave_translate_bubble_view.h/.cc
inside gn.
Currently did this in 6acee43, wdyt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated as suggested in 60e70de
- Move adding Open Link with Tor into InitMenu and remove AppendBraveLinkItems - Fix bug when removing IDC_CONTENT_CONTEXT_TRANSLATE since it is not always existed - Define BRAVE_RENDER_VIEW_CONTEXT_MENU_H_ and BRAVE_TRANSLATE_BUBBLE_VIEW_H_ to be extensible in the header
bf5ab9e
to
6fb489c
Compare
private: \ | ||
friend class BraveTranslateBubbleView; \ | ||
public: | ||
class BraveTranslateBubbleView; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just for readability please leave a space after the multiline macro
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
addresses in 352251d
- Separate translate build flags for go-translate and google translate extension approaches - Guard translate_bubble_view and translate_icon_view subclasses files in gn
6acee43
to
352251d
Compare
|
||
declare_args() { | ||
enable_brave_translate = !is_release_channel | ||
enable_brave_translate_go = false | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit - you only need one declare_args section here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm actually getting below build error when doing enable_brave_translate_extension = !enable_brave_translate_go && enable_extensions
if using one declare_args.
ERROR at //brave/browser/translate/buildflags/buildflags.gni:7:39: Reading a variable defined in the same declare_args() call.
const Browser* browser = GetBrowser(); | ||
const bool is_app = browser && browser->is_app(); | ||
|
||
index = menu_model_.GetIndexOfCommandId( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @petemill - anything else she should do here? Did you find a good way to test?
return was_visible != GetVisible(); | ||
} | ||
|
||
return TranslateIconView::Update(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this right? Won't ChromeTranslateClient::FromWebContents(GetWebContents())
return nullptr in TranslateIconView::Update
? Either way does it ever make sense to call the superclass method here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It won't be nullptr when doing ChromeTranslateClient::FromWebContents(GetWebContents())
in TranslateIconView::Update
, the client still exists in our case.
What I planned to achieve here is just to behave the same way as superclass before google translate is installed, and make sure we won't still show the icon right after google translate is already installed.
@@ -0,0 +1,138 @@ | |||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should this stuff maybe be in browser/ui/views/translate/extension
?
6d0cc01
to
256b4d9
Compare
Added unit tests for translate bubble, latest CI test failure was only in win-x64's |
Offer google translate installation in translate bubbles
Using
Used the following websites:
Examples of the feature: |
Guys, is there a way to disable the offer to install the extension? I don't want to install it and it constantly pops up. |
@jost-s yes, there is 😄 Visit brave://settings/languages and click the down chevron under languages. There should be an option: We're rolling out a fix soon (today) that offers a |
@bsclifton Brilliant, cheers man! 😃 |
Fix brave/brave-browser#5561
Below is the gif of how this PR looks like and it's easier to go through each commit when reviewing.
This PR repurposed TranslateBubbleView and TranslateIconView to offer google translate installation in translate bubbles when
ENABLE_BRAVE_TRANSLATE
(go-translate) is disabled.This UI is expected to be used in all desktop channels, and the prompt of translate bubbles could be disabled through language settings by toggling
Offer to translate pages that aren't in a language you read
as below.Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Offer to translate pages that aren't in a language you read
setting in Languages -> Language.Translate to _your_language_
should not be shown in the context menu.Offer to translate pages that aren't in a language you read
setting in Languages -> Language.Reviewer Checklist:
After-merge Checklist:
changes has landed on.