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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 // Add a beacon to the logs that'll allow us to identify later what | 97 // Add a beacon to the logs that'll allow us to identify later what |
98 // inlining state a user is in. Do this by incrementing a bucket in | 98 // inlining state a user is in. Do this by incrementing a bucket in |
99 // a histogram, where the bucket represents the user's inlining state. | 99 // a histogram, where the bucket represents the user's inlining state. |
100 UMA_HISTOGRAM_ENUMERATION( | 100 UMA_HISTOGRAM_ENUMERATION( |
101 "Omnibox.InlineHistoryQuickProviderFieldTrialBeacon", | 101 "Omnibox.InlineHistoryQuickProviderFieldTrialBeacon", |
102 inlining_option, NUM_OPTIONS); | 102 inlining_option, NUM_OPTIONS); |
103 } | 103 } |
104 | 104 |
105 HistoryQuickProvider::~HistoryQuickProvider() {} | |
106 | |
107 void HistoryQuickProvider::Start(const AutocompleteInput& input, | 105 void HistoryQuickProvider::Start(const AutocompleteInput& input, |
108 bool minimal_changes) { | 106 bool minimal_changes) { |
109 matches_.clear(); | 107 matches_.clear(); |
110 if (disabled_) | 108 if (disabled_) |
111 return; | 109 return; |
112 | 110 |
113 // Don't bother with INVALID and FORCED_QUERY. Also pass when looking for | 111 // Don't bother with INVALID and FORCED_QUERY. Also pass when looking for |
114 // BEST_MATCH and there is no inline autocompletion because none of the HQP | 112 // BEST_MATCH and there is no inline autocompletion because none of the HQP |
115 // matches can score highly enough to qualify. | 113 // matches can score highly enough to qualify. |
116 if ((input.type() == AutocompleteInput::INVALID) || | 114 if ((input.type() == AutocompleteInput::INVALID) || |
(...skipping 18 matching lines...) Expand all Loading... |
135 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); | 133 name, 1, 1000, 50, base::Histogram::kUmaTargetedHistogramFlag); |
136 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); | 134 counter->Add(static_cast<int>((end_time - start_time).InMilliseconds())); |
137 } | 135 } |
138 UpdateStarredStateOfMatches(); | 136 UpdateStarredStateOfMatches(); |
139 } | 137 } |
140 } | 138 } |
141 | 139 |
142 // TODO(mrossetti): Implement this function. (Will happen in next CL.) | 140 // TODO(mrossetti): Implement this function. (Will happen in next CL.) |
143 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} | 141 void HistoryQuickProvider::DeleteMatch(const AutocompleteMatch& match) {} |
144 | 142 |
| 143 HistoryQuickProvider::~HistoryQuickProvider() {} |
| 144 |
145 void HistoryQuickProvider::DoAutocomplete() { | 145 void HistoryQuickProvider::DoAutocomplete() { |
146 // Get the matching URLs from the DB. | 146 // Get the matching URLs from the DB. |
147 string16 term_string = autocomplete_input_.text(); | 147 string16 term_string = autocomplete_input_.text(); |
148 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(term_string); | 148 ScoredHistoryMatches matches = GetIndex()->HistoryItemsForTerms(term_string); |
149 if (matches.empty()) | 149 if (matches.empty()) |
150 return; | 150 return; |
151 | 151 |
152 // Loop over every result and add it to matches_. In the process, | 152 // Loop over every result and add it to matches_. In the process, |
153 // guarantee that scores are decreasing. |max_match_score| keeps | 153 // guarantee that scores are decreasing. |max_match_score| keeps |
154 // track of the highest score we can assign to any later results we | 154 // track of the highest score we can assign to any later results we |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
268 do { | 268 do { |
269 offset += matches[i].length; | 269 offset += matches[i].length; |
270 ++i; | 270 ++i; |
271 } while ((i < match_count) && (offset == matches[i].offset)); | 271 } while ((i < match_count) && (offset == matches[i].offset)); |
272 if (offset < text_length) | 272 if (offset < text_length) |
273 spans.push_back(ACMatchClassification(offset, url_style)); | 273 spans.push_back(ACMatchClassification(offset, url_style)); |
274 } | 274 } |
275 | 275 |
276 return spans; | 276 return spans; |
277 } | 277 } |
OLD | NEW |