-
Notifications
You must be signed in to change notification settings - Fork 889
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
New Tab Page WebUI: Use Profile Preferences to store page options instead of localStorage #2831
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.
C++ looks good to me with trivial nits. 👍
Will toss other changes to FE experts.
public: | ||
explicit BraveNewTabMessageHandler(BraveNewTabUI* web_ui); | ||
~BraveNewTabMessageHandler() override; | ||
void OnStatsChanged(); |
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: These three callback methods can be in private section.
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 spotting, this is fixed now. It was left over from a previous strategy.
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.
Code looks great (see nits by @simonhong) - I verified the functionality works as expected and even cracked open the Default/Preferences
file to verify the new setting by hand
Really nice work on this one! 😻
There is a browser test failure 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.
left some code comments
… MessageHandler Following best practices from chromium webui documentation, move towards using DataSource keys for the initial page data, and FireWebUIListener for updating data. We're still manually setting data on the render_host in the WebUIController, but this refactor allows us to use FireWebUIListener now, and move towards using DataSource for that data in the future. MessageHandler allows us to use an established JS lifecycle to ensure that data is only sent to the correct contexts at the correct time. Use FireWebUIListener for 'stats-updated' instead of expecting a global 'statsUpdated' function to exist (which was causing some JS errors).
…tead of localStorage This allows: - Surfacing these preferences outside of the NTP - Syncing / migrating the preferences - Making the change immediately for all open NTP Use FireWebUIListener to push data to javascript event subscribers. Still uses render_view_host->SetWebUIProperty (like the existing NTP data), which we may port in the future to a DataSource Dictionary like the other WebUI in chromium. Provides any data retreived or updated to redux store via redux action, but does not use redux actions to ask for a data change. Fix brave/brave-browser#5064
I guess this also fixes brave/brave-browser#2848 since the static global function call |
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.
++
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.
nailed it. +1000
This follow-up is required along with this PR:
Fix brave/brave-browser#5064
Fix brave/brave-browser#2848
This is created as a PR on top of master and does not include the extra preferences from #2762 since it has not been merged yet.
This allows:
Use FireWebUIListener to push data to javascript event subscribers.
Still uses render_view_host->SetWebUIProperty (like the existing NTP data), which we may port in the future to a DataSource Dictionary like the other WebUI in chromium.
Provides any data retrieved or updated to redux store via redux action, but does not use redux actions to ask for a data change.
Also includes
Refactor NTP WebUI backend
Focus on the MessageHandler in order to use FireWebUIListener and follow chromium best practice for setting data and events
TS types for NTP actions
Small change for intellisense™ and action parameter type checking
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Default/Preferences
file and look forbrave.new_tab_page.show_background_image
and either true/false (depending on what you set in the UI)Reviewer Checklist:
After-merge Checklist:
changes has landed on.