| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 // inputs because these are likely to be an e-mail address. HistoryURL | 108 // inputs because these are likely to be an e-mail address. HistoryURL |
| 109 // provider won't promote the URL-what-you-typed match to first | 109 // provider won't promote the URL-what-you-typed match to first |
| 110 // for these inputs. | 110 // for these inputs. |
| 111 const bool can_have_url_what_you_typed_match_first = | 111 const bool can_have_url_what_you_typed_match_first = |
| 112 (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) && | 112 (autocomplete_input_.type() != metrics::OmniboxInputType::QUERY) && |
| 113 (!autocomplete_input_.parts().username.is_nonempty() || | 113 (!autocomplete_input_.parts().username.is_nonempty() || |
| 114 autocomplete_input_.parts().password.is_nonempty() || | 114 autocomplete_input_.parts().password.is_nonempty() || |
| 115 autocomplete_input_.parts().path.is_nonempty()); | 115 autocomplete_input_.parts().path.is_nonempty()); |
| 116 if (can_have_url_what_you_typed_match_first) { | 116 if (can_have_url_what_you_typed_match_first) { |
| 117 HistoryService* const history_service = | 117 HistoryService* const history_service = |
| 118 HistoryServiceFactory::GetForProfile(profile_, | 118 HistoryServiceFactory::GetForProfile( |
| 119 Profile::EXPLICIT_ACCESS); | 119 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 120 // We expect HistoryService to be available. In case it's not, | 120 // We expect HistoryService to be available. In case it's not, |
| 121 // (e.g., due to Profile corruption) we let HistoryQuick provider | 121 // (e.g., due to Profile corruption) we let HistoryQuick provider |
| 122 // completions (which may be available because it's a different | 122 // completions (which may be available because it's a different |
| 123 // data structure) compete with the URL-what-you-typed match as | 123 // data structure) compete with the URL-what-you-typed match as |
| 124 // normal. | 124 // normal. |
| 125 if (history_service) { | 125 if (history_service) { |
| 126 history::URLDatabase* url_db = history_service->InMemoryDatabase(); | 126 history::URLDatabase* url_db = history_service->InMemoryDatabase(); |
| 127 // url_db can be NULL if it hasn't finished initializing (or | 127 // url_db can be NULL if it hasn't finished initializing (or |
| 128 // failed to to initialize). In this case, we let HistoryQuick | 128 // failed to to initialize). In this case, we let HistoryQuick |
| 129 // provider completions compete with the URL-what-you-typed | 129 // provider completions compete with the URL-what-you-typed |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 284 match.RecordAdditionalInfo("visit count", info.visit_count()); | 284 match.RecordAdditionalInfo("visit count", info.visit_count()); |
| 285 match.RecordAdditionalInfo("last visit", info.last_visit()); | 285 match.RecordAdditionalInfo("last visit", info.last_visit()); |
| 286 | 286 |
| 287 return match; | 287 return match; |
| 288 } | 288 } |
| 289 | 289 |
| 290 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { | 290 history::InMemoryURLIndex* HistoryQuickProvider::GetIndex() { |
| 291 if (index_for_testing_.get()) | 291 if (index_for_testing_.get()) |
| 292 return index_for_testing_.get(); | 292 return index_for_testing_.get(); |
| 293 | 293 |
| 294 HistoryService* const history_service = | 294 HistoryService* const history_service = HistoryServiceFactory::GetForProfile( |
| 295 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 295 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
| 296 if (!history_service) | 296 if (!history_service) |
| 297 return NULL; | 297 return NULL; |
| 298 | 298 |
| 299 return history_service->InMemoryIndex(); | 299 return history_service->InMemoryIndex(); |
| 300 } | 300 } |
| OLD | NEW |