Add method for priming the SincResampler with silence.
[chromium-blink-merge.git] / ui / app_list / search_result.h
blobdd955a6c831ca5148c867af9b25f01b0441ce948
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
3 // found in the LICENSE file.
5 #ifndef UI_APP_LIST_SEARCH_RESULT_H_
6 #define UI_APP_LIST_SEARCH_RESULT_H_
8 #include <string>
9 #include <vector>
11 #include "base/basictypes.h"
12 #include "base/observer_list.h"
13 #include "base/strings/string16.h"
14 #include "ui/app_list/app_list_export.h"
15 #include "ui/gfx/image/image_skia.h"
16 #include "ui/gfx/range/range.h"
18 namespace ui {
19 class MenuModel;
22 namespace app_list {
24 class SearchResultObserver;
26 // SearchResult consists of an icon, title text and details text. Title and
27 // details text can have tagged ranges that are displayed differently from
28 // default style.
29 class APP_LIST_EXPORT SearchResult {
30 public:
31 // How the result should be displayed.
32 enum DisplayType {
33 DISPLAY_LIST,
34 DISPLAY_TILE,
37 // A tagged range in search result text.
38 struct APP_LIST_EXPORT Tag {
39 // Similar to ACMatchClassification::Style, the style values are not
40 // mutually exclusive.
41 enum Style {
42 NONE = 0,
43 URL = 1 << 0,
44 MATCH = 1 << 1,
45 DIM = 1 << 2,
48 Tag(int styles, size_t start, size_t end)
49 : styles(styles),
50 range(start, end) {
53 int styles;
54 gfx::Range range;
56 typedef std::vector<Tag> Tags;
58 // Data representing an action that can be performed on this search result.
59 // An action could be represented as an icon set or as a blue button with
60 // a label. Icon set is chosen if label text is empty. Otherwise, a blue
61 // button with the label text will be used.
62 struct APP_LIST_EXPORT Action {
63 Action(const gfx::ImageSkia& base_image,
64 const gfx::ImageSkia& hover_image,
65 const gfx::ImageSkia& pressed_image,
66 const base::string16& tooltip_text);
67 Action(const base::string16& label_text,
68 const base::string16& tooltip_text);
69 ~Action();
71 gfx::ImageSkia base_image;
72 gfx::ImageSkia hover_image;
73 gfx::ImageSkia pressed_image;
75 base::string16 tooltip_text;
76 base::string16 label_text;
78 typedef std::vector<Action> Actions;
80 SearchResult();
81 virtual ~SearchResult();
83 const gfx::ImageSkia& icon() const { return icon_; }
84 void SetIcon(const gfx::ImageSkia& icon);
86 const base::string16& title() const { return title_; }
87 void set_title(const base::string16& title) { title_ = title;}
89 const Tags& title_tags() const { return title_tags_; }
90 void set_title_tags(const Tags& tags) { title_tags_ = tags; }
92 const base::string16& details() const { return details_; }
93 void set_details(const base::string16& details) { details_ = details; }
95 const Tags& details_tags() const { return details_tags_; }
96 void set_details_tags(const Tags& tags) { details_tags_ = tags; }
98 const std::string& id() const { return id_; }
99 double relevance() const { return relevance_; }
100 DisplayType display_type() const { return display_type_; }
102 const Actions& actions() const {
103 return actions_;
105 void SetActions(const Actions& sets);
107 bool is_installing() const { return is_installing_; }
108 void SetIsInstalling(bool is_installing);
110 int percent_downloaded() const { return percent_downloaded_; }
111 void SetPercentDownloaded(int percent_downloaded);
113 // Returns the dimension at which this result's icon should be displayed.
114 int GetPreferredIconDimension() const;
116 void NotifyItemInstalled();
117 void NotifyItemUninstalled();
119 void AddObserver(SearchResultObserver* observer);
120 void RemoveObserver(SearchResultObserver* observer);
122 // TODO(mukai): Remove this method and really simplify the ownership of
123 // SearchResult. Ideally, SearchResult will be copyable.
124 virtual scoped_ptr<SearchResult> Duplicate() = 0;
126 // Opens the result.
127 virtual void Open(int event_flags);
129 // Invokes a custom action on the result. It does nothing by default.
130 virtual void InvokeAction(int action_index, int event_flags);
132 // Returns the context menu model for this item, or NULL if there is currently
133 // no menu for the item (e.g. during install).
134 // Note the returned menu model is owned by this item.
135 virtual ui::MenuModel* GetContextMenuModel();
137 protected:
138 void set_id(const std::string& id) { id_ = id; }
139 void set_relevance(double relevance) { relevance_ = relevance; }
140 void set_display_type(DisplayType display_type) {
141 display_type_ = display_type;
144 private:
145 gfx::ImageSkia icon_;
147 base::string16 title_;
148 Tags title_tags_;
150 base::string16 details_;
151 Tags details_tags_;
153 std::string id_;
154 double relevance_;
155 DisplayType display_type_;
157 Actions actions_;
159 bool is_installing_;
160 int percent_downloaded_;
162 ObserverList<SearchResultObserver> observers_;
164 DISALLOW_COPY_AND_ASSIGN(SearchResult);
167 } // namespace app_list
169 #endif // UI_APP_LIST_SEARCH_RESULT_H_