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> |
(...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
592 // Used to indicate an index that is not selected in a call to Update(). | 592 // Used to indicate an index that is not selected in a call to Update(). |
593 static const int kNoItemSelected; | 593 static const int kNoItemSelected; |
594 | 594 |
595 // Normally, you will call the first constructor. Unit tests can use the | 595 // Normally, you will call the first constructor. Unit tests can use the |
596 // second to set the providers to some known testing providers. The default | 596 // second to set the providers to some known testing providers. The default |
597 // providers will be overridden and the controller will take ownership of the | 597 // providers will be overridden and the controller will take ownership of the |
598 // providers, Release()ing them on destruction. | 598 // providers, Release()ing them on destruction. |
599 AutocompleteController(Profile* profile, | 599 AutocompleteController(Profile* profile, |
600 AutocompleteControllerDelegate* delegate); | 600 AutocompleteControllerDelegate* delegate); |
601 #ifdef UNIT_TEST | 601 #ifdef UNIT_TEST |
602 AutocompleteController(const ACProviders& providers, Profile* profile) | 602 explicit AutocompleteController(const ACProviders& providers) |
603 : delegate_(NULL), | 603 : delegate_(NULL), |
604 providers_(providers), | 604 providers_(providers), |
605 keyword_provider_(NULL), | 605 keyword_provider_(NULL), |
606 search_provider_(NULL), | 606 search_provider_(NULL), |
607 done_(true), | 607 done_(true), |
608 in_start_(false), | 608 in_start_(false) { |
609 profile_(profile) { | |
610 } | 609 } |
611 #endif | 610 #endif |
612 ~AutocompleteController(); | 611 ~AutocompleteController(); |
613 | 612 |
614 // Invoked when the profile changes. This forwards the call down to all | 613 // Invoked when the profile changes. This forwards the call down to all |
615 // the AutocompleteProviders. | 614 // the AutocompleteProviders. |
616 void SetProfile(Profile* profile); | 615 void SetProfile(Profile* profile); |
617 | 616 |
618 // Starts an autocomplete query, which continues until all providers are | 617 // Starts an autocomplete query, which continues until all providers are |
619 // done or the query is Stop()ed. It is safe to Start() a new query without | 618 // done or the query is Stop()ed. It is safe to Start() a new query without |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
722 // invokes |ExpireCopiedEntries|. | 721 // invokes |ExpireCopiedEntries|. |
723 base::OneShotTimer<AutocompleteController> expire_timer_; | 722 base::OneShotTimer<AutocompleteController> expire_timer_; |
724 | 723 |
725 // True if a query is not currently running. | 724 // True if a query is not currently running. |
726 bool done_; | 725 bool done_; |
727 | 726 |
728 // Are we in Start()? This is used to avoid updating |result_| and sending | 727 // Are we in Start()? This is used to avoid updating |result_| and sending |
729 // notifications until Start() has been invoked on all providers. | 728 // notifications until Start() has been invoked on all providers. |
730 bool in_start_; | 729 bool in_start_; |
731 | 730 |
732 Profile* profile_; | |
733 | |
734 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); | 731 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); |
735 }; | 732 }; |
736 | 733 |
737 // AutocompleteLog ------------------------------------------------------------ | 734 // AutocompleteLog ------------------------------------------------------------ |
738 | 735 |
739 // The data to log (via the metrics service) when the user selects an item | 736 // The data to log (via the metrics service) when the user selects an item |
740 // from the omnibox popup. | 737 // from the omnibox popup. |
741 struct AutocompleteLog { | 738 struct AutocompleteLog { |
742 AutocompleteLog(const string16& text, | 739 AutocompleteLog(const string16& text, |
743 AutocompleteInput::Type input_type, | 740 AutocompleteInput::Type input_type, |
(...skipping 12 matching lines...) Expand all Loading... |
756 AutocompleteInput::Type input_type; | 753 AutocompleteInput::Type input_type; |
757 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). | 754 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). |
758 size_t selected_index; | 755 size_t selected_index; |
759 // Inline autocompleted length (if displayed). | 756 // Inline autocompleted length (if displayed). |
760 size_t inline_autocompleted_length; | 757 size_t inline_autocompleted_length; |
761 // Result set. | 758 // Result set. |
762 const AutocompleteResult& result; | 759 const AutocompleteResult& result; |
763 }; | 760 }; |
764 | 761 |
765 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 762 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
OLD | NEW |