OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "components/omnibox/search_provider.h" | 5 #include "components/omnibox/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/callback.h" | 12 #include "base/callback.h" |
13 #include "base/i18n/break_iterator.h" | 13 #include "base/i18n/break_iterator.h" |
14 #include "base/i18n/case_conversion.h" | 14 #include "base/i18n/case_conversion.h" |
15 #include "base/json/json_string_value_serializer.h" | 15 #include "base/json/json_string_value_serializer.h" |
16 #include "base/metrics/histogram.h" | 16 #include "base/metrics/histogram.h" |
17 #include "base/metrics/user_metrics.h" | 17 #include "base/metrics/user_metrics.h" |
18 #include "base/rand_util.h" | 18 #include "base/rand_util.h" |
| 19 #include "base/strings/string_split.h" |
19 #include "base/strings/string_util.h" | 20 #include "base/strings/string_util.h" |
20 #include "base/strings/utf_string_conversions.h" | 21 #include "base/strings/utf_string_conversions.h" |
21 #include "components/history/core/browser/in_memory_database.h" | 22 #include "components/history/core/browser/in_memory_database.h" |
22 #include "components/history/core/browser/keyword_search_term.h" | 23 #include "components/history/core/browser/keyword_search_term.h" |
23 #include "components/metrics/proto/omnibox_input_type.pb.h" | 24 #include "components/metrics/proto/omnibox_input_type.pb.h" |
24 #include "components/omnibox/autocomplete_provider_client.h" | 25 #include "components/omnibox/autocomplete_provider_client.h" |
25 #include "components/omnibox/autocomplete_provider_listener.h" | 26 #include "components/omnibox/autocomplete_provider_listener.h" |
26 #include "components/omnibox/autocomplete_result.h" | 27 #include "components/omnibox/autocomplete_result.h" |
27 #include "components/omnibox/keyword_provider.h" | 28 #include "components/omnibox/keyword_provider.h" |
28 #include "components/omnibox/omnibox_field_trial.h" | 29 #include "components/omnibox/omnibox_field_trial.h" |
(...skipping 1400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 // Finally, if we have an inlineable navsuggestion with an inline completion | 1430 // Finally, if we have an inlineable navsuggestion with an inline completion |
1430 // that we're not preventing, make sure we didn't trim any whitespace. | 1431 // that we're not preventing, make sure we didn't trim any whitespace. |
1431 // We don't want to claim http://foo.com/bar is inlineable against the | 1432 // We don't want to claim http://foo.com/bar is inlineable against the |
1432 // input "foo.com/b ". | 1433 // input "foo.com/b ". |
1433 match.allowed_to_be_default_match = | 1434 match.allowed_to_be_default_match = |
1434 (prefix != NULL) && | 1435 (prefix != NULL) && |
1435 (providers_.GetKeywordProviderURL() == NULL) && | 1436 (providers_.GetKeywordProviderURL() == NULL) && |
1436 !navigation.received_after_last_keystroke() && | 1437 !navigation.received_after_last_keystroke() && |
1437 (match.inline_autocompletion.empty() || | 1438 (match.inline_autocompletion.empty() || |
1438 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); | 1439 (!input_.prevent_inline_autocomplete() && !trimmed_whitespace)); |
| 1440 std::vector<base::string16> words; |
| 1441 base::SplitString(input_.text(), ' ', &words); |
1439 match.EnsureUWYTIsAllowedToBeDefault( | 1442 match.EnsureUWYTIsAllowedToBeDefault( |
1440 input_.canonicalized_url(), providers_.template_url_service()); | 1443 input_.canonicalized_url(), words, providers_.template_url_service()); |
1441 | 1444 |
1442 match.contents = navigation.match_contents(); | 1445 match.contents = navigation.match_contents(); |
1443 match.contents_class = navigation.match_contents_class(); | 1446 match.contents_class = navigation.match_contents_class(); |
1444 match.description = navigation.description(); | 1447 match.description = navigation.description(); |
1445 AutocompleteMatch::ClassifyMatchInString(input, match.description, | 1448 AutocompleteMatch::ClassifyMatchInString(input, match.description, |
1446 ACMatchClassification::NONE, &match.description_class); | 1449 ACMatchClassification::NONE, &match.description_class); |
1447 | 1450 |
1448 match.RecordAdditionalInfo( | 1451 match.RecordAdditionalInfo( |
1449 kRelevanceFromServerKey, | 1452 kRelevanceFromServerKey, |
1450 navigation.relevance_from_server() ? kTrue : kFalse); | 1453 navigation.relevance_from_server() ? kTrue : kFalse); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1512 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 1515 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
1513 matches.push_back(i->second); | 1516 matches.push_back(i->second); |
1514 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); | 1517 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); |
1515 | 1518 |
1516 // If there is a top scoring entry, find the corresponding answer. | 1519 // If there is a top scoring entry, find the corresponding answer. |
1517 if (!matches.empty()) | 1520 if (!matches.empty()) |
1518 return answers_cache_.GetTopAnswerEntry(matches[0].contents); | 1521 return answers_cache_.GetTopAnswerEntry(matches[0].contents); |
1519 | 1522 |
1520 return AnswersQueryData(); | 1523 return AnswersQueryData(); |
1521 } | 1524 } |
OLD | NEW |