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