-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 3 additions & 15 deletions
18
browser/autocomplete/brave_autocomplete_provider_client.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
browser/autocomplete/brave_autocomplete_provider_client_for_classifier.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/* Copyright (c) 2019 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#include "brave/browser/autocomplete/brave_autocomplete_provider_client_for_classifier.h" | ||
|
||
#include "chrome/browser/profiles/profile.h" | ||
#include "chrome/browser/search_engines/template_url_service_factory.h" | ||
|
||
BraveAutocompleteProviderClientForClassifier:: | ||
BraveAutocompleteProviderClientForClassifier( | ||
Profile* profile) | ||
: BraveAutocompleteProviderClient(profile->GetOriginalProfile()), | ||
profile_(profile) { | ||
} | ||
|
||
BraveAutocompleteProviderClientForClassifier:: | ||
~BraveAutocompleteProviderClientForClassifier() { | ||
} | ||
|
||
TemplateURLService* | ||
BraveAutocompleteProviderClientForClassifier::GetTemplateURLService() { | ||
return TemplateURLServiceFactory::GetForProfile(profile_); | ||
} | ||
|
||
const TemplateURLService* | ||
BraveAutocompleteProviderClientForClassifier::GetTemplateURLService() const { | ||
return TemplateURLServiceFactory::GetForProfile(profile_); | ||
} |
44 changes: 44 additions & 0 deletions
44
browser/autocomplete/brave_autocomplete_provider_client_for_classifier.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* Copyright (c) 2020 The Brave Authors. All rights reserved. | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this file, | ||
* You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
#ifndef BRAVE_BROWSER_AUTOCOMPLETE_BRAVE_AUTOCOMPLETE_PROVIDER_CLIENT_FOR_CLASSIFIER_H_ | ||
#define BRAVE_BROWSER_AUTOCOMPLETE_BRAVE_AUTOCOMPLETE_PROVIDER_CLIENT_FOR_CLASSIFIER_H_ | ||
|
||
#include "brave/browser/autocomplete/brave_autocomplete_provider_client.h" | ||
|
||
// In brave, different AutocompleteClassifiers are created for normal and | ||
// incognito profile by changing | ||
// AutocompleteClassifierFactory::GetBrowserContextToUse(). | ||
// This changes are needed to use different search engine used by web search in | ||
// web page context menu. | ||
// When context menu handles web search it gets search engine url from | ||
// ChromeAutocompleteProviderClient via AutocompleteClassifiers. | ||
// Because of this, private window will use same search engine url of normal | ||
// window if same AutocompleteClassifiers are used on normal and incognito. | ||
// So, we made this change. | ||
// However, ChromeAutocompleteProviderClient exposes many other services based | ||
// on profiles. | ||
// We don't want to change other services. Only wanted to get proper | ||
// TemplateURLService. To achieve this, BraveAutocompleteProviderClient is | ||
// introduced. It initializes ChromeAutocompleteProviderClient with original | ||
// profile and only overrided TemplateURLService getter. | ||
// BraveAutocompleteSchemeClassifier also initialize | ||
// ChromeAutocompleteSchemeClassifier with original profile for same reason. | ||
class BraveAutocompleteProviderClientForClassifier | ||
: public BraveAutocompleteProviderClient { | ||
public: | ||
explicit BraveAutocompleteProviderClientForClassifier(Profile* profile); | ||
~BraveAutocompleteProviderClientForClassifier() override; | ||
|
||
TemplateURLService* GetTemplateURLService() override; | ||
const TemplateURLService* GetTemplateURLService() const override; | ||
|
||
private: | ||
Profile* profile_; | ||
|
||
DISALLOW_COPY_AND_ASSIGN(BraveAutocompleteProviderClientForClassifier); | ||
}; | ||
|
||
#endif // BRAVE_BROWSER_AUTOCOMPLETE_BRAVE_AUTOCOMPLETE_PROVIDER_CLIENT_FOR_CLASSIFIER_H_ |
7 changes: 4 additions & 3 deletions
7
chromium_src/chrome/browser/autocomplete/autocomplete_classifier_factory.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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