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/shortcuts_provider.h" | 5 #include "chrome/browser/autocomplete/shortcuts_provider.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <cmath> | 8 #include <cmath> |
9 #include <map> | 9 #include <map> |
10 #include <vector> | 10 #include <vector> |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 shortcuts_backend_->RemoveObserver(this); | 69 shortcuts_backend_->RemoveObserver(this); |
70 } | 70 } |
71 | 71 |
72 void ShortcutsProvider::Start(const AutocompleteInput& input, | 72 void ShortcutsProvider::Start(const AutocompleteInput& input, |
73 bool minimal_changes) { | 73 bool minimal_changes) { |
74 matches_.clear(); | 74 matches_.clear(); |
75 | 75 |
76 if (input.type() == AutocompleteInput::INVALID) | 76 if (input.type() == AutocompleteInput::INVALID) |
77 return; | 77 return; |
78 | 78 |
| 79 if (input.text().empty()) |
| 80 return; |
| 81 |
79 if (!initialized_) | 82 if (!initialized_) |
80 return; | 83 return; |
81 | 84 |
82 base::TimeTicks start_time = base::TimeTicks::Now(); | 85 base::TimeTicks start_time = base::TimeTicks::Now(); |
83 GetMatches(input); | 86 GetMatches(input); |
84 if (input.text().length() < 6) { | 87 if (input.text().length() < 6) { |
85 base::TimeTicks end_time = base::TimeTicks::Now(); | 88 base::TimeTicks end_time = base::TimeTicks::Now(); |
86 std::string name = "ShortcutsProvider.QueryIndexTime." + | 89 std::string name = "ShortcutsProvider.QueryIndexTime." + |
87 base::IntToString(input.text().size()); | 90 base::IntToString(input.text().size()); |
88 base::Histogram* counter = base::Histogram::FactoryGet( | 91 base::Histogram* counter = base::Histogram::FactoryGet( |
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
300 | 303 |
301 void ShortcutsProvider::set_shortcuts_backend( | 304 void ShortcutsProvider::set_shortcuts_backend( |
302 history::ShortcutsBackend* shortcuts_backend) { | 305 history::ShortcutsBackend* shortcuts_backend) { |
303 DCHECK(shortcuts_backend); | 306 DCHECK(shortcuts_backend); |
304 shortcuts_backend_ = shortcuts_backend; | 307 shortcuts_backend_ = shortcuts_backend; |
305 shortcuts_backend_->AddObserver(this); | 308 shortcuts_backend_->AddObserver(this); |
306 if (shortcuts_backend_->initialized()) | 309 if (shortcuts_backend_->initialized()) |
307 initialized_ = true; | 310 initialized_ = true; |
308 } | 311 } |
309 | 312 |
OLD | NEW |