-
Notifications
You must be signed in to change notification settings - Fork 904
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
Fix alternative search engine provider feature bugs #529
Conversation
Marked as wip. I'll push all fixes of ddg search provider issues to this PR. |
e2b3f5a
to
425dc58
Compare
6f93b79
to
367e668
Compare
TemplateURLData GetAlternativeSearchEngineData() { | ||
TemplateURLData private_search_engine_data; | ||
private_search_engine_data.SetShortName(base::ASCIIToUTF16("DuckDuckGo")); | ||
private_search_engine_data.SetKeyword(base::ASCIIToUTF16("duckduckgo.com")); |
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.
Should this be set to :d
to match what we will have on the search engines settings page and in muon?
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 deleted this function and used our prepopulated lists to get ddg data.
4f2480d
So far, webui didn't store setting value. Just button was toggled. Because of this, when reloading button state is back to initial value. To fix this, this value should be delivered to webui when preference is changed.
When private search engine doesn't use ddg prefs, it should follow normal profile's search engine change.
To support alternative search engine provider to tor(guest) window, SearchEngineProviderController and its subclasses are introduced. PrivateWindowSearchEngineProviderController handles private window's alternative search engine provider and GuestWindowSearchEngineProviderController will handle tor(guest) window's search engine provider. Also some cleanup is done.
GuestWindowSearchEngineProviderController handles.
Currently, changing provider from settings ui is prevented. Need to revisit when related UX is determined.
367e668
to
4f2480d
Compare
It causes crash for now with below log. [brave_content_browser_client.cc(217)] Check failed: !path.empty(). This Will be enabled later when I can avoid this crash.
Fix alternative search engine provider feature bugs
Fix alternative search engine provider feature bugs
Did this address brave/brave-browser#1226 too? |
@riastradh-brave Partially addressed. With this PR, only ddg is used on tor. |
// Prevent search engine changing from settings page for tor profile. | ||
// TODO(simonhong): Revisit when related ux is determined. | ||
if (otr_profile_->IsTorProfile()) { | ||
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.
we don't allow users to change search engine in tor window?
I thought we only set it to DDG by default for tor and then if users have their own preference, we respect their decisions.
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.
Yep, making this optional is next task.
@@ -63,3 +74,21 @@ IN_PROC_BROWSER_TEST_F(SearchEngineProviderControllerTest, PrefTest) { | |||
EXPECT_EQ(incognito_service->GetDefaultSearchProvider()->data().short_name(), | |||
base::ASCIIToUTF16("test1")); | |||
} | |||
|
|||
// This test crashes with below. I don't know how to deal with now. |
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.
you should use
class TorUnittestProfileManager : public ProfileManagerWithoutInit { |
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.
Thanks. I'll update this test later!
First commit addressed brave/brave-browser#1235.
Second commit addressed brave/brave-browser#1393
Third commit is refactoring and cleanup.
Forth commit addressed brave/brave-browser#1394
Fifth commit partially addressed brave/brave-browser#1226 because current PR only uses ddg for tor window.
Close: brave/brave-browser#1235
Close: brave/brave-browser#1393
Close: brave/brave-browser#1394
Issue: brave/brave-browser#1226
Simple high level overview
When profile is created, appropriate
SearchEngineProviderController
is initialized.PrivateWindowSearchEngineProviderController
is for private window andGuestWindowSearchEngineProviderController
is for guest window.ProfileCreationMonitor
monitors profile creation and tries to initialize above controllers if needed.Submitter Checklist:
git rebase -i
to squash commits (if needed).Test Plan:
Open private window and toggle ddg button and reload.
Then check toggle state is remained as before.
yarn test brave_browser_tests --filter=SearchEngineProviderControllerTest.*
Reviewer Checklist: