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

Rewards check includes #25685

Merged
merged 12 commits into from
Sep 23, 2024
Merged

Rewards check includes #25685

merged 12 commits into from
Sep 23, 2024

Conversation

bridiver
Copy link
Collaborator

@bridiver bridiver commented Sep 21, 2024

Resolves brave/brave-browser#10618

Submitter Checklist:

  • I confirm that no security/privacy review is needed and no other type of reviews are needed, or that I have requested them
  • There is a ticket for my issue
  • Used Github auto-closing keywords in the PR description above
  • Wrote a good PR/commit description
  • Squashed any review feedback or "fixup" commits before merge, so that history is a record of what happened in the repo, not your PR
  • Added appropriate labels (QA/Yes or QA/No; release-notes/include or release-notes/exclude; OS/...) to the associated issue
  • Checked the PR locally:
    • npm run test -- brave_browser_tests, npm run test -- brave_unit_tests wiki
    • npm run presubmit wiki, npm run gn_check, npm run tslint
  • Ran git rebase master (if needed)

Reviewer Checklist:

  • A security review is not needed, or a link to one is included in the PR description
  • New files have MPL-2.0 license header
  • Adequate test coverage exists to prevent regressions
  • Major classes, functions and non-trivial code blocks are well-commented
  • Changes in component dependencies are properly reflected in gn
  • Code follows the style guide
  • Test plan is specified in PR before merging

After-merge Checklist:

Test Plan:

@bridiver bridiver requested review from a team as code owners September 21, 2024 22:35
@bridiver bridiver changed the base branch from master to rewards_api_deps September 21, 2024 22:36
Base automatically changed from rewards_api_deps to master September 22, 2024 13:16
Copy link
Collaborator

@zenparsing zenparsing left a comment

Choose a reason for hiding this comment

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

This is great - thanks!

#include "chrome/browser/ui/tabs/tab_strip_model.h"
#endif

namespace brave_rewards {

#if !BUILDFLAG(IS_ANDROID)
class BraveBrowserListObserver : public BrowserListObserver {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Up to you, but since this is only used within the tab helper, it could be a nested class or be given a more specific name.

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 wasn't really sure what to call it, but I'm open to suggestions

source_set("brave_rewards") {
sources = [
"//brave/browser/brave_rewards/rewards_service_factory.h",
"//brave/browser/brave_rewards/rewards_tab_helper.h",
Copy link
Member

Choose a reason for hiding this comment

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

nit: consider fixing these paths to be local in all new targets you introduce in this PR:

    "rewards_service_factory.h",
    "rewards_tab_helper.h",

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, yep, copy-pasted the list and forgot to remove the full paths

}

private:
raw_ptr<RewardsTabHelper> tab_helper_; // Not owned.
Copy link
Member

Choose a reason for hiding this comment

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

const all constructor-initialized pointers to trigger compile errors if initialization is missing.

source_set("brave_rewards_source") {
sources = [
"webui/brave_rewards_source.cc",
"webui/brave_rewards_source.h",
Copy link
Member

Choose a reason for hiding this comment

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

there's ui/webui/brave_rewards dir. Would be nice to move this into it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

trying to avoid any changes that aren't necessary here because it already touches a lot of stuff

Copy link
Contributor

[puLL-Merge] - brave/brave-core@25685

Here's my review of the pull request:

Description

This PR refactors the Brave Rewards service implementation to reduce dependencies and improve modularity. The main changes include:

  1. Decoupling RewardsServiceImpl from Profile, using more specific dependencies instead.
  2. Restructuring the build files to separate the Brave Rewards implementation from its interfaces.
  3. Cleaning up include statements and removing unused dependencies.
  4. Adjusting tests to work with the new RewardsServiceImpl constructor.
Changes

Changes

browser/brave_rewards/BUILD.gn

  • Added new source sets for brave_rewards and brave_rewards_impl.
  • Moved sources from sources.gni into these new source sets.
  • Added conditional compilation for Greaselion and extensions support.

browser/brave_rewards/rewards_service_factory.cc

  • Updated RewardsServiceImpl constructor call to use specific services instead of Profile.
  • Added FaviconService and BitmapFetcherService as dependencies.

browser/brave_rewards/rewards_tab_helper.cc and .h

  • Introduced BraveBrowserListObserver to handle browser list observations.

browser/greaselion/BUILD.gn

  • Created a new BUILD.gn file for the Greaselion component.

browser/sources.gni

  • Removed references to brave_rewards_sources and greaselion_sources.
  • Added reference to new Brave Rewards Android sources.

browser/ui/BUILD.gn

  • Created a new source set for brave_rewards_source.

components/brave_rewards/browser/BUILD.gn

  • Updated dependencies and removed unnecessary public_deps.

components/brave_rewards/browser/rewards_service_impl.cc and .h

  • Refactored constructor to take specific services instead of Profile.
  • Replaced profile_ member with individual service members.
  • Updated methods to use the new service members instead of accessing through profile_.

components/brave_rewards/browser/rewards_service_impl_unittest.cc and rewards_service_impl_jp_unittest.cc

  • Updated test setup to use the new RewardsServiceImpl constructor.

Possible Issues

  • The refactoring might have introduced subtle changes in behavior due to the different way services are now accessed. Thorough testing of all Brave Rewards functionality is recommended.

Security Hotspots

No significant security issues were identified in this change.

Overall, this refactoring appears to be a positive change that improves the modularity and testability of the Brave Rewards service. It reduces coupling with the Profile class and makes dependencies more explicit, which should make the code easier to maintain and extend in the future.

Copy link
Member

@fmarier fmarier left a comment

Choose a reason for hiding this comment

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

browser/tor/test/BUILD.gn change 👍

@bridiver bridiver merged commit 2e85065 into master Sep 23, 2024
17 checks passed
@bridiver bridiver deleted the rewards_check_includes branch September 23, 2024 21:07
@github-actions github-actions bot added this to the 1.72.x - Nightly milestone Sep 23, 2024
"//brave/components/resources",
"//brave/components/services/bat_rewards/public/interfaces",
"//brave/components/time_period_storage",
"//chrome/browser/bitmap_fetcher", # bad
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

oops, I totally missed this before I merged it. Need to fix this one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Desktop] Fix deps in //brave/components/brave_rewards/browser/*
5 participants