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 "chrome/browser/autocomplete/search_provider.h" | 5 #include "chrome/browser/autocomplete/search_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 | 9 |
10 #include "base/callback.h" | 10 #include "base/callback.h" |
(...skipping 1656 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1667 // First look for the user's input inside the fill_into_edit as it would be | 1667 // First look for the user's input inside the fill_into_edit as it would be |
1668 // without trimming the scheme, so we can find matches at the beginning of the | 1668 // without trimming the scheme, so we can find matches at the beginning of the |
1669 // scheme. | 1669 // scheme. |
1670 const string16& untrimmed_fill_into_edit = navigation.formatted_url(); | 1670 const string16& untrimmed_fill_into_edit = navigation.formatted_url(); |
1671 const URLPrefix* prefix = | 1671 const URLPrefix* prefix = |
1672 URLPrefix::BestURLPrefix(untrimmed_fill_into_edit, input); | 1672 URLPrefix::BestURLPrefix(untrimmed_fill_into_edit, input); |
1673 size_t match_start = (prefix == NULL) ? | 1673 size_t match_start = (prefix == NULL) ? |
1674 untrimmed_fill_into_edit.find(input) : prefix->prefix.length(); | 1674 untrimmed_fill_into_edit.find(input) : prefix->prefix.length(); |
1675 size_t inline_autocomplete_offset = (prefix == NULL) ? | 1675 size_t inline_autocomplete_offset = (prefix == NULL) ? |
1676 string16::npos : (match_start + input.length()); | 1676 string16::npos : (match_start + input.length()); |
1677 bool trim_http = !HasHTTPScheme(input) && (!prefix || (match_start != 0)); | 1677 bool trim_http = !AutocompleteInput::HasHTTPScheme(input) && |
| 1678 (!prefix || (match_start != 0)); |
1678 | 1679 |
1679 // Preserve the forced query '?' prefix in |match.fill_into_edit|. | 1680 // Preserve the forced query '?' prefix in |match.fill_into_edit|. |
1680 // Otherwise, user edits to a suggestion would show non-Search results. | 1681 // Otherwise, user edits to a suggestion would show non-Search results. |
1681 if (input_.type() == AutocompleteInput::FORCED_QUERY) { | 1682 if (input_.type() == AutocompleteInput::FORCED_QUERY) { |
1682 match.fill_into_edit = ASCIIToUTF16("?"); | 1683 match.fill_into_edit = ASCIIToUTF16("?"); |
1683 if (inline_autocomplete_offset != string16::npos) | 1684 if (inline_autocomplete_offset != string16::npos) |
1684 ++inline_autocomplete_offset; | 1685 ++inline_autocomplete_offset; |
1685 } | 1686 } |
1686 | 1687 |
1687 const std::string languages( | 1688 const std::string languages( |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1764 it->set_relevance(max_query_relevance); | 1765 it->set_relevance(max_query_relevance); |
1765 it->set_relevance_from_server(relevance_from_server); | 1766 it->set_relevance_from_server(relevance_from_server); |
1766 } | 1767 } |
1767 } | 1768 } |
1768 | 1769 |
1769 void SearchProvider::UpdateDone() { | 1770 void SearchProvider::UpdateDone() { |
1770 // We're done when the timer isn't running, there are no suggest queries | 1771 // We're done when the timer isn't running, there are no suggest queries |
1771 // pending, and we're not waiting on Instant. | 1772 // pending, and we're not waiting on Instant. |
1772 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1773 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
1773 } | 1774 } |
OLD | NEW |