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

Fixes hover card bubble chrome:// urls. #3687

Merged
merged 1 commit into from
Oct 17, 2019

Conversation

mkarolin
Copy link
Collaborator

@mkarolin mkarolin commented Oct 12, 2019

Fixes brave/brave-browser#6385

Replaces chrome:// scheme with brave://.

Submitter Checklist:

Test Plan:

  1. Start Brave.
  2. Navigate to brave://settings.
  3. Hover mouse over the tab.
  4. Observe popup showing the title Settings and subtitle brave://settings

Reviewer Checklist:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

After-merge Checklist:

  • The associated issue milestone is set to the smallest version that the
    changes has landed on.
  • All relevant documentation has been updated.

@mkarolin mkarolin added this to the 0.72.x - Nightly milestone Oct 12, 2019
@mkarolin mkarolin self-assigned this Oct 12, 2019
@bsclifton
Copy link
Member

Tested this on macOS; works great! 😄

@mkarolin mkarolin force-pushed the maxk-fix-hover-card-bubble-2 branch from 74b2012 to 3ebf237 Compare October 12, 2019 16:10
@mkarolin mkarolin changed the title Fixes hover card bubble chrome:// urls. WIP: Fixes hover card bubble chrome:// urls. Oct 12, 2019
@mkarolin mkarolin marked this pull request as ready for review October 12, 2019 16:35
@mkarolin mkarolin requested a review from bridiver as a code owner October 12, 2019 16:35
@mkarolin mkarolin force-pushed the maxk-fix-hover-card-bubble-2 branch 2 times, most recently from 232e25d to 14bae84 Compare October 13, 2019 00:31
@mkarolin
Copy link
Collaborator Author

CI failures are in lint and an unrelated browser test.

@mkarolin mkarolin changed the title WIP: Fixes hover card bubble chrome:// urls. Fixes hover card bubble chrome:// urls. Oct 14, 2019
Copy link
Member

@bsclifton bsclifton left a comment

Choose a reason for hiding this comment

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

LGTM! 😄

#define BRAVE_TAB_HOVER_CARD_BUBBLE_VIEW_H_ \
\
protected: \
class BraveAnonymous; \
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'm not understanding what is happening here. Why are we creating an inner class that just has a single static method? Why do we need a class here at all?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I am using an inner class here because inner classes have access to private members.
Because I am redefining TabHoverCardBubbleView as TabHoverCardBubbleView_ChromiumImpl (and then declaring the subclass as TabHoverCardBubbleView) I can't add a friend class TabHoverCardBubbleView.

};

void TabHoverCardBubbleView::UpdateCardContent(const Tab* tab) {
TabHoverCardBubbleView_ChromiumImpl::BraveAnonymous::UpdateCardContent(
Copy link
Collaborator

Choose a reason for hiding this comment

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

re https://github.com/brave/brave-core/pull/3687/files#r335575232 - why aren't we just directly calling the code in TabHoverCardBubbleView_ChromiumImpl::BraveAnonymous::UpdateCardContent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Similarly here, I am going through the inner class method to get to the private members of the base class (because I couldn't make the subclass a friend with this approach).

Copy link
Collaborator

@bridiver bridiver Oct 16, 2019

Choose a reason for hiding this comment

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

why rename it? Wouldn't it be simpler to subclass/friend and override in tab_strip.cc? You need a patch in TabHoverCardBubbleView either way and it would be simpler to understand imo

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Mainly was just trying out a way to make changes without having to patch tab_strip.cc.

Copy link
Collaborator

Choose a reason for hiding this comment

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

you wouldn't have to patch tab_strip.cc, you can change the class name with a chromium_src override

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but with TabHoverCardBubbleView, tab_strip.cc:126 also has
TabHoverCardEventSniffer(TabHoverCardBubbleView* hover_card, TabStrip* tab_strip)
which would get redefined.

Copy link
Collaborator

Choose a reason for hiding this comment

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

why does that matter? I saw it, but maybe I'm missing something?

Copy link
Collaborator

Choose a reason for hiding this comment

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

ok, I see why it matters (TabHoverCardBubbleView* hover_card_ = nullptr;) in the header, but can't you just override in the header as well?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I mean, what you have works, it's just harder to follow because it's very different from what we would normally do in this case. If we can subclass and override I think it would be better for long-term maintenance

Copy link
Collaborator

Choose a reason for hiding this comment

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

or if we went this route, wouldn't it be simpler to just directly patch in a method to TabHoverCardBubbleView_ChromiumImpl instead of creating an inner class?

private:

#define TabHoverCardBubbleView TabHoverCardBubbleView_ChromiumImpl
#define UpdateCardContent virtual UpdateCardContent
Copy link
Collaborator

Choose a reason for hiding this comment

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

this could be used to get rid of a lot of other patches for virtual. I didn't realize it was valid to have void virtual Method(...) cc @bbondy

Copy link
Collaborator

Choose a reason for hiding this comment

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

@mkarolin please take advantage of this when doing chromium updates for existing patches using virtual

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, you can have virtual after the return type as long as the return type is not a pointer or a reference. If they are then you need to have A virtual *function, which doesn't help us.

Copy link
Collaborator

Choose a reason for hiding this comment

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

that's the case even though the standard for chromium code is T* function()? Shouldn't the preprocessor replacement work correctly for that?

@mkarolin mkarolin force-pushed the maxk-fix-hover-card-bubble-2 branch 3 times, most recently from af7ec45 to 3dbda8d Compare October 16, 2019 22:22
@mkarolin mkarolin added CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS CI/skip-linux and removed CI/skip-android Do not run CI builds for Android CI/skip-ios Do not run CI builds for iOS labels Oct 17, 2019
Fixes brave/brave-browser#6385

Replaces chrome:// scheme with brave:// in the hover card text.
Added a browser test to test the same.

Also, organized brave_browser_tests sources alphabetically in
test/BUILD.gn.
@mkarolin mkarolin force-pushed the maxk-fix-hover-card-bubble-2 branch from 3dbda8d to defda68 Compare October 17, 2019 16:25
@mkarolin
Copy link
Collaborator Author

CI fails in an unrelated unit test.

@mkarolin mkarolin merged commit 8f02f5c into master Oct 17, 2019
@mkarolin mkarolin deleted the maxk-fix-hover-card-bubble-2 branch October 17, 2019 18:48
mkarolin added a commit that referenced this pull request Oct 17, 2019
Fixes hover card bubble chrome:// urls.
mkarolin added a commit that referenced this pull request Oct 17, 2019
Fixes hover card bubble chrome:// urls.
mkarolin added a commit that referenced this pull request Oct 17, 2019
Fixes hover card bubble chrome:// urls.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hover card shows chrome:// on brave:// pages (C78)
4 participants