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_POPUP_MODEL_H_ | 5 #ifndef CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ |
6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ | 6 #define CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
10 #include "chrome/browser/autocomplete/autocomplete.h" | 10 #include "chrome/browser/autocomplete/autocomplete.h" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
63 // be updated forcibly even if the |line| is same as the current selected | 63 // be updated forcibly even if the |line| is same as the current selected |
64 // line. | 64 // line. |
65 // NOTE: This assumes the popup is open, and thus both old and new values for | 65 // NOTE: This assumes the popup is open, and thus both old and new values for |
66 // the selected line should not be kNoMatch. | 66 // the selected line should not be kNoMatch. |
67 void SetSelectedLine(size_t line, bool reset_to_default, bool force); | 67 void SetSelectedLine(size_t line, bool reset_to_default, bool force); |
68 | 68 |
69 // Called when the user hits escape after arrowing around the popup. This | 69 // Called when the user hits escape after arrowing around the popup. This |
70 // will change the selected line back to the default match and redraw. | 70 // will change the selected line back to the default match and redraw. |
71 void ResetToDefaultMatch(); | 71 void ResetToDefaultMatch(); |
72 | 72 |
73 // Gets the selected keyword or keyword hint for the given match. If the match | |
74 // is already keyword, then the keyword will be returned directly. Otherwise, | |
75 // it returns GetKeywordForText(match.fill_into_edit, keyword). | |
76 bool GetKeywordForMatch(const AutocompleteMatch& match, | |
77 string16* keyword) const; | |
78 | |
79 // Gets the selected keyword or keyword hint for the given text. Returns | |
80 // true if |keyword| represents a keyword hint, or false if |keyword| | |
81 // represents a selected keyword. (|keyword| will always be set [though | |
82 // possibly to the empty string], and you cannot have both a selected keyword | |
83 // and a keyword hint simultaneously.) | |
84 bool GetKeywordForText(const string16& text, string16* keyword) const; | |
85 | |
86 // Immediately updates and opens the popup if necessary, then moves the | 73 // Immediately updates and opens the popup if necessary, then moves the |
87 // current selection down (|count| > 0) or up (|count| < 0), clamping to the | 74 // current selection down (|count| > 0) or up (|count| < 0), clamping to the |
88 // first or last result if necessary. If |count| == 0, the selection will be | 75 // first or last result if necessary. If |count| == 0, the selection will be |
89 // unchanged, but the popup will still redraw and modify the text in the | 76 // unchanged, but the popup will still redraw and modify the text in the |
90 // AutocompleteEditModel. | 77 // AutocompleteEditModel. |
91 void Move(int count); | 78 void Move(int count); |
92 | 79 |
93 // Called when the user hits shift-delete. This should determine if the item | 80 // Called when the user hits shift-delete. This should determine if the item |
94 // can be removed from history, and if so, remove it and update the popup. | 81 // can be removed from history, and if so, remove it and update the popup. |
95 void TryDeletingCurrentItem(); | 82 void TryDeletingCurrentItem(); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
127 // which should only be true when the popup is closed. | 114 // which should only be true when the popup is closed. |
128 size_t selected_line_; | 115 size_t selected_line_; |
129 | 116 |
130 // The match the user has manually chosen, if any. | 117 // The match the user has manually chosen, if any. |
131 AutocompleteResult::Selection manually_selected_match_; | 118 AutocompleteResult::Selection manually_selected_match_; |
132 | 119 |
133 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupModel); | 120 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupModel); |
134 }; | 121 }; |
135 | 122 |
136 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ | 123 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ |
OLD | NEW |