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 UI_APP_LIST_SEARCH_RESULT_H_ | 5 #ifndef UI_APP_LIST_SEARCH_RESULT_H_ |
6 #define UI_APP_LIST_SEARCH_RESULT_H_ | 6 #define UI_APP_LIST_SEARCH_RESULT_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
12 #include "base/observer_list.h" | 12 #include "base/observer_list.h" |
13 #include "base/strings/string16.h" | 13 #include "base/strings/string16.h" |
14 #include "ui/app_list/app_list_export.h" | 14 #include "ui/app_list/app_list_export.h" |
15 #include "ui/gfx/image/image_skia.h" | 15 #include "ui/gfx/image/image_skia.h" |
16 #include "ui/gfx/range/range.h" | 16 #include "ui/gfx/range/range.h" |
17 | 17 |
18 namespace ui { | 18 namespace ui { |
19 class MenuModel; | 19 class MenuModel; |
20 } | 20 } |
21 | 21 |
22 namespace app_list { | 22 namespace app_list { |
23 | 23 |
24 class SearchResultObserver; | 24 class SearchResultObserver; |
| 25 class TokenizedString; |
| 26 class TokenizedStringMatch; |
25 | 27 |
26 // SearchResult consists of an icon, title text and details text. Title and | 28 // SearchResult consists of an icon, title text and details text. Title and |
27 // details text can have tagged ranges that are displayed differently from | 29 // details text can have tagged ranges that are displayed differently from |
28 // default style. | 30 // default style. |
29 class APP_LIST_EXPORT SearchResult { | 31 class APP_LIST_EXPORT SearchResult { |
30 public: | 32 public: |
31 // How the result should be displayed. Do not change the order of these as | 33 // How the result should be displayed. Do not change the order of these as |
32 // they are used for metrics. | 34 // they are used for metrics. |
33 enum DisplayType { | 35 enum DisplayType { |
34 DISPLAY_NONE = 0, | 36 DISPLAY_NONE = 0, |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 void SetPercentDownloaded(int percent_downloaded); | 130 void SetPercentDownloaded(int percent_downloaded); |
129 | 131 |
130 // Returns the dimension at which this result's icon should be displayed. | 132 // Returns the dimension at which this result's icon should be displayed. |
131 int GetPreferredIconDimension() const; | 133 int GetPreferredIconDimension() const; |
132 | 134 |
133 void NotifyItemInstalled(); | 135 void NotifyItemInstalled(); |
134 | 136 |
135 void AddObserver(SearchResultObserver* observer); | 137 void AddObserver(SearchResultObserver* observer); |
136 void RemoveObserver(SearchResultObserver* observer); | 138 void RemoveObserver(SearchResultObserver* observer); |
137 | 139 |
| 140 // Updates the result's relevance score, and sets its title and title tags, |
| 141 // based on a string match result. |
| 142 void UpdateFromMatch(const TokenizedString& title, |
| 143 const TokenizedStringMatch& match); |
| 144 |
138 // TODO(mukai): Remove this method and really simplify the ownership of | 145 // TODO(mukai): Remove this method and really simplify the ownership of |
139 // SearchResult. Ideally, SearchResult will be copyable. | 146 // SearchResult. Ideally, SearchResult will be copyable. |
140 virtual scoped_ptr<SearchResult> Duplicate() const = 0; | 147 virtual scoped_ptr<SearchResult> Duplicate() const = 0; |
141 | 148 |
142 // Opens the result. | 149 // Opens the result. |
143 virtual void Open(int event_flags); | 150 virtual void Open(int event_flags); |
144 | 151 |
145 // Invokes a custom action on the result. It does nothing by default. | 152 // Invokes a custom action on the result. It does nothing by default. |
146 virtual void InvokeAction(int action_index, int event_flags); | 153 virtual void InvokeAction(int action_index, int event_flags); |
147 | 154 |
148 // Returns the context menu model for this item, or NULL if there is currently | 155 // Returns the context menu model for this item, or NULL if there is currently |
149 // no menu for the item (e.g. during install). | 156 // no menu for the item (e.g. during install). |
150 // Note the returned menu model is owned by this item. | 157 // Note the returned menu model is owned by this item. |
151 virtual ui::MenuModel* GetContextMenuModel(); | 158 virtual ui::MenuModel* GetContextMenuModel(); |
152 | 159 |
| 160 // Returns a string showing |text| marked up with brackets indicating the |
| 161 // tag positions in |tags|. Useful for debugging and testing. |
| 162 static std::string TagsDebugString(const std::string& text, const Tags& tags); |
| 163 |
153 protected: | 164 protected: |
154 void set_id(const std::string& id) { id_ = id; } | 165 void set_id(const std::string& id) { id_ = id; } |
155 void set_voice_result(bool voice_result) { voice_result_ = voice_result; } | 166 void set_voice_result(bool voice_result) { voice_result_ = voice_result; } |
156 | 167 |
157 private: | 168 private: |
158 gfx::ImageSkia icon_; | 169 gfx::ImageSkia icon_; |
159 | 170 |
160 base::string16 title_; | 171 base::string16 title_; |
161 Tags title_tags_; | 172 Tags title_tags_; |
162 | 173 |
(...skipping 11 matching lines...) Expand all Loading... |
174 int percent_downloaded_; | 185 int percent_downloaded_; |
175 | 186 |
176 ObserverList<SearchResultObserver> observers_; | 187 ObserverList<SearchResultObserver> observers_; |
177 | 188 |
178 DISALLOW_COPY_AND_ASSIGN(SearchResult); | 189 DISALLOW_COPY_AND_ASSIGN(SearchResult); |
179 }; | 190 }; |
180 | 191 |
181 } // namespace app_list | 192 } // namespace app_list |
182 | 193 |
183 #endif // UI_APP_LIST_SEARCH_RESULT_H_ | 194 #endif // UI_APP_LIST_SEARCH_RESULT_H_ |
OLD | NEW |