Skip to content

Commit

Permalink
[cros search service] Use input locale if provided
Browse files Browse the repository at this point in the history
Bug: 1090132
Change-Id: I6289fd96f7a701370dec37d59a148f38f61ea98c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2275988
Reviewed-by: Thanh Nguyen <thanhdng@chromium.org>
Commit-Queue: Jia Meng <jiameng@chromium.org>
Cr-Commit-Position: refs/heads/master@{#784731}
  • Loading branch information
jm318 authored and Commit Bot committed Jul 2, 2020
1 parent 9836a23 commit ef52e81
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ void InvertedIndexSearch::AddOrUpdate(
const std::vector<local_search_service::Data>& data,
bool build_index) {
for (const Data& d : data) {
// TODO(jiameng): use different locales.
const std::vector<Token> document_tokens = ExtractDocumentTokens(d, "en");
// Use input locale unless it's empty. In this case we will use system
// default locale.
const std::string locale =
d.locale.empty() ? base::i18n::GetConfiguredLocale() : d.locale;
const std::vector<Token> document_tokens = ExtractDocumentTokens(d, locale);
DCHECK(!document_tokens.empty());
inverted_index_->AddDocument(d.id, document_tokens);
}
Expand Down
5 changes: 5 additions & 0 deletions chrome/browser/chromeos/local_search_service/test_utils.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ std::vector<Data> CreateTestData(
for (const auto& item : input) {
Data data;
data.id = item.first;
// Hardcode to "en" because it's unclear what config locale will be when
// running a test.
// TODO(jiameng): allow locale to be passed in if there's a need to use
// non-en data in tests.
data.locale = "en";
std::vector<Content>& contents = data.contents;
for (const auto& content_with_id : item.second) {
const Content content(content_with_id.first,
Expand Down

0 comments on commit ef52e81

Please sign in to comment.