-
Notifications
You must be signed in to change notification settings - Fork 871
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
Donate dialog #556
Donate dialog #556
Conversation
I suggest we work together on this branch @NejcZdovc. There's work to do on two fronts:
Alternatively, we could get this PR merge-able by removing the code path to show the dialog, and then work in two subsequent PRs for the above issues. cc @bbondy @bridiver (to review the correct BrowserContext is being used) and @bsclifton @simonhong for feedback |
5c19e6b
to
0ef702d
Compare
6a87038
to
3c3a635
Compare
7608b93
to
2a62cb5
Compare
I've had no luck with some design ambitions here:
For now I've set the popup to be a fixed [window width - 25px] x 500px, so it looks similar to other popups (Print Preview..., Cast...). Alternative would be to change to autosize and have the height manually set in the html. |
Scratch that last point - I've got the auto-size working with some adjustments to the html content. Still doesn't resize when the window resizes, but I'm ok with that for now. |
… instead of fixed position as per brave/brave-core#556
… instead of fixed position as per brave/brave-core#556
b4704ed
to
9508bb5
Compare
} | ||
result.SetDictionary("social", std::move(social)); | ||
|
||
web_ui()->CallJavascriptFunctionUnsafe("brave_rewards_donate.publisherBanner", result); |
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.
- Use
CallJavascriptFunction
instead?
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 forgot why, but CallJavascriptFunction
was not working. cc @bbondy if you can remember
we currently use CallJavascriptFunctionUnsafe
across all our webui logic
publisherKey: string | ||
title: string | ||
description: string | ||
background: 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.
Is the publisher background and logo stored locally?
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.
no, we get it from publisher API. Example of the url https://rewards-stg.bravesoftware.com/P5RxjtP44tJnVNeR9nNCLmgX
. In this PR we have both of them disabled and we will fix this in the follow up, because you can't do requests outside from webui
} | ||
|
||
void RewardsDonateDOMHandler::Init() { | ||
Profile* profile = Profile::FromWebUI(web_ui()); |
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.
as @jumde mentioned the UI should be disabled if RewardsServiceFactory::GetForProfile is null. Any menu items should similarly be disabled
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.
Didn't see an obvious quick way to disable after the DomHandler::Init phase, so I disabled via the webui constructor, checking IsOffTheRecord
. Shows chrome://network-error for now
const base::FilePath::StringType kPublisher_state("publisher_state"); | ||
const base::FilePath::StringType kPublisher_info_db("publisher_info_db"); | ||
const base::FilePath::StringType kPublishers_list("publishers_list"); | ||
const base::FilePath::StringType kPublisher_state("publisher_state"); |
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.
why are these indented 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.
fixed
const char kBraveNewTabJS[] = "brave_new_tab.js"; | ||
const char kBraveUIWelcomeURL[] = "chrome://welcome/"; | ||
const char kBraveUIRewardsURL[] = "chrome://rewards/"; | ||
const char kBraveUIAdblockURL[] = "chrome://adblock/"; | ||
const char kBraveUIDonateURL[] = "chrome://donate/"; |
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.
is direct navigation to chrome://donate
expected?
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.
Is there an easy way to block this? Right now it errors because it doesn't get any JSON input args, and displays fallback copy. Either way, I talked with @NejcZdovc and we'll make sure the webui doesn't display anything if navigated to in a tab.
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.
cc: @bridiver ^
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.
For now, it's only possible in non-OffTheRecord profiles and is non-functional
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.e. I blocked it
7964203
to
e2a65f4
Compare
Use ConstrainedWebDialogUI instead of regular WebUI in order to gain message passing for incoming arguments and dialog-closing function. Stub content for demonstration - to be replaced with content from brave-ui.
Expose `donateToSite` to `chrome.braveRewards` which accepts tabId and publisherKey Pass publisherKey to chrome://donate WebUI page Read publisher key in donate JS and write to html output
11cc346
to
699f6c3
Compare
252b660
to
2955b14
Compare
2955b14
to
3151f55
Compare
Includes tests
3151f55
to
f190808
Compare
…eight with normal DOM layout flow instead of fixed position as per #556
Resolves brave/brave-browser#924
TODO
chrome://donate
rest of height of content area should have semi-transparent overlay. For now I've given the dialog some x and y margin so that it doesn't appear to have replaced the tab contents.y coordinate of dialog should be at content top (at the moment it's just below LocationBar)Close donate dialog when ESC is pressedBug: Dialog is opened twice resulting in dialog re-opening once when first closedwill be fixed in brave-ui Button click handlers are running twice brave-ui#197More of the features should be supported for brave/brave-browser#1221 although not all are required for this Donate dialog, which has a closer milestone than the Tipping dialog
Current state
Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist: