-
Notifications
You must be signed in to change notification settings - Fork 868
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #5221 from brave/maxk-issue-9119
Fixes crash when suggesting in Private window.
- Loading branch information
Showing
7 changed files
with
93 additions
and
46 deletions.
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