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