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/autocomplete_controller.h" | 5 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/format_macros.h" | 10 #include "base/format_macros.h" |
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 stop_timer_.Stop(); | 320 stop_timer_.Stop(); |
321 done_ = true; | 321 done_ = true; |
322 if (clear_result && !result_.empty()) { | 322 if (clear_result && !result_.empty()) { |
323 result_.Reset(); | 323 result_.Reset(); |
324 // NOTE: We pass in false since we're trying to only clear the popup, not | 324 // NOTE: We pass in false since we're trying to only clear the popup, not |
325 // touch the edit... this is all a mess and should be cleaned up :( | 325 // touch the edit... this is all a mess and should be cleaned up :( |
326 NotifyChanged(false); | 326 NotifyChanged(false); |
327 } | 327 } |
328 } | 328 } |
329 | 329 |
330 void AutocompleteController::StartZeroSuggest(const AutocompleteInput& input) { | 330 void AutocompleteController::OnOmniboxFocused(const AutocompleteInput& input) { |
331 if (zero_suggest_provider_ == NULL) | |
332 return; | |
333 | |
334 DCHECK(!in_start_); // We should not be already running a query. | 331 DCHECK(!in_start_); // We should not be already running a query. |
335 | 332 |
336 // Call Start() on all prefix-based providers with an INVALID | 333 // Call Start() on all prefix-based providers with an INVALID |
337 // AutocompleteInput to clear out cached |matches_|, which ensures that | 334 // AutocompleteInput to clear out cached |matches_|, which ensures that |
338 // they aren't used with zero suggest. | 335 // they aren't used with zero suggest. |
339 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { | 336 for (Providers::iterator i(providers_.begin()); i != providers_.end(); ++i) { |
340 if (i->get() == zero_suggest_provider_) | 337 if ((*i)->ProvidesMatchesOnOmniboxFocus()) |
341 (*i)->Start(input, false); | 338 (*i)->Start(input, false); |
342 else | 339 else |
343 (*i)->Start(AutocompleteInput(), false); | 340 (*i)->Start(AutocompleteInput(), false); |
344 } | 341 } |
345 | 342 |
346 if (!zero_suggest_provider_->matches().empty()) | 343 UpdateResult(false, false); |
347 UpdateResult(false, false); | |
348 } | 344 } |
349 | 345 |
350 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { | 346 void AutocompleteController::DeleteMatch(const AutocompleteMatch& match) { |
351 DCHECK(match.SupportsDeletion()); | 347 DCHECK(match.SupportsDeletion()); |
352 | 348 |
353 // Delete duplicate matches attached to the main match first. | 349 // Delete duplicate matches attached to the main match first. |
354 for (ACMatches::const_iterator it(match.duplicate_matches.begin()); | 350 for (ACMatches::const_iterator it(match.duplicate_matches.begin()); |
355 it != match.duplicate_matches.end(); ++it) { | 351 it != match.duplicate_matches.end(); ++it) { |
356 if (it->deletable) | 352 if (it->deletable) |
357 it->provider->DeleteMatch(*it); | 353 it->provider->DeleteMatch(*it); |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 this, &AutocompleteController::ExpireCopiedEntries); | 675 this, &AutocompleteController::ExpireCopiedEntries); |
680 } | 676 } |
681 | 677 |
682 void AutocompleteController::StartStopTimer() { | 678 void AutocompleteController::StartStopTimer() { |
683 stop_timer_.Start(FROM_HERE, | 679 stop_timer_.Start(FROM_HERE, |
684 stop_timer_duration_, | 680 stop_timer_duration_, |
685 base::Bind(&AutocompleteController::Stop, | 681 base::Bind(&AutocompleteController::Stop, |
686 base::Unretained(this), | 682 base::Unretained(this), |
687 false)); | 683 false)); |
688 } | 684 } |
OLD | NEW |