-
Notifications
You must be signed in to change notification settings - Fork 898
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
Fixed crash with search provider extension #8539
Conversation
2c199a0
to
6d6ae20
Compare
3de7c8d
to
66d4c62
Compare
if (ignore_template_url_service_changing_) | ||
return; | ||
|
||
base::AutoReset<bool> reset(&ignore_template_url_service_changing_, true); |
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.
AutoReset<>
is a super nice base library offering 🙂 Had never worked with this before, just looked into it now! Really nice to temporarily change the value and then it resets after going out of scope
66d4c62
to
6691c44
Compare
c0dfc49
to
a1519b6
Compare
377ae23
to
0db630e
Compare
Kindly ping :) |
// This doesn't handle guest window's provider because guest window only uses | ||
// its own private profile. Using SearchEngineProviderService for managing guest | ||
// window's DDG toggle button config is sufficient. | ||
class ActiveWindowSearchProviderManager : public views::WidgetObserver { |
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'm not quire sure this is a way to go. The service is queried for GetDefaultSearchProvider()
across the code and the callers can get different results depending on a visible widget, isn't 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.
With this approach, we can use one service for normal/private like chromium.
Many places & services with single instance service (use one service instance for both profile) refers TemplateURLService
. This makes conflict with our needs(we need different TemplateURLService
instance).
Search provider extension crash also comes from using different TemplateURLService
instance.
Of course, I also think this approach is not the best but this works well and we can archieve our needs w/o patching/overrding anymore.
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.
IMO, we should introduce new complex patches/overriding to fix crash issues(brave/brave-browser#15224, brave/brave-browser#14218) w/o this approach.
and I think this approach is straightforward and can be maintained easily. WDYT? @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.
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.
in fact I found instances where GetDefaultSearchProvider
is called async which means the active window could change from what it was when the action was initiated
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.
will close this PR and I'll try to resolve with another approach - #8626
return popup_view_.get(); | ||
} | ||
|
||
+ BRAVE_OMNIBOX_VIEW_VIEWS_H |
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.
#define OnOmniboxPaste NotUsed() {}; friend ... OnOmniboxPaste
?
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.
@bridiver Right, we don't need to add new patch file for this :)
Fixed. thanks!
fix: brave/brave-browser#15224 fix: brave/brave-browser#10601 fix: brave/brave-browser#14218 Changed to use same TemplateURLService for normal & private profile.
As we use one TemplateURLService for normal/private profile and set proper provider for current active window's profile, we always can get proper selection navigation url.
On linux, BraveBrowserFrame is not used. Changed ActiveWindowSearchProviderManager owner to BrowserView. and updated test cases.
Omnibox placeholder text includes current search provider info. As we are using same TemplateURLService for normal/private window, Inactive browser window's omnibox placeholder could show different search provider. For example, when private window is active and DDG is on, other inactive window's omnibox placeholder shows DDG's placeholder if it's current tab is NTP. Of course, it's set properly when it's activated. but it could make user confusing. To fix this, inactive windows omnibox place holder will not be updated. and when activated anytime, omnibox can have proper placeholder text.
As we started to use private profile for tor window instead of guest window, we don't need to handle kDefaultSearchProviderDataPrefName differently for tor. When tor window is started, proper search provider is set regardless of `kDefaultSearchProviderDataPrefName`.
If private window is activated first, cached normal search provider is empty. In this case, we just use initial default search provider.
0db630e
to
ca8f294
Compare
fix: brave/brave-browser#15224
fix: brave/brave-browser#10601
fix: brave/brave-browser#14218
Crash comes from absense of exension search provider in private profile's TemplateURLService because
we are using different TemplateURLService for private profile. but many places in upstream doesn't know about this.
Changed to use same TemplateURLService for normal & private profile.
Previously we created different
TemplateURLService
instance for normal and private profile becausewe want to use different search provider on both. However, this approach added technical debt over time
because it's different with upstream chromium. chromium uses same instance for both.
And it turns out that search provider extension doesnt work well with current approach.
So, decided to use same architecture - using same
TemplateURLService
.Instead of using one instance, active search provider is set for profile of current active windows.
With this, we can delete some patches and overrides for using different
TemplateURLService.
Submitter Checklist:
QA/Yes
orQA/No
;release-notes/include
orrelease-notes/exclude
;OS/...
) to the associated issuenpm run test -- brave_browser_tests
,npm run test -- brave_unit_tests
,npm run lint
,npm run gn_check
,npm run tslint
git rebase master
(if needed)Reviewer Checklist:
gn
After-merge Checklist:
changes has landed on
Test Plan:
npm run test brave_browser_tests -- --filter=SearchEngineProviderServiceTest*
See above issue's STR.
and below issue's STR because codes for fixing below issues is cleaned up also.
brave/brave-browser#1758
brave/brave-browser#1037
Check normal window/private/private(tor) 's search engine options works properly.