| 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 explicit AutocompleteController(const ACProviders& providers) | 602 AutocompleteController(const ACProviders& providers, Profile* profile) |
| 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) { |
| 609 } | 610 } |
| 610 #endif | 611 #endif |
| 611 ~AutocompleteController(); | 612 ~AutocompleteController(); |
| 612 | 613 |
| 613 // Invoked when the profile changes. This forwards the call down to all | 614 // Invoked when the profile changes. This forwards the call down to all |
| 614 // the AutocompleteProviders. | 615 // the AutocompleteProviders. |
| 615 void SetProfile(Profile* profile); | 616 void SetProfile(Profile* profile); |
| 616 | 617 |
| 617 // Starts an autocomplete query, which continues until all providers are | 618 // Starts an autocomplete query, which continues until all providers are |
| 618 // done or the query is Stop()ed. It is safe to Start() a new query without | 619 // 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... |
| 721 // invokes |ExpireCopiedEntries|. | 722 // invokes |ExpireCopiedEntries|. |
| 722 base::OneShotTimer<AutocompleteController> expire_timer_; | 723 base::OneShotTimer<AutocompleteController> expire_timer_; |
| 723 | 724 |
| 724 // True if a query is not currently running. | 725 // True if a query is not currently running. |
| 725 bool done_; | 726 bool done_; |
| 726 | 727 |
| 727 // Are we in Start()? This is used to avoid updating |result_| and sending | 728 // Are we in Start()? This is used to avoid updating |result_| and sending |
| 728 // notifications until Start() has been invoked on all providers. | 729 // notifications until Start() has been invoked on all providers. |
| 729 bool in_start_; | 730 bool in_start_; |
| 730 | 731 |
| 732 Profile* profile_; |
| 733 |
| 731 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); | 734 DISALLOW_COPY_AND_ASSIGN(AutocompleteController); |
| 732 }; | 735 }; |
| 733 | 736 |
| 734 // AutocompleteLog ------------------------------------------------------------ | 737 // AutocompleteLog ------------------------------------------------------------ |
| 735 | 738 |
| 736 // The data to log (via the metrics service) when the user selects an item | 739 // The data to log (via the metrics service) when the user selects an item |
| 737 // from the omnibox popup. | 740 // from the omnibox popup. |
| 738 struct AutocompleteLog { | 741 struct AutocompleteLog { |
| 739 AutocompleteLog(const string16& text, | 742 AutocompleteLog(const string16& text, |
| 740 AutocompleteInput::Type input_type, | 743 AutocompleteInput::Type input_type, |
| (...skipping 12 matching lines...) Expand all Loading... |
| 753 AutocompleteInput::Type input_type; | 756 AutocompleteInput::Type input_type; |
| 754 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). | 757 // Selected index (if selected) or -1 (AutocompletePopupModel::kNoMatch). |
| 755 size_t selected_index; | 758 size_t selected_index; |
| 756 // Inline autocompleted length (if displayed). | 759 // Inline autocompleted length (if displayed). |
| 757 size_t inline_autocompleted_length; | 760 size_t inline_autocompleted_length; |
| 758 // Result set. | 761 // Result set. |
| 759 const AutocompleteResult& result; | 762 const AutocompleteResult& result; |
| 760 }; | 763 }; |
| 761 | 764 |
| 762 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ | 765 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_H_ |
| OLD | NEW |