| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/extension_app_provider.h" | 5 #include "chrome/browser/autocomplete/extension_app_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 | 9 |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 49 string16::const_iterator url_iter = std::search(url.begin(), url.end(), | 49 string16::const_iterator url_iter = std::search(url.begin(), url.end(), |
| 50 input.text().begin(), input.text().end(), | 50 input.text().begin(), input.text().end(), |
| 51 base::CaseInsensitiveCompare<char16>()); | 51 base::CaseInsensitiveCompare<char16>()); |
| 52 bool matches_url = url_iter != url.end() && | 52 bool matches_url = url_iter != url.end() && |
| 53 input.type() != AutocompleteInput::FORCED_QUERY; | 53 input.type() != AutocompleteInput::FORCED_QUERY; |
| 54 | 54 |
| 55 if (matches_name || matches_url) { | 55 if (matches_name || matches_url) { |
| 56 // We have a match, might be a partial match. | 56 // We have a match, might be a partial match. |
| 57 // TODO(finnur): Figure out what type to return here, might want to have | 57 // TODO(finnur): Figure out what type to return here, might want to have |
| 58 // the extension icon/a generic icon show up in the Omnibox. | 58 // the extension icon/a generic icon show up in the Omnibox. |
| 59 AutocompleteMatch match(this, 0, false, | 59 // TODO(dominich): Confidence would require us to create a match set and |
| 60 // then iterate over to create the AutocompleteMatch objects. Currently |
| 61 // confidence is used for instant/prerender/DNS preconnect and we may |
| 62 // not want to do those for extension apps anyway. |
| 63 AutocompleteMatch match(this, 0, 0.0f, false, |
| 60 AutocompleteMatch::EXTENSION_APP); | 64 AutocompleteMatch::EXTENSION_APP); |
| 61 match.fill_into_edit = url; | 65 match.fill_into_edit = url; |
| 62 match.destination_url = GURL(url); | 66 match.destination_url = GURL(url); |
| 63 match.inline_autocomplete_offset = string16::npos; | 67 match.inline_autocomplete_offset = string16::npos; |
| 64 match.contents = name; | 68 match.contents = name; |
| 65 AutocompleteMatch::ClassifyLocationInString(matches_name ? | 69 AutocompleteMatch::ClassifyLocationInString(matches_name ? |
| 66 static_cast<size_t>(name_iter - name.begin()) : string16::npos, | 70 static_cast<size_t>(name_iter - name.begin()) : string16::npos, |
| 67 input.text().length(), name.length(), ACMatchClassification::NONE, | 71 input.text().length(), name.length(), ACMatchClassification::NONE, |
| 68 &match.contents_class); | 72 &match.contents_class); |
| 69 match.description = url; | 73 match.description = url; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 history::URLRow info; | 149 history::URLRow info; |
| 146 url_db->GetRowForURL(url, &info); | 150 url_db->GetRowForURL(url, &info); |
| 147 type_count_boost = | 151 type_count_boost = |
| 148 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); | 152 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); |
| 149 } | 153 } |
| 150 int relevance = 575 + static_cast<int>(type_count_boost) + | 154 int relevance = 575 + static_cast<int>(type_count_boost) + |
| 151 static_cast<int>(fraction_boost); | 155 static_cast<int>(fraction_boost); |
| 152 DCHECK_LE(relevance, kMaxRelevance); | 156 DCHECK_LE(relevance, kMaxRelevance); |
| 153 return relevance; | 157 return relevance; |
| 154 } | 158 } |
| OLD | NEW |