| 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/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/i18n/break_iterator.h" | 10 #include "base/i18n/break_iterator.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 if ((input.type() == AutocompleteInput::INVALID) || | 53 if ((input.type() == AutocompleteInput::INVALID) || |
| 54 (input.type() == AutocompleteInput::FORCED_QUERY) || | 54 (input.type() == AutocompleteInput::FORCED_QUERY) || |
| 55 (input.matches_requested() == AutocompleteInput::BEST_MATCH && | 55 (input.matches_requested() == AutocompleteInput::BEST_MATCH && |
| 56 input.prevent_inline_autocomplete())) | 56 input.prevent_inline_autocomplete())) |
| 57 return; | 57 return; |
| 58 | 58 |
| 59 autocomplete_input_ = input; | 59 autocomplete_input_ = input; |
| 60 | 60 |
| 61 // Do some fixup on the user input before matching against it, so we provide | 61 // Do some fixup on the user input before matching against it, so we provide |
| 62 // good results for local file paths, input with spaces, etc. | 62 // good results for local file paths, input with spaces, etc. |
| 63 // NOTE: This purposefully doesn't take input.desired_tld() into account; if | 63 if (!FixupUserInput(&autocomplete_input_)) |
| 64 // it did, then holding "ctrl" would change all the results from the | |
| 65 // HistoryQuickProvider provider, not just the What You Typed Result. | |
| 66 const string16 fixed_text(FixupUserInput(input)); | |
| 67 if (fixed_text.empty()) { | |
| 68 // Conceivably fixup could result in an empty string (although I don't | |
| 69 // have cases where this happens offhand). We can't do anything with | |
| 70 // empty input, so just bail; otherwise we'd crash later. | |
| 71 return; | 64 return; |
| 72 } | |
| 73 autocomplete_input_.set_text(fixed_text); | |
| 74 | 65 |
| 75 // TODO(pkasting): We should just block here until this loads. Any time | 66 // TODO(pkasting): We should just block here until this loads. Any time |
| 76 // someone unloads the history backend, we'll get inconsistent inline | 67 // someone unloads the history backend, we'll get inconsistent inline |
| 77 // autocomplete behavior here. | 68 // autocomplete behavior here. |
| 78 if (GetIndex()) { | 69 if (GetIndex()) { |
| 79 base::TimeTicks start_time = base::TimeTicks::Now(); | 70 base::TimeTicks start_time = base::TimeTicks::Now(); |
| 80 DoAutocomplete(); | 71 DoAutocomplete(); |
| 81 if (input.text().length() < 6) { | 72 if (input.text().length() < 6) { |
| 82 base::TimeTicks end_time = base::TimeTicks::Now(); | 73 base::TimeTicks end_time = base::TimeTicks::Now(); |
| 83 std::string name = "HistoryQuickProvider.QueryIndexTime." + | 74 std::string name = "HistoryQuickProvider.QueryIndexTime." + |
| (...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 do { | 237 do { |
| 247 offset += matches[i].length; | 238 offset += matches[i].length; |
| 248 ++i; | 239 ++i; |
| 249 } while ((i < match_count) && (offset == matches[i].offset)); | 240 } while ((i < match_count) && (offset == matches[i].offset)); |
| 250 if (offset < text_length) | 241 if (offset < text_length) |
| 251 spans.push_back(ACMatchClassification(offset, url_style)); | 242 spans.push_back(ACMatchClassification(offset, url_style)); |
| 252 } | 243 } |
| 253 | 244 |
| 254 return spans; | 245 return spans; |
| 255 } | 246 } |
| OLD | NEW |