-
Notifications
You must be signed in to change notification settings - Fork 885
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
Issue 8341: Add the default search engine metric. #4771
Conversation
@bridiver @simonhong ready for review |
@@ -47,7 +48,7 @@ KeyedService* InitializeSearchEngineProviderServiceIfNeeded(Profile* profile) { | |||
return new PrivateWindowSearchEngineProviderService(profile); | |||
} | |||
|
|||
return nullptr; | |||
return new DefaultSearchEngineProviderService(profile); |
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.
Hmm, using |profile| could make confusing.
So far, SearchEngineProviderService
and its subclasses are instantiated with otr profile because they are only used for otr profile. and all implementation assumes it's otr profile.
How about introducing new service instead of subclassing SearchEngineProviderService
?
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.
Yeah, that's a good point, I was thinking about it, but decided that observing a single data point doesn't worth creating a whole new service :) If you feel like writing a separate one is more clear, I will do that
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.
actually, passing normal profile doesn't cause any side effect because you're only using original_template_url_service_
. Or, how about adding some comments?
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.
Hmm, I think this service factory is not a proper place to get default search engine metric because this service was intended only for handling default search engine of non-normal profile.
but you only want normal profile's default search engine changing.
If we don't have yet, I think general-purpose service seems fine for logging metric if there is no good point for. WDYT?
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.
Or just using different service with this factory. is it strange?
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 I'll just go for separate service&factory to reduce confusion
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
SearchEngineType type = GetEngineType_ChromiumImpl(url); | ||
if (type == SEARCH_ENGINE_OTHER) { | ||
for (const auto& entry : brave_engines_map) { | ||
const auto& engine = entry.second; |
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.
This causes compile failure - maybe you want const auto*
?
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.
compiled successfully on my machine :-/
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
37af5ca
to
8e535ee
Compare
@simonhong ptal |
@bridiver pls check the removed patch. We don't need it because:
|
SearchEngineTrackerFactory::~SearchEngineTrackerFactory() {} | ||
|
||
KeyedService* SearchEngineTrackerFactory::BuildServiceInstanceFor( | ||
content::BrowserContext* context) const { |
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.
How about return nullptr if |context| is non normal profile?
I think this only tracks for normal profile?
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.
It already works like this, as per BrowserContextKeyedServiceFactory::GetBrowserContextToUse
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, it's default behavior! :)
please add issue url in the description. |
const SearchTermsData& search_terms = | ||
template_url_service_->search_terms_data(); | ||
const GURL& url = template_url->GenerateSearchURL(search_terms); | ||
if (url != default_search_url_) { |
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.
Just out of curiosity, this callback is called in url == default_search_url_
case?
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 yes, because other details (e.g. shortcut or anything else) could be changed, and in this case the callback fires as well
added, I hope this will not close 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.
LGTM
@bridiver can you please review 😄 I'll try to check out soon too! |
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.
patch change looks good
Issue 8341: Add the default search engine metric.
Edit: Only Question 2 is implemented in this PR. @iefremov logged a follow-up issue for Question1 brave/brave-browser#8854 |
Verification PASSED with Windows 10 x64 using
Question 2 - metric Brave.Search.DefaultEngine Clean profile:
Upgraded profile:
|
brave/brave-browser#8341
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
Reviewer Checklist:
After-merge Checklist:
changes has landed on.