-
Notifications
You must be signed in to change notification settings - Fork 868
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
Fixes crash when suggesting in Private window. #5221
Conversation
Fixes brave/brave-browser#9119 When search suggestions are turned on and a user types into the omnibox in a Private window a crash would occur. This started happening with the upgrade to Chromium 81 because the check for BitmapFetchService bein null has been removed in ChromeOmniboxClient::OnResultChanged (and other places). This is because the code there isn't expected to be triggered for an OTR profile. Updated BraveAutocompleteProviderClient to override 2 additional methods: 1. IsOffTheRecord 2. StartServiceWorker These methods regulate when it is suitable to make suggestions and should use the real profile (OTR or regular) instead of using regular profile that we send to the base class even when the profile is OTR.
|
||
void BraveAutocompleteProviderClient::StartServiceWorker( | ||
const GURL& destination_url) { | ||
if (profile_->IsOffTheRecord()) |
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 confusing with this method. Is it possible that ChromeAutocompleteProviderClient::profile_
is OTR?
It's always initialized by ChromeAutocompleteProviderClient(profile->GetOriginalProfile())
.
So, I'm curious why this method should be overridden? (Maybe I'm missing something..?)
// We should not hide the true nature of the profile when these methods in | ||
// ChromeAutocompleteProviderClient are called as they control what is | ||
// suitable for suggestions in regular vs incognito profiles. | ||
bool IsOffTheRecord() const override; |
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.
ChromeAutocompleteProvider::IsOffTheRecored() can return true?
I think the root cause of this issue is below code.
We made all
We overrides it with |
For ChromeOmniboxClient, we don't need to use original profile explicitely. For AutocompleteProviderClassifier, we need to initialize base class with original profile For more detail, please see BraveAutocompleteProviderClientForClassifier.
@mkarolin I added one commit based on my above comment. |
@simonhong, yes that makes sense to me. I assumed it was the way it was for #757 and didn't try to dig into it, but if only the classifier needs the original profile instead of the OTR, then it's definitely a better solution. |
CI: known unrelated failure on Android (dist). Unrelated browser test failure on Mac. |
#include "chrome/common/webui_url_constants.h" | ||
|
||
BraveAutocompleteProviderClient::BraveAutocompleteProviderClient( | ||
Profile* profile) | ||
: ChromeAutocompleteProviderClient(profile->GetOriginalProfile()), |
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 fairly certain we're leaking private autocomplete into the regular profile here in the old code and here in the updated code https://github.com/brave/brave-core/pull/5221/files#diff-2325211a427ac6f007ad338411e100aaR14 cc @diracdeltas @simonhong
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.
approving to fix the crash, but this needs a follow-up to fix the private -> public leak
Fixes crash when suggesting in Private window.
Verification PASSED on
Ensure that
|
Looks good to me too.
Following same steps as above. |
Fixes crash when suggesting in Private window.
Fixes brave/brave-browser#9119
When search suggestions are turned on and a user types into the omnibox
in a Private window a crash would occur. This started happening with the
upgrade to Chromium 81 because the check for BitmapFetchService bein
null has been removed in ChromeOmniboxClient::OnResultChanged (and other
places). This is because the code there isn't expected to be triggered
for an OTR profile.
Updated BraveAutocompleteProviderClient to override 2 additional
methods:
These methods regulate when it is suitable to make suggestions and
should use the real profile (OTR or regular) instead of using regular
profile that we send to the base class even when the profile is OTR.
Submitter Checklist:
npm run lint
)git rebase master
(if needed).git rebase -i
to squash commits (if needed).Test Plan:
See STR in brave/brave-browser#9119
Reviewer Checklist:
After-merge Checklist:
changes has landed on.