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

Conversation

simonhong
Copy link
Member

@simonhong simonhong commented Oct 1, 2018

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 and GuestWindowSearchEngineProviderController is for guest window.
ProfileCreationMonitor monitors profile creation and tries to initialize above controllers if needed.

Submitter Checklist:

  • Submitted a ticket for my issue if one did not already exist.
  • Used Github auto-closing keywords in the commit message.
  • Added/updated tests for this change (for new code or code which already has tests).
  • Ran git rebase -i to squash commits (if needed).
  • Tagged reviewers and labelled the pull request as needed.
  • Request a security/privacy review as needed.
  • Add appropriate QA labels (QA/Yes or QA/No) to include the closed issue in milestone

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:

  • New files have MPL-2.0 license header.
  • Request a security/privacy review as needed.
  • Adequate test coverage exists to prevent regressions
  • Verify test plan is specified in PR before merging to source

@simonhong simonhong self-assigned this Oct 1, 2018
@simonhong simonhong requested a review from bbondy October 1, 2018 13:29
@simonhong simonhong changed the title Fix ddg search button value is reseted when reloading WIP: Fix ddg search button value is reseted when reloading Oct 1, 2018
@simonhong
Copy link
Member Author

Marked as wip. I'll push all fixes of ddg search provider issues to this PR.

@simonhong simonhong force-pushed the private_search_engine_provider branch 3 times, most recently from e2b3f5a to 425dc58 Compare October 2, 2018 13:13
@simonhong simonhong changed the title WIP: Fix ddg search button value is reseted when reloading WIP: Fix alternative search engine provider feature bugs Oct 2, 2018
@simonhong simonhong changed the title WIP: Fix alternative search engine provider feature bugs Fix alternative search engine provider feature bugs Oct 2, 2018
@bsclifton bsclifton requested a review from mkarolin October 2, 2018 16:44
@simonhong simonhong force-pushed the private_search_engine_provider branch from 6f93b79 to 367e668 Compare October 2, 2018 17:18
TemplateURLData GetAlternativeSearchEngineData() {
TemplateURLData private_search_engine_data;
private_search_engine_data.SetShortName(base::ASCIIToUTF16("DuckDuckGo"));
private_search_engine_data.SetKeyword(base::ASCIIToUTF16("duckduckgo.com"));
Copy link
Collaborator

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?

Copy link
Member Author

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.
@simonhong simonhong requested a review from darkdh October 3, 2018 06:29
@simonhong simonhong force-pushed the private_search_engine_provider branch from 367e668 to 4f2480d Compare October 3, 2018 09:30
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.
@bbondy bbondy merged commit aa8863d into master Oct 3, 2018
bbondy added a commit that referenced this pull request Oct 3, 2018
Fix alternative search engine provider feature bugs
bbondy added a commit that referenced this pull request Oct 3, 2018
Fix alternative search engine provider feature bugs
@bbondy
Copy link
Member

bbondy commented Oct 3, 2018

master: aa8863d
0.56.x: 4820c64
0.55.x: 1bb0d4b

@riastradh-brave
Copy link
Contributor

Did this address brave/brave-browser#1226 too?

@simonhong
Copy link
Member Author

@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);
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.

@@ -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.
Copy link
Member

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 {
)

Copy link
Member Author

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
5 participants