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" |
11 #include "chrome/browser/autocomplete/autocomplete_edit.h" | 11 #include "chrome/browser/autocomplete/autocomplete_edit.h" |
12 | 12 |
13 class AutocompletePopupView; | 13 class AutocompletePopupView; |
14 class Profile; | |
15 class SkBitmap; | 14 class SkBitmap; |
16 | 15 |
17 class AutocompletePopupModel { | 16 class AutocompletePopupModel { |
18 public: | 17 public: |
19 AutocompletePopupModel(AutocompletePopupView* popup_view, | 18 AutocompletePopupModel(AutocompletePopupView* popup_view, |
20 AutocompleteEditModel* edit_model, | 19 AutocompleteEditModel* edit_model); |
21 Profile* profile); | |
22 ~AutocompletePopupModel(); | 20 ~AutocompletePopupModel(); |
23 | 21 |
24 // Invoked when the profile has changed. | |
25 void set_profile(Profile* profile) { profile_ = profile; } | |
26 | |
27 // TODO(sky): see about removing this. | |
28 Profile* profile() const { return profile_; } | |
29 | |
30 // Returns true if the popup is currently open. | 22 // Returns true if the popup is currently open. |
31 bool IsOpen() const; | 23 bool IsOpen() const; |
32 | 24 |
33 AutocompletePopupView* view() const { return view_; } | 25 AutocompletePopupView* view() const { return view_; } |
34 | 26 |
35 // Returns the AutocompleteController used by this popup. | 27 // Returns the AutocompleteController used by this popup. |
36 AutocompleteController* autocomplete_controller() const { | 28 AutocompleteController* autocomplete_controller() const { |
37 return edit_model_->autocomplete_controller(); | 29 return edit_model_->autocomplete_controller(); |
38 } | 30 } |
39 | 31 |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 | 100 |
109 // The token value for selected_line_, hover_line_ and functions dealing with | 101 // The token value for selected_line_, hover_line_ and functions dealing with |
110 // a "line number" that indicates "no line". | 102 // a "line number" that indicates "no line". |
111 static const size_t kNoMatch = -1; | 103 static const size_t kNoMatch = -1; |
112 | 104 |
113 private: | 105 private: |
114 AutocompletePopupView* view_; | 106 AutocompletePopupView* view_; |
115 | 107 |
116 AutocompleteEditModel* edit_model_; | 108 AutocompleteEditModel* edit_model_; |
117 | 109 |
118 // Profile for current tab. | |
119 Profile* profile_; | |
120 | |
121 // The line that's currently hovered. If we're not drawing a hover rect, | 110 // The line that's currently hovered. If we're not drawing a hover rect, |
122 // this will be kNoMatch, even if the cursor is over the popup contents. | 111 // this will be kNoMatch, even if the cursor is over the popup contents. |
123 size_t hovered_line_; | 112 size_t hovered_line_; |
124 | 113 |
125 // The currently selected line. This is kNoMatch when nothing is selected, | 114 // The currently selected line. This is kNoMatch when nothing is selected, |
126 // which should only be true when the popup is closed. | 115 // which should only be true when the popup is closed. |
127 size_t selected_line_; | 116 size_t selected_line_; |
128 | 117 |
129 // The match the user has manually chosen, if any. | 118 // The match the user has manually chosen, if any. |
130 AutocompleteResult::Selection manually_selected_match_; | 119 AutocompleteResult::Selection manually_selected_match_; |
131 | 120 |
132 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupModel); | 121 DISALLOW_COPY_AND_ASSIGN(AutocompletePopupModel); |
133 }; | 122 }; |
134 | 123 |
135 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ | 124 #endif // CHROME_BROWSER_AUTOCOMPLETE_AUTOCOMPLETE_POPUP_MODEL_H_ |
OLD | NEW |