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

Add about:welcome, add about:adblock, refactor about:payments WebUI #186

Merged
merged 10 commits into from Jul 5, 2018

Conversation

cezaraugusto
Copy link
Contributor

@cezaraugusto cezaraugusto commented Jun 22, 2018

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.*

screen shot 2018-06-21 at 5 31 52 pm

@cezaraugusto cezaraugusto self-assigned this Jun 22, 2018
@cezaraugusto cezaraugusto requested a review from bbondy June 22, 2018 01:11
url.host_piece() == chrome::kChromeUINewTabHost) {
return &NewWebUI<BasicUI>;
} else if (url.spec() == kWelcomeRemoteURL) {
} else if (url.spec() == kBraveUIWelcomeURL) {
Copy link
Member

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?

Copy link
Member

@simonhong simonhong Jun 22, 2018

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?

Copy link
Member

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.

@simonhong
Copy link
Member

Also you can revert this PR - #153.

@bbondy bbondy changed the title add about:welcome and webui handler WIP: add about:welcome and webui handler Jun 25, 2018
@bbondy
Copy link
Member

bbondy commented Jun 25, 2018

Re-added WIP label and title based on last review comments, please remove and re-ping once it is ready. Thank you!

@bbondy bbondy force-pushed the welcome/webui branch 2 times, most recently from ea75eea to a6ff0ed Compare July 4, 2018 17:05
@bbondy bbondy changed the title WIP: add about:welcome and webui handler Add about:welcome, add about:adblock, refactor about:payments WebUI Jul 4, 2018
@bbondy bbondy force-pushed the welcome/webui branch 2 times, most recently from f295afa to 071e7e3 Compare July 5, 2018 01:52
@bbondy bbondy self-assigned this Jul 5, 2018
simonhong
simonhong previously approved these changes Jul 5, 2018
Copy link
Member

@simonhong simonhong left a 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.

"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",
Copy link
Member

Choose a reason for hiding this comment

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

nit: order

Copy link
Member

Choose a reason for hiding this comment

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

fixed.

}

BraveNewTabUI::~BraveNewTabUI() {
pref_change_registrar_.reset();
Copy link
Member

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.

Copy link
Member

@bbondy bbondy Jul 5, 2018

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_;
Copy link
Member

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|?

Copy link
Member

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.

Copy link
Member

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>
Copy link
Member

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.

Copy link
Member

@bbondy bbondy Jul 5, 2018

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>
Copy link
Member

Choose a reason for hiding this comment

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

Header guard is omitted.

Copy link
Member

Choose a reason for hiding this comment

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

Fixed.

public:
explicit BraveWelcomeUI(content::WebUI* web_ui);
explicit BraveWelcomeUI(content::WebUI* web_ui, const std::string& host);
Copy link
Member

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

Copy link
Member

Choose a reason for hiding this comment

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

Fixed.


class BraveRewardsUI : public BasicUI {
public:
explicit BraveRewardsUI(content::WebUI* web_ui, const std::string& host);
Copy link
Member

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.

Copy link
Member

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.

Copy link
Member

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

Copy link
Member

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!


class BraveAdblockUI : public BasicUI {
public:
explicit BraveAdblockUI(content::WebUI* web_ui, const std::string& host);
Copy link
Member

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_;
Copy link
Member

Choose a reason for hiding this comment

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

ditto

Copy link
Member

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.

Copy link
Member

Choose a reason for hiding this comment

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

Agreed

}

BraveAdblockUI::~BraveAdblockUI() {
pref_change_registrar_.reset();
Copy link
Member

Choose a reason for hiding this comment

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

ditto

cezaraugusto and others added 9 commits July 5, 2018 10:15
-
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
void RenderFrameCreated(content::RenderFrameHost* render_frame_host) override;
void OnPreferenceChanged();

std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
Copy link
Member

Choose a reason for hiding this comment

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

Ok

@bbondy bbondy merged commit 4f6afa8 into master Jul 5, 2018
@cezaraugusto cezaraugusto deleted the welcome/webui branch July 9, 2018 13:47
NejcZdovc pushed a commit that referenced this pull request Dec 10, 2018
Adding provider to ledger::PublisherBanner
NejcZdovc pushed a commit that referenced this pull request Dec 11, 2018
Adding provider to ledger::PublisherBanner
cezaraugusto pushed a commit that referenced this pull request Jul 17, 2019
NejcZdovc added a commit that referenced this pull request Sep 18, 2019
NejcZdovc added a commit that referenced this pull request Sep 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants