Skip to content
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

Merged
merged 7 commits into from
Oct 3, 2018
11 changes: 10 additions & 1 deletion browser/guest_window_search_engine_provider_controller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,20 @@ void GuestWindowSearchEngineProviderController::OnTemplateURLServiceChanged() {
if (ignore_template_url_service_changing_)
return;

// 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);
Copy link
Member

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.

Copy link
Member Author

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.

ChangeToAlternativeSearchEngineProvider();
return;
}


// The purpose of below code is turn off alternative prefs
// when user changes to different search engine provider from settings.
// However, this callback is also called during the TemplateURLService
// initialization phase. Because of this, guest view always starts with
// pref off state.
// this prefs off state when browser restarted(persisted during the runtime).
// Currently I don't know how to determine who is caller of this callback.
// TODO(simonhong): Revisit here when brave's related ux is determined.
if (UseAlternativeSearchEngineProvider())
Expand Down
5 changes: 5 additions & 0 deletions browser/search_engine_provider_controller_base.cc
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ void SearchEngineProviderControllerBase::OnPreferenceChanged(

bool
SearchEngineProviderControllerBase::UseAlternativeSearchEngineProvider() const {
// Currently, use alternative search engine provider for tor profile.
// TODO(simonhong): Revisit when related setting ux is determined.
if (otr_profile_->IsTorProfile())
return true;

return use_alternative_search_engine_provider_.GetValue();
}

Expand Down