| 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_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ | 5 #ifndef CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ |
| 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ | 6 #define CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/observer_list.h" |
| 9 #include "chrome/browser/autocomplete/autocomplete_controller.h" | 10 #include "chrome/browser/autocomplete/autocomplete_controller.h" |
| 10 #include "chrome/browser/autocomplete/autocomplete_result.h" | 11 #include "chrome/browser/autocomplete/autocomplete_result.h" |
| 11 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" | 12 #include "chrome/browser/ui/omnibox/omnibox_edit_model.h" |
| 12 | 13 |
| 14 class OmniboxPopupModelObserver; |
| 13 class OmniboxPopupView; | 15 class OmniboxPopupView; |
| 14 | 16 |
| 15 namespace gfx { | 17 namespace gfx { |
| 16 class Image; | 18 class Image; |
| 17 } | 19 } |
| 18 | 20 |
| 19 class OmniboxPopupModel { | 21 class OmniboxPopupModel { |
| 20 public: | 22 public: |
| 21 // See selected_line_state_ for details. | 23 // See selected_line_state_ for details. |
| 22 enum LineState { | 24 enum LineState { |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 | 91 |
| 90 // The match the user has manually chosen, if any. | 92 // The match the user has manually chosen, if any. |
| 91 const AutocompleteResult::Selection& manually_selected_match() const { | 93 const AutocompleteResult::Selection& manually_selected_match() const { |
| 92 return manually_selected_match_; | 94 return manually_selected_match_; |
| 93 } | 95 } |
| 94 | 96 |
| 95 // Invoked from the edit model any time the result set of the controller | 97 // Invoked from the edit model any time the result set of the controller |
| 96 // changes. | 98 // changes. |
| 97 void OnResultChanged(); | 99 void OnResultChanged(); |
| 98 | 100 |
| 101 // Add and remove observers. |
| 102 void AddObserver(OmniboxPopupModelObserver* observer); |
| 103 void RemoveObserver(OmniboxPopupModelObserver* observer); |
| 104 |
| 99 // The token value for selected_line_, hover_line_ and functions dealing with | 105 // The token value for selected_line_, hover_line_ and functions dealing with |
| 100 // a "line number" that indicates "no line". | 106 // a "line number" that indicates "no line". |
| 101 static const size_t kNoMatch; | 107 static const size_t kNoMatch; |
| 102 | 108 |
| 103 private: | 109 private: |
| 104 OmniboxPopupView* view_; | 110 OmniboxPopupView* view_; |
| 105 | 111 |
| 106 OmniboxEditModel* edit_model_; | 112 OmniboxEditModel* edit_model_; |
| 107 | 113 |
| 108 // The line that's currently hovered. If we're not drawing a hover rect, | 114 // The line that's currently hovered. If we're not drawing a hover rect, |
| 109 // this will be kNoMatch, even if the cursor is over the popup contents. | 115 // this will be kNoMatch, even if the cursor is over the popup contents. |
| 110 size_t hovered_line_; | 116 size_t hovered_line_; |
| 111 | 117 |
| 112 // The currently selected line. This is kNoMatch when nothing is selected, | 118 // The currently selected line. This is kNoMatch when nothing is selected, |
| 113 // which should only be true when the popup is closed. | 119 // which should only be true when the popup is closed. |
| 114 size_t selected_line_; | 120 size_t selected_line_; |
| 115 | 121 |
| 116 // If the selected line has both a normal match and a keyword match, this | 122 // If the selected line has both a normal match and a keyword match, this |
| 117 // determines whether the normal match (if NORMAL) or the keyword match | 123 // determines whether the normal match (if NORMAL) or the keyword match |
| 118 // (if KEYWORD) is selected. | 124 // (if KEYWORD) is selected. |
| 119 LineState selected_line_state_; | 125 LineState selected_line_state_; |
| 120 | 126 |
| 121 // The match the user has manually chosen, if any. | 127 // The match the user has manually chosen, if any. |
| 122 AutocompleteResult::Selection manually_selected_match_; | 128 AutocompleteResult::Selection manually_selected_match_; |
| 123 | 129 |
| 130 // Observers. |
| 131 ObserverList<OmniboxPopupModelObserver> observers_; |
| 132 |
| 124 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModel); | 133 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupModel); |
| 125 }; | 134 }; |
| 126 | 135 |
| 127 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ | 136 #endif // CHROME_BROWSER_UI_OMNIBOX_OMNIBOX_POPUP_MODEL_H_ |
| OLD | NEW |