| 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/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <cmath> | 8 #include <cmath> |
| 9 #include <map> | 9 #include <map> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 if (matches_.size() > AutocompleteProvider::kMaxMatches) { | 176 if (matches_.size() > AutocompleteProvider::kMaxMatches) { |
| 177 matches_.erase(matches_.begin() + AutocompleteProvider::kMaxMatches, | 177 matches_.erase(matches_.begin() + AutocompleteProvider::kMaxMatches, |
| 178 matches_.end()); | 178 matches_.end()); |
| 179 } | 179 } |
| 180 } | 180 } |
| 181 | 181 |
| 182 AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( | 182 AutocompleteMatch ShortcutsProvider::ShortcutToACMatch( |
| 183 const AutocompleteInput& input, | 183 const AutocompleteInput& input, |
| 184 const string16& term_string, | 184 const string16& term_string, |
| 185 ShortcutMap::iterator it) { | 185 ShortcutMap::iterator it) { |
| 186 AutocompleteMatch match(this, CalculateScore(term_string, it->second), | 186 // TODO(dominich): Use the same score calculation for confidence and |
| 187 // relevance. |
| 188 AutocompleteMatch match(this, CalculateScore(term_string, it->second), 0.0f, |
| 187 true, AutocompleteMatch::HISTORY_TITLE); | 189 true, AutocompleteMatch::HISTORY_TITLE); |
| 188 match.destination_url = it->second.url; | 190 match.destination_url = it->second.url; |
| 189 DCHECK(match.destination_url.is_valid()); | 191 DCHECK(match.destination_url.is_valid()); |
| 190 match.fill_into_edit = UTF8ToUTF16(it->second.url.spec()); | 192 match.fill_into_edit = UTF8ToUTF16(it->second.url.spec()); |
| 191 | 193 |
| 192 match.contents = it->second.contents; | 194 match.contents = it->second.contents; |
| 193 match.contents_class = ClassifyAllMatchesInString(term_string, | 195 match.contents_class = ClassifyAllMatchesInString(term_string, |
| 194 match.contents, | 196 match.contents, |
| 195 it->second.contents_class); | 197 it->second.contents_class); |
| 196 | 198 |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 321 } | 323 } |
| 322 | 324 |
| 323 void ShortcutsProvider::LoadShortcuts() { | 325 void ShortcutsProvider::LoadShortcuts() { |
| 324 DCHECK(shortcuts_backend_.get()); | 326 DCHECK(shortcuts_backend_.get()); |
| 325 guid_map_.clear(); | 327 guid_map_.clear(); |
| 326 CHECK(shortcuts_backend_->GetShortcuts(&shortcuts_map_)); | 328 CHECK(shortcuts_backend_->GetShortcuts(&shortcuts_map_)); |
| 327 for (shortcuts_provider::ShortcutMap::iterator it = shortcuts_map_.begin(); | 329 for (shortcuts_provider::ShortcutMap::iterator it = shortcuts_map_.begin(); |
| 328 it != shortcuts_map_.end(); ++it) | 330 it != shortcuts_map_.end(); ++it) |
| 329 guid_map_[it->second.id] = it; | 331 guid_map_[it->second.id] = it; |
| 330 } | 332 } |
| OLD | NEW |