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/history_quick_provider.h" | 5 #include "chrome/browser/autocomplete/history_quick_provider.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 // completions (which may be available because it's a different | 140 // completions (which may be available because it's a different |
141 // data structure) compete with the URL-what-you-typed match as | 141 // data structure) compete with the URL-what-you-typed match as |
142 // normal. | 142 // normal. |
143 if (history_service) { | 143 if (history_service) { |
144 history::URLDatabase* url_db = history_service->InMemoryDatabase(); | 144 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
145 // url_db can be NULL if it hasn't finished initializing (or | 145 // url_db can be NULL if it hasn't finished initializing (or |
146 // failed to to initialize). In this case, we let HistoryQuick | 146 // failed to to initialize). In this case, we let HistoryQuick |
147 // provider completions compete with the URL-what-you-typed | 147 // provider completions compete with the URL-what-you-typed |
148 // match as normal. | 148 // match as normal. |
149 if (url_db) { | 149 if (url_db) { |
150 const std::string host(UTF16ToUTF8(autocomplete_input_.text().substr( | 150 const std::string host(base::UTF16ToUTF8( |
151 autocomplete_input_.parts().host.begin, | 151 autocomplete_input_.text().substr( |
152 autocomplete_input_.parts().host.len))); | 152 autocomplete_input_.parts().host.begin, |
| 153 autocomplete_input_.parts().host.len))); |
153 // We want to put the URL-what-you-typed match first if either | 154 // We want to put the URL-what-you-typed match first if either |
154 // * the user visited the URL before (intranet or internet). | 155 // * the user visited the URL before (intranet or internet). |
155 // * it's a URL on a host that user visited before and this | 156 // * it's a URL on a host that user visited before and this |
156 // is the root path of the host. (If the user types some | 157 // is the root path of the host. (If the user types some |
157 // of a path--more than a simple "/"--we let autocomplete compete | 158 // of a path--more than a simple "/"--we let autocomplete compete |
158 // normally with the URL-what-you-typed match.) | 159 // normally with the URL-what-you-typed match.) |
159 // TODO(mpearson): Remove this hacky code and simply score URL-what- | 160 // TODO(mpearson): Remove this hacky code and simply score URL-what- |
160 // you-typed in some sane way relative to possible completions: | 161 // you-typed in some sane way relative to possible completions: |
161 // URL-what-you-typed should get some sort of a boost relative | 162 // URL-what-you-typed should get some sort of a boost relative |
162 // to completions, but completions should naturally win if | 163 // to completions, but completions should naturally win if |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 if (index_for_testing_.get()) | 310 if (index_for_testing_.get()) |
310 return index_for_testing_.get(); | 311 return index_for_testing_.get(); |
311 | 312 |
312 HistoryService* const history_service = | 313 HistoryService* const history_service = |
313 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 314 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); |
314 if (!history_service) | 315 if (!history_service) |
315 return NULL; | 316 return NULL; |
316 | 317 |
317 return history_service->InMemoryIndex(); | 318 return history_service->InMemoryIndex(); |
318 } | 319 } |
OLD | NEW |