| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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/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/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 111 if (input.text().empty()) | 111 if (input.text().empty()) |
| 112 return; | 112 return; |
| 113 | 113 |
| 114 for (ExtensionApps::const_iterator app = extension_apps_.begin(); | 114 for (ExtensionApps::const_iterator app = extension_apps_.begin(); |
| 115 app != extension_apps_.end(); ++app) { | 115 app != extension_apps_.end(); ++app) { |
| 116 // See if the input matches this extension application. | 116 // See if the input matches this extension application. |
| 117 const base::string16& name = app->name; | 117 const base::string16& name = app->name; |
| 118 base::string16::const_iterator name_iter = | 118 base::string16::const_iterator name_iter = |
| 119 std::search(name.begin(), name.end(), | 119 std::search(name.begin(), name.end(), |
| 120 input.text().begin(), input.text().end(), | 120 input.text().begin(), input.text().end(), |
| 121 base::CaseInsensitiveCompare<char16>()); | 121 base::CaseInsensitiveCompare<base::char16>()); |
| 122 bool matches_name = name_iter != name.end(); | 122 bool matches_name = name_iter != name.end(); |
| 123 size_t name_match_index = matches_name ? | 123 size_t name_match_index = matches_name ? |
| 124 static_cast<size_t>(name_iter - name.begin()) : base::string16::npos; | 124 static_cast<size_t>(name_iter - name.begin()) : base::string16::npos; |
| 125 | 125 |
| 126 bool matches_url = false; | 126 bool matches_url = false; |
| 127 size_t url_match_index = base::string16::npos; | 127 size_t url_match_index = base::string16::npos; |
| 128 if (app->should_match_against_launch_url) { | 128 if (app->should_match_against_launch_url) { |
| 129 const base::string16& url = app->launch_url; | 129 const base::string16& url = app->launch_url; |
| 130 base::string16::const_iterator url_iter = | 130 base::string16::const_iterator url_iter = |
| 131 std::search(url.begin(), url.end(), | 131 std::search(url.begin(), url.end(), |
| 132 input.text().begin(), input.text().end(), | 132 input.text().begin(), input.text().end(), |
| 133 base::CaseInsensitiveCompare<char16>()); | 133 base::CaseInsensitiveCompare<base::char16>()); |
| 134 matches_url = url_iter != url.end() && | 134 matches_url = url_iter != url.end() && |
| 135 input.type() != AutocompleteInput::FORCED_QUERY; | 135 input.type() != AutocompleteInput::FORCED_QUERY; |
| 136 url_match_index = matches_url ? | 136 url_match_index = matches_url ? |
| 137 static_cast<size_t>(url_iter - url.begin()) : base::string16::npos; | 137 static_cast<size_t>(url_iter - url.begin()) : base::string16::npos; |
| 138 } | 138 } |
| 139 | 139 |
| 140 if (matches_name || matches_url) { | 140 if (matches_name || matches_url) { |
| 141 // We have a match, might be a partial match. | 141 // We have a match, might be a partial match. |
| 142 matches_.push_back(CreateAutocompleteMatch( | 142 matches_.push_back(CreateAutocompleteMatch( |
| 143 input, *app, name_match_index, url_match_index)); | 143 input, *app, name_match_index, url_match_index)); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 219 history::URLRow info; | 219 history::URLRow info; |
| 220 url_db->GetRowForURL(url, &info); | 220 url_db->GetRowForURL(url, &info); |
| 221 type_count_boost = | 221 type_count_boost = |
| 222 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); | 222 400 * (1.0 - (std::pow(static_cast<double>(2), -info.typed_count()))); |
| 223 } | 223 } |
| 224 int relevance = 575 + static_cast<int>(type_count_boost) + | 224 int relevance = 575 + static_cast<int>(type_count_boost) + |
| 225 static_cast<int>(fraction_boost); | 225 static_cast<int>(fraction_boost); |
| 226 DCHECK_LE(relevance, kMaxRelevance); | 226 DCHECK_LE(relevance, kMaxRelevance); |
| 227 return relevance; | 227 return relevance; |
| 228 } | 228 } |
| OLD | NEW |