| 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 1525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1536 net::FormatUrl(navigation.url(), languages, format_types, | 1536 net::FormatUrl(navigation.url(), languages, format_types, |
| 1537 net::UnescapeRule::SPACES, NULL, NULL, | 1537 net::UnescapeRule::SPACES, NULL, NULL, |
| 1538 &inline_autocomplete_offset)); | 1538 &inline_autocomplete_offset)); |
| 1539 // Preserve the forced query '?' prefix in |match.fill_into_edit|. | 1539 // Preserve the forced query '?' prefix in |match.fill_into_edit|. |
| 1540 // Otherwise, user edits to a suggestion would show non-Search results. | 1540 // Otherwise, user edits to a suggestion would show non-Search results. |
| 1541 if (input_.type() == AutocompleteInput::FORCED_QUERY) { | 1541 if (input_.type() == AutocompleteInput::FORCED_QUERY) { |
| 1542 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); | 1542 match.fill_into_edit.insert(0, base::ASCIIToUTF16("?")); |
| 1543 if (inline_autocomplete_offset != base::string16::npos) | 1543 if (inline_autocomplete_offset != base::string16::npos) |
| 1544 ++inline_autocomplete_offset; | 1544 ++inline_autocomplete_offset; |
| 1545 } | 1545 } |
| 1546 if (!input_.prevent_inline_autocomplete() && | 1546 if (inline_autocomplete_offset != base::string16::npos) { |
| 1547 (inline_autocomplete_offset != base::string16::npos)) { | |
| 1548 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); | 1547 DCHECK(inline_autocomplete_offset <= match.fill_into_edit.length()); |
| 1549 // A navsuggestion can only be the default match when there is no | |
| 1550 // keyword provider active, lest it appear first and break the user | |
| 1551 // out of keyword mode. | |
| 1552 match.allowed_to_be_default_match = | |
| 1553 (providers_.GetKeywordProviderURL() == NULL); | |
| 1554 match.inline_autocompletion = | 1548 match.inline_autocompletion = |
| 1555 match.fill_into_edit.substr(inline_autocomplete_offset); | 1549 match.fill_into_edit.substr(inline_autocomplete_offset); |
| 1556 } | 1550 } |
| 1551 // An inlineable navsuggestion can only be the default match when there |
| 1552 // is no keyword provider active, lest it appear first and break the user |
| 1553 // out of keyword mode. It can also only be default when we're not |
| 1554 // preventing inline autocompletion (unless the inline autocompletion |
| 1555 // would be empty). |
| 1556 match.allowed_to_be_default_match = navigation.IsInlineable(input) && |
| 1557 (providers_.GetKeywordProviderURL() == NULL) && |
| 1558 (!input_.prevent_inline_autocomplete() || |
| 1559 match.inline_autocompletion.empty()); |
| 1557 | 1560 |
| 1558 match.contents = navigation.match_contents(); | 1561 match.contents = navigation.match_contents(); |
| 1559 match.contents_class = navigation.match_contents_class(); | 1562 match.contents_class = navigation.match_contents_class(); |
| 1560 match.description = navigation.description(); | 1563 match.description = navigation.description(); |
| 1561 AutocompleteMatch::ClassifyMatchInString(input, match.description, | 1564 AutocompleteMatch::ClassifyMatchInString(input, match.description, |
| 1562 ACMatchClassification::NONE, &match.description_class); | 1565 ACMatchClassification::NONE, &match.description_class); |
| 1563 | 1566 |
| 1564 match.RecordAdditionalInfo( | 1567 match.RecordAdditionalInfo( |
| 1565 kRelevanceFromServerKey, | 1568 kRelevanceFromServerKey, |
| 1566 navigation.relevance_from_server() ? kTrue : kFalse); | 1569 navigation.relevance_from_server() ? kTrue : kFalse); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 it->set_relevance(max_query_relevance); | 1611 it->set_relevance(max_query_relevance); |
| 1609 it->set_relevance_from_server(relevance_from_server); | 1612 it->set_relevance_from_server(relevance_from_server); |
| 1610 } | 1613 } |
| 1611 } | 1614 } |
| 1612 | 1615 |
| 1613 void SearchProvider::UpdateDone() { | 1616 void SearchProvider::UpdateDone() { |
| 1614 // We're done when the timer isn't running, there are no suggest queries | 1617 // We're done when the timer isn't running, there are no suggest queries |
| 1615 // pending, and we're not waiting on Instant. | 1618 // pending, and we're not waiting on Instant. |
| 1616 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); | 1619 done_ = !timer_.IsRunning() && (suggest_results_pending_ == 0); |
| 1617 } | 1620 } |
| OLD | NEW |