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