| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/history_contents_provider.h" | 5 #include "chrome/browser/autocomplete/history_contents_provider.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/histogram.h" | 8 #include "base/histogram.h" |
| 9 #include "base/string_util.h" | 9 #include "base/string_util.h" |
| 10 #include "chrome/browser/bookmarks/bookmark_model.h" | 10 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 11 #include "chrome/browser/bookmarks/bookmark_utils.h" | 11 #include "chrome/browser/bookmarks/bookmark_utils.h" |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 200 return !result.title_match_positions().empty(); | 200 return !result.title_match_positions().empty(); |
| 201 } | 201 } |
| 202 | 202 |
| 203 AutocompleteMatch HistoryContentsProvider::ResultToMatch( | 203 AutocompleteMatch HistoryContentsProvider::ResultToMatch( |
| 204 const history::URLResult& result, | 204 const history::URLResult& result, |
| 205 int score) { | 205 int score) { |
| 206 // TODO(sky): if matched title highlight matching words in title. | 206 // TODO(sky): if matched title highlight matching words in title. |
| 207 // Also show star in popup. | 207 // Also show star in popup. |
| 208 AutocompleteMatch match(this, score, false, MatchInTitle(result) ? | 208 AutocompleteMatch match(this, score, false, MatchInTitle(result) ? |
| 209 AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_BODY); | 209 AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_BODY); |
| 210 match.fill_into_edit = StringForURLDisplay(result.url(), true); | 210 match.fill_into_edit = StringForURLDisplay(result.url(), true, trim_http_); |
| 211 match.destination_url = result.url(); | 211 match.destination_url = result.url(); |
| 212 match.contents = match.fill_into_edit; | 212 match.contents = match.fill_into_edit; |
| 213 if (trim_http_) | |
| 214 TrimHttpPrefix(&match.contents); | |
| 215 match.contents_class.push_back( | 213 match.contents_class.push_back( |
| 216 ACMatchClassification(0, ACMatchClassification::URL)); | 214 ACMatchClassification(0, ACMatchClassification::URL)); |
| 217 match.description = result.title(); | 215 match.description = result.title(); |
| 218 match.starred = | 216 match.starred = |
| 219 (profile_->GetBookmarkModel() && | 217 (profile_->GetBookmarkModel() && |
| 220 profile_->GetBookmarkModel()->IsBookmarked(result.url())); | 218 profile_->GetBookmarkModel()->IsBookmarked(result.url())); |
| 221 | 219 |
| 222 ClassifyDescription(result, &match); | 220 ClassifyDescription(result, &match); |
| 223 return match; | 221 return match; |
| 224 } | 222 } |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 UMA_HISTOGRAM_TIMES("Omnibox.QueryBookmarksTime", | 272 UMA_HISTOGRAM_TIMES("Omnibox.QueryBookmarksTime", |
| 275 TimeTicks::Now() - start_time); | 273 TimeTicks::Now() - start_time); |
| 276 } | 274 } |
| 277 | 275 |
| 278 void HistoryContentsProvider::AddBookmarkTitleMatchToResults( | 276 void HistoryContentsProvider::AddBookmarkTitleMatchToResults( |
| 279 const bookmark_utils::TitleMatch& match) { | 277 const bookmark_utils::TitleMatch& match) { |
| 280 history::URLResult url_result(match.node->GetURL(), match.match_positions); | 278 history::URLResult url_result(match.node->GetURL(), match.match_positions); |
| 281 url_result.set_title(match.node->GetTitle()); | 279 url_result.set_title(match.node->GetTitle()); |
| 282 results_.AppendURLBySwapping(&url_result); | 280 results_.AppendURLBySwapping(&url_result); |
| 283 } | 281 } |
| OLD | NEW |