-
Notifications
You must be signed in to change notification settings - Fork 901
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
Add about:welcome, add about:adblock, refactor about:payments WebUI #186
Conversation
url.host_piece() == chrome::kChromeUINewTabHost) { | ||
return &NewWebUI<BasicUI>; | ||
} else if (url.spec() == kWelcomeRemoteURL) { | ||
} else if (url.spec() == kBraveUIWelcomeURL) { |
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 if clauses isn't used anymore because of above url.host_piece() == kWelcomeHost
.
Does BraveWelcomeUIBrowserTest.StartupURLTest pass?
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 assume you didn't try to browser test yet.
You need to replace kWelcomeRemoteURL
with kBraveUIWelcomeURL
in the test code.
Sorry, you already changed it.
To pass the test, logic in BraveWelcomeUI::BraveWelcomeUI()
should be used.
How about make BraveWelcomeUI
inherit BasicUI
and use it for url.host_piece() == kWelcomeHost
?
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 tested this PR on my local machine.
First, BraveWelcomeUIBrowserTest
was failed in PRE_StartupURLTest
because actual url isn't same askBraveUIWelcomeURL
.
The reason is reverse handler(HandleURLReverseRewrite
) isn't working properly.
If reverse handler doesn't return true, virtual url is not updated with our ones.
Because of this, virtual url of tab at 0 index in test browser was different.
To fix this, kBraveUIWelcomeURL
should be chrome://welcome/
not chrome://welcome
. (url.spec()
is chrome://welcome/
). Or checking like above newtab seems better instead of comparing whole url.
When run test again, test will be failed in StartupURLTest
because prefs::kHasSeenWelcomePage
and prefs::kHasSeenWin10PromoPage
isn't set properly.
If these prefs are not updated, browser always create welcome ui tab at startup.
It was handled in ctor of BraveWelcomeUI
.
So, I recommend that making BraveWelcomeUI as a subclass of BasicUI
and use it.
Also you can revert this PR - #153. |
Re-added WIP label and title based on last review comments, please remove and re-ping once it is ready. Thank you! |
ea75eea
to
a6ff0ed
Compare
f295afa
to
071e7e3
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.
I think most of comments are trivial.
Feel free to merge after addressing nits.
browser/ui/BUILD.gn
Outdated
"webui/brave_web_ui_controller_factory.cc", | ||
"webui/brave_web_ui_controller_factory.h", | ||
"webui/brave_welcome_ui.cc", | ||
"webui/brave_welcome_ui.h", | ||
"webui/new_tab_html_source.cc", | ||
"webui/new_tab_html_source.h", | ||
"webui/brave_webui_source.cc", |
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: order
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.
fixed.
browser/ui/webui/brave_new_tab_ui.cc
Outdated
} | ||
|
||
BraveNewTabUI::~BraveNewTabUI() { | ||
pref_change_registrar_.reset(); |
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.
You don't need to call unique_ptr's reset()
explicitly here.
dtor will destroy it implicitly and then it will destroy its managed object.
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.
Fixed.
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | ||
void OnPreferenceChanged(); | ||
|
||
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
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.
If the lifetime of object member is same with this class, do we have to use |unique_ptr|?
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.
per above, same as for reasons of forward declaring only. Will leave it.
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.
Ok
|
||
#include "brave/browser/ui/webui/brave_webui_source.h" | ||
|
||
#include <string> |
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.
can be removed because header file did it already.
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.
Fixed.
@@ -2,11 +2,11 @@ | |||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | |||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | |||
|
|||
#include <string> |
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.
Header guard is omitted.
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.
Fixed.
browser/ui/webui/brave_welcome_ui.h
Outdated
public: | ||
explicit BraveWelcomeUI(content::WebUI* web_ui); | ||
explicit BraveWelcomeUI(content::WebUI* web_ui, const std::string& host); |
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.
explicit keyword can be removed
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.
Fixed.
browser/ui/webui/brave_rewards_ui.h
Outdated
|
||
class BraveRewardsUI : public BasicUI { | ||
public: | ||
explicit BraveRewardsUI(content::WebUI* web_ui, const std::string& host); |
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.
We don't need to use explicit
keyword for ctor that has more than one parameter.
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.
oops left over from copying from somewhere. Fixed.
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.
@simonhong although not needed here I agree and removed, but just noting that it can still be used with multiple params: https://stackoverflow.com/a/39122237
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.
Oh.. I didn't think about initializer-list. Thanks for checking this!
browser/ui/webui/brave_adblock_ui.h
Outdated
|
||
class BraveAdblockUI : public BasicUI { | ||
public: | ||
explicit BraveAdblockUI(content::WebUI* web_ui, const std::string& host); |
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.
ditto
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | ||
void OnPreferenceChanged(); | ||
|
||
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
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.
ditto
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 going to keep this as std::unique_ptr
because then it can be forward declared. I see a lot of instances in chromium source in both ways. I will remove the destructor explicit reset though which I agree isn't needed.
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.
Agreed
browser/ui/webui/brave_adblock_ui.cc
Outdated
} | ||
|
||
BraveAdblockUI::~BraveAdblockUI() { | ||
pref_change_registrar_.reset(); |
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.
ditto
- adds basic UI handler for welcome page without usable UI while design finish the new spec for the page - address brave/brave-browser#276 test plan: npm run test -- brave_browser_tests --filter=BraveWelcomeUIBrowserTest.*
BasicUI had some things only specific to the new-tab in it. This change makes it so the custom things for NewTabUI are in the NewTab page and makes it easier for future things to subclass BasicUI
Partially implements brave/brave-browser#267
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override; | ||
void OnPreferenceChanged(); | ||
|
||
std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
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.
Ok
Adding provider to ledger::PublisherBanner
Adding provider to ledger::PublisherBanner
…ader Add loader to welcome page
adds basic UI handler for welcome page without usable UI while design finish the new spec for the page
address brave/brave-browser#276
Test Plan: