| 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" |
| (...skipping 1403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1414 // Otherwise, user edits to a suggestion would show non-Search results. | 1414 // Otherwise, user edits to a suggestion would show non-Search results. |
| 1415 if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY) { | 1415 if (input_.type() == metrics::OmniboxInputType::FORCED_QUERY) { |
| 1416 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); | 1416 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); |
| 1417 if (inline_autocomplete_offset != base::string16::npos) | 1417 if (inline_autocomplete_offset != base::string16::npos) |
| 1418 ++inline_autocomplete_offset; | 1418 ++inline_autocomplete_offset; |
| 1419 } | 1419 } |
| 1420 if (inline_autocomplete_offset != base::string16::npos) { | 1420 if (inline_autocomplete_offset != base::string16::npos) { |
| 1421 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); | 1421 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); |
| 1422 match.inline_autocompletion = | 1422 match.inline_autocompletion = |
| 1423 match.fill_into_edit.substr(inline_autocomplete_offset); | 1423 match.fill_into_edit.substr(inline_autocomplete_offset); |
| 1424 match.StripLoneSlashOnInlineAutocompletion(); |
| 1424 } | 1425 } |
| 1425 // An inlineable navsuggestion can only be the default match when there | 1426 // An inlineable navsuggestion can only be the default match when there |
| 1426 // is no keyword provider active, lest it appear first and break the user | 1427 // is no keyword provider active, lest it appear first and break the user |
| 1427 // out of keyword mode. We also must have received the navsuggestion before | 1428 // out of keyword mode. We also must have received the navsuggestion before |
| 1428 // the last keystroke, to prevent asynchronous inline autocompletions changes. | 1429 // the last keystroke, to prevent asynchronous inline autocompletions changes. |
| 1429 // The navsuggestion can also only be default if either the inline | 1430 // The navsuggestion can also only be default if either the inline |
| 1430 // autocompletion is empty or we're not preventing inline autocompletion. | 1431 // autocompletion is empty or we're not preventing inline autocompletion. |
| 1431 // Finally, if we have an inlineable navsuggestion with an inline completion | 1432 // Finally, if we have an inlineable navsuggestion with an inline completion |
| 1432 // that we're not preventing, make sure we didn't trim any whitespace. | 1433 // that we're not preventing, make sure we didn't trim any whitespace. |
| 1433 // We don't want to claim http://foo.com/bar is inlineable against the | 1434 // We don't want to claim http://foo.com/bar is inlineable against the |
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1514 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) | 1515 for (MatchMap::const_iterator i(map.begin()); i != map.end(); ++i) |
| 1515 matches.push_back(i->second); | 1516 matches.push_back(i->second); |
| 1516 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); | 1517 std::sort(matches.begin(), matches.end(), &AutocompleteMatch::MoreRelevant); |
| 1517 | 1518 |
| 1518 // If there is a top scoring entry, find the corresponding answer. | 1519 // If there is a top scoring entry, find the corresponding answer. |
| 1519 if (!matches.empty()) | 1520 if (!matches.empty()) |
| 1520 return answers_cache_.GetTopAnswerEntry(matches[0].contents); | 1521 return answers_cache_.GetTopAnswerEntry(matches[0].contents); |
| 1521 | 1522 |
| 1522 return AnswersQueryData(); | 1523 return AnswersQueryData(); |
| 1523 } | 1524 } |
| OLD | NEW |