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 #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/timer.h" | 17 #include "base/timer.h" |
17 #include "googleurl/src/gurl.h" | 18 #include "googleurl/src/gurl.h" |
18 #include "googleurl/src/url_parse.h" | 19 #include "googleurl/src/url_parse.h" |
19 | 20 |
20 // The AutocompleteController is the center of the autocomplete system. A | 21 // The AutocompleteController is the center of the autocomplete system. A |
21 // class creates an instance of the controller, which in turn creates a set of | 22 // class creates an instance of the controller, which in turn creates a set of |
22 // AutocompleteProviders to serve it. The owning class can ask the controller | 23 // AutocompleteProviders to serve it. The owning class can ask the controller |
(...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
661 void DeleteMatch(const AutocompleteMatch& match); | 662 void DeleteMatch(const AutocompleteMatch& match); |
662 | 663 |
663 // Removes any entries that were copied from the last result. This is used by | 664 // Removes any entries that were copied from the last result. This is used by |
664 // the popup to ensure it's not showing an out-of-date query. | 665 // the popup to ensure it's not showing an out-of-date query. |
665 void ExpireCopiedEntries(); | 666 void ExpireCopiedEntries(); |
666 | 667 |
667 #ifdef UNIT_TEST | 668 #ifdef UNIT_TEST |
668 void set_search_provider(SearchProvider* provider) { | 669 void set_search_provider(SearchProvider* provider) { |
669 search_provider_ = provider; | 670 search_provider_ = provider; |
670 } | 671 } |
672 void set_keyword_provider(KeywordProvider* provider) { | |
673 keyword_provider_ = provider; | |
674 } | |
671 #endif | 675 #endif |
672 SearchProvider* search_provider() const { return search_provider_; } | 676 SearchProvider* search_provider() const { return search_provider_; } |
677 KeywordProvider* keyword_provider() const { return keyword_provider_; } | |
673 | 678 |
674 // Getters | 679 // Getters |
675 const AutocompleteInput& input() const { return input_; } | 680 const AutocompleteInput& input() const { return input_; } |
676 const AutocompleteResult& result() const { return result_; } | 681 const AutocompleteResult& result() const { return result_; } |
677 bool done() const { return done_; } | 682 bool done() const { return done_; } |
678 | 683 |
679 // From AutocompleteProvider::Listener | 684 // From AutocompleteProvider::Listener |
680 virtual void OnProviderUpdate(bool updated_matches); | 685 virtual void OnProviderUpdate(bool updated_matches); |
681 | 686 |
682 private: | 687 private: |
688 friend class AutocompleteProviderTest; | |
689 FRIEND_TEST_ALL_PREFIXES(AutocompleteProviderTest, | |
690 RedundantKeywordsIgnoredInResult); | |
Peter Kasting
2011/12/15 22:56:04
Nit: Indent even if possible
| |
691 | |
683 // Updates |result_| to reflect the current provider state. Resets timers and | 692 // Updates |result_| to reflect the current provider state. Resets timers and |
684 // fires notifications as necessary. |is_synchronous_pass| is true only when | 693 // fires notifications as necessary. |is_synchronous_pass| is true only when |
685 // Start() is calling this to get the synchronous result. | 694 // Start() is calling this to get the synchronous result. |
686 void UpdateResult(bool is_synchronous_pass); | 695 void UpdateResult(bool is_synchronous_pass); |
687 | 696 |
697 // Updates |result| to populate each match's |associated_keyword| if that | |
698 // match can show a keyword hint. |result| should be sorted by | |
699 // relevance before this is called. | |
700 void UpdateAssociatedKeywords(AutocompleteResult* result); | |
701 | |
688 // For each group of contiguous matches from the same TemplateURL, show the | 702 // For each group of contiguous matches from the same TemplateURL, show the |
689 // provider name as a description on the first match in the group. | 703 // provider name as a description on the first match in the group. |
690 void UpdateKeywordDescriptions(AutocompleteResult* result); | 704 void UpdateKeywordDescriptions(AutocompleteResult* result); |
691 | 705 |
692 // Calls AutocompleteControllerDelegate::OnResultChanged() and if done sends | 706 // Calls AutocompleteControllerDelegate::OnResultChanged() and if done sends |
693 // AUTOCOMPLETE_CONTROLLER_RESULT_READY. | 707 // AUTOCOMPLETE_CONTROLLER_RESULT_READY. |
694 void NotifyChanged(bool notify_default_match); | 708 void NotifyChanged(bool notify_default_match); |
695 | 709 |
696 // Updates |done_| to be accurate with respect to current providers' statuses. | 710 // Updates |done_| to be accurate with respect to current providers' statuses. |
697 void CheckIfDone(); | 711 void CheckIfDone(); |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
752 AutocompleteInput::Type input_type; | 766 AutocompleteInput::Type input_type; |
753 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). | 767 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). |
754 size_t selected_index; | 768 size_t selected_index; |
755 // Inline autocompleted length (if displayed). | 769 // Inline autocompleted length (if displayed). |
756 size_t inline_autocompleted_length; | 770 size_t inline_autocompleted_length; |
757 // Result set. | 771 // Result set. |
758 const AutocompleteResult& result; | 772 const AutocompleteResult& result; |
759 }; | 773 }; |
760 | 774 |
761 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 775 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
OLD | NEW |