-
Notifications
You must be signed in to change notification settings - Fork 872
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
Rewards check includes #25685
Changes from 2 commits
c8ef420
dbde163
5b9451a
65b9983
5280aa9
a955b51
d19a800
78956df
8ae9c76
125d86d
b86f80b
1c83d10
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,14 +21,36 @@ | |
#include "chrome/browser/ui/browser.h" | ||
#include "chrome/browser/ui/browser_finder.h" | ||
#include "chrome/browser/ui/browser_list.h" | ||
#include "chrome/browser/ui/browser_list_observer.h" | ||
#include "chrome/browser/ui/tabs/tab_strip_model.h" | ||
#endif | ||
|
||
namespace brave_rewards { | ||
|
||
#if !BUILDFLAG(IS_ANDROID) | ||
class BraveBrowserListObserver : public BrowserListObserver { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
public: | ||
explicit BraveBrowserListObserver(RewardsTabHelper* tab_helper) | ||
: tab_helper_(tab_helper) {} | ||
~BraveBrowserListObserver() override {} | ||
void OnBrowserSetLastActive(Browser* browser) override { | ||
tab_helper_->OnBrowserSetLastActive(browser); | ||
} | ||
void OnBrowserNoLongerActive(Browser* browser) override { | ||
tab_helper_->OnBrowserNoLongerActive(browser); | ||
} | ||
|
||
private: | ||
raw_ptr<RewardsTabHelper> tab_helper_; // Not owned. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
}; | ||
#endif | ||
|
||
RewardsTabHelper::RewardsTabHelper(content::WebContents* web_contents) | ||
: content::WebContentsUserData<RewardsTabHelper>(*web_contents), | ||
WebContentsObserver(web_contents), | ||
#if !BUILDFLAG(IS_ANDROID) | ||
browser_list_observer_(new BraveBrowserListObserver(this)), | ||
#endif | ||
tab_id_(sessions::SessionTabHelper::IdForTab(web_contents)) { | ||
if (tab_id_.is_valid()) { | ||
rewards_service_ = RewardsServiceFactory::GetForProfile( | ||
|
@@ -40,7 +62,7 @@ RewardsTabHelper::RewardsTabHelper(content::WebContents* web_contents) | |
} | ||
|
||
#if !BUILDFLAG(IS_ANDROID) | ||
BrowserList::AddObserver(this); | ||
BrowserList::AddObserver(browser_list_observer_.get()); | ||
#endif | ||
} | ||
|
||
|
@@ -49,7 +71,7 @@ RewardsTabHelper::~RewardsTabHelper() { | |
rewards_service_->RemoveObserver(this); | ||
} | ||
#if !BUILDFLAG(IS_ANDROID) | ||
BrowserList::RemoveObserver(this); | ||
BrowserList::RemoveObserver(browser_list_observer_.get()); | ||
#endif | ||
} | ||
|
||
|
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: consider fixing these paths to be local in all new targets you introduce in this PR:
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, yep, copy-pasted the list and forgot to remove the full paths