-
Notifications
You must be signed in to change notification settings - Fork 894
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
Adds WebUI handler for Android AI #20129
Conversation
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 is great but as of #20068 we no longer observe the TabStripModel and no longer need to change active / target WebContents. All platforms will now only observe 1 WebContents at a time when opened.
So I think we can simplify this - make the same AIChatUIPageHandler
implementation for both platforms, and have it accept a single target WebContents in the ctor. AIChatUI
can select the currently active target WebContents
per-platform (L91) - tab_strip_model->GetActiveWebContents()
for desktop and your specific GetActiveWebContents
for android.
What do you think?
ok, sounds good, going to do it that way in that case. |
f8a296f
to
dc3c53b
Compare
@petemill I re-made it following the new code requirements, it's good for another review round. |
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.
Thanks for re-working. Just some minor feedback and this looks great
web_ui()->GetWebContents()) != TabStripModel::kNoTab; | ||
#else | ||
web_contents = GetActiveWebContents(profile_); | ||
is_standalone = web_contents == nullptr; |
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.
Shouldn't the is_standalone
for both platforms be based on whether this WebUI is the active Tab vs a separate WebContents, i.e. for both platforms:
is_standalone = web_contends !== web_ui->GetWebContents()
?
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.
yeah perhaps it's better to do that way for the feature standalone option on 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.
actually that's not right as web_contents
is the current page contents vs web_ui->GetWebContents()
is an actual web ui with the chat contents. So I think Android detection is correct it means we have a chat opened only if we don't have an active tab and the web ui, but for desktop I'm not sure exactly what do we check there, we are looking for an index of the chat web ui and we assume it's not a standalone if we found it. As to me the check should be
is_standalone = web_contents == web_ui->GetWebContents();
@@ -41,7 +44,9 @@ class AIChatUI : public ui::UntrustedWebUIController { | |||
|
|||
base::WeakPtr<ui::MojoBubbleWebUIController::Embedder> embedder_; | |||
raw_ptr<Profile> profile_ = nullptr; | |||
#if !BUILDFLAG(IS_ANDROID) | |||
raw_ptr<Browser> browser_ = nullptr; |
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 need browser_
for either platform now
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.
yeah I noticed that also about the member, I just didn't remove as thought we kept it for some feature interaction. I will remove it.
public AIChatTabHelper::Observer, | ||
public content::WebContentsObserver { | ||
public: | ||
AIChatUIPageHandler( | ||
content::WebContents* owner_web_contents, | ||
TabStripModel* tab_strip_model, | ||
bool is_standalone, | ||
content::WebContents* web_contents, |
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: perhaps a more specific name, e.g. chat_context_web_contents
?
public AIChatTabHelper::Observer, | ||
public content::WebContentsObserver { | ||
public: | ||
AIChatUIPageHandler( | ||
content::WebContents* owner_web_contents, | ||
TabStripModel* tab_strip_model, | ||
bool is_standalone, |
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 wonder if we even need is_standalone
? Perhaps consumer just passes nullptr
for the WebContents
param?
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.
yeah it could be detected that way, I will change it
dc3c53b
to
a293c5b
Compare
@petemill it's good for another review round. |
a293c5b
to
e897f71
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.
👍
bool is_visible = | ||
(web_contents->GetVisibility() == content::Visibility::VISIBLE) ? true | ||
: false; | ||
bool is_visible = (chat_context_web_contents->GetVisibility() == |
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.
That's strange, this is meant to check visibility of owner_web_contents
. I guess it's an existing bug, but if you have to make any other changes to this PR then please change it. But it's fine to leave it and we'll fix it separately.
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.
security gtg
Resolves brave/brave-browser#32808
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
wikinpm run lint
,npm run presubmit
wiki,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan: