| 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 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
| 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include <map> | 9 #include <map> |
| 10 #include <string> | 10 #include <string> |
| 11 #include <vector> | 11 #include <vector> |
| 12 | 12 |
| 13 #include "base/gtest_prod_util.h" |
| 13 #include "base/logging.h" | 14 #include "base/logging.h" |
| 14 #include "base/memory/ref_counted.h" | 15 #include "base/memory/ref_counted.h" |
| 15 #include "base/string16.h" | 16 #include "base/string16.h" |
| 16 #include "base/time.h" | 17 #include "base/time.h" |
| 17 #include "base/timer.h" | 18 #include "base/timer.h" |
| 18 #include "chrome/browser/sessions/session_id.h" | 19 #include "chrome/browser/sessions/session_id.h" |
| 19 #include "googleurl/src/gurl.h" | 20 #include "googleurl/src/gurl.h" |
| 20 #include "googleurl/src/url_parse.h" | 21 #include "googleurl/src/url_parse.h" |
| 21 | 22 |
| 22 // The AutocompleteController is the center of the autocomplete system. A | 23 // The AutocompleteController is the center of the autocomplete system. A |
| (...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 671 void DeleteMatch(const AutocompleteMatch& match); | 672 void DeleteMatch(const AutocompleteMatch& match); |
| 672 | 673 |
| 673 // Removes any entries that were copied from the last result. This is used by | 674 // Removes any entries that were copied from the last result. This is used by |
| 674 // the popup to ensure it's not showing an out-of-date query. | 675 // the popup to ensure it's not showing an out-of-date query. |
| 675 void ExpireCopiedEntries(); | 676 void ExpireCopiedEntries(); |
| 676 | 677 |
| 677 #ifdef UNIT_TEST | 678 #ifdef UNIT_TEST |
| 678 void set_search_provider(SearchProvider* provider) { | 679 void set_search_provider(SearchProvider* provider) { |
| 679 search_provider_ = provider; | 680 search_provider_ = provider; |
| 680 } | 681 } |
| 682 void set_keyword_provider(KeywordProvider* provider) { |
| 683 keyword_provider_ = provider; |
| 684 } |
| 681 #endif | 685 #endif |
| 682 SearchProvider* search_provider() const { return search_provider_; } | 686 SearchProvider* search_provider() const { return search_provider_; } |
| 687 KeywordProvider* keyword_provider() const { return keyword_provider_; } |
| 683 | 688 |
| 684 // Getters | 689 // Getters |
| 685 const AutocompleteInput& input() const { return input_; } | 690 const AutocompleteInput& input() const { return input_; } |
| 686 const AutocompleteResult& result() const { return result_; } | 691 const AutocompleteResult& result() const { return result_; } |
| 687 bool done() const { return done_; } | 692 bool done() const { return done_; } |
| 688 const ACProviders* providers() const { return &providers_; } | 693 const ACProviders* providers() const { return &providers_; } |
| 689 | 694 |
| 690 // From AutocompleteProvider::Listener | 695 // From AutocompleteProvider::Listener |
| 691 virtual void OnProviderUpdate(bool updated_matches); | 696 virtual void OnProviderUpdate(bool updated_matches); |
| 692 | 697 |
| 693 private: | 698 private: |
| 699 friend class AutocompleteProviderTest; |
| 700 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, |
| 701 RedundantKeywordsIgnoredInResult); |
| 702 |
| 694 // Updates |result_| to reflect the current provider state. Resets timers and | 703 // Updates |result_| to reflect the current provider state. Resets timers and |
| 695 // fires notifications as necessary. |is_synchronous_pass| is true only when | 704 // fires notifications as necessary. |is_synchronous_pass| is true only when |
| 696 // Start() is calling this to get the synchronous result. | 705 // Start() is calling this to get the synchronous result. |
| 697 void UpdateResult(bool is_synchronous_pass); | 706 void UpdateResult(bool is_synchronous_pass); |
| 698 | 707 |
| 708 // Updates |result| to populate each match's |associated_keyword| if that |
| 709 // match can show a keyword hint. |result| should be sorted by |
| 710 // relevance before this is called. |
| 711 void UpdateAssociatedKeywords(AutocompleteResult* result); |
| 712 |
| 699 // For each group of contiguous matches from the same TemplateURL, show the | 713 // For each group of contiguous matches from the same TemplateURL, show the |
| 700 // provider name as a description on the first match in the group. | 714 // provider name as a description on the first match in the group. |
| 701 void UpdateKeywordDescriptions(AutocompleteResult* result); | 715 void UpdateKeywordDescriptions(AutocompleteResult* result); |
| 702 | 716 |
| 703 // Calls AutocompleteControllerDelegate::OnResultChanged() and if done sends | 717 // Calls AutocompleteControllerDelegate::OnResultChanged() and if done sends |
| 704 // AUTOCOMPLETE_CONTROLLER_RESULT_READY. | 718 // AUTOCOMPLETE_CONTROLLER_RESULT_READY. |
| 705 void NotifyChanged(bool notify_default_match); | 719 void NotifyChanged(bool notify_default_match); |
| 706 | 720 |
| 707 // Updates |done_| to be accurate with respect to current providers' statuses. | 721 // Updates |done_| to be accurate with respect to current providers' statuses. |
| 708 void CheckIfDone(); | 722 void CheckIfDone(); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 772 // the time the user began typing (this should only happen in | 786 // the time the user began typing (this should only happen in |
| 773 // unit tests), this elapsed time is set to -1 milliseconds. | 787 // unit tests), this elapsed time is set to -1 milliseconds. |
| 774 base::TimeDelta elapsed_time_since_user_first_modified_omnibox; | 788 base::TimeDelta elapsed_time_since_user_first_modified_omnibox; |
| 775 // Inline autocompleted length (if displayed). | 789 // Inline autocompleted length (if displayed). |
| 776 size_t inline_autocompleted_length; | 790 size_t inline_autocompleted_length; |
| 777 // Result set. | 791 // Result set. |
| 778 const AutocompleteResult& result; | 792 const AutocompleteResult& result; |
| 779 }; | 793 }; |
| 780 | 794 |
| 781 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 795 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
| OLD | NEW |