MSan: temporarily blacklist an uninit in CLD2.
[chromium-blink-merge.git] / ui / app_list / search_result.h
blobcf9130c02b86247b0ac967996da4844feea3ac08
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 <vector>
10 #include "base/basictypes.h"
11 #include "base/observer_list.h"
12 #include "base/strings/string16.h"
13 #include "ui/app_list/app_list_export.h"
14 #include "ui/gfx/image/image_skia.h"
15 #include "ui/gfx/range/range.h"
17 namespace ui {
18 class MenuModel;
21 namespace app_list {
23 class SearchResultObserver;
25 // SearchResult consists of an icon, title text and details text. Title and
26 // details text can have tagged ranges that are displayed differently from
27 // default style.
28 class APP_LIST_EXPORT SearchResult {
29 public:
30 // A tagged range in search result text.
31 struct APP_LIST_EXPORT Tag {
32 // Similar to ACMatchClassification::Style, the style values are not
33 // mutually exclusive.
34 enum Style {
35 NONE = 0,
36 URL = 1 << 0,
37 MATCH = 1 << 1,
38 DIM = 1 << 2,
41 Tag(int styles, size_t start, size_t end)
42 : styles(styles),
43 range(start, end) {
46 int styles;
47 gfx::Range range;
49 typedef std::vector<Tag> Tags;
51 // Data representing an action that can be performed on this search result.
52 // An action could be represented as an icon set or as a blue button with
53 // a label. Icon set is chosen if label text is empty. Otherwise, a blue
54 // button with the label text will be used.
55 struct APP_LIST_EXPORT Action {
56 Action(const gfx::ImageSkia& base_image,
57 const gfx::ImageSkia& hover_image,
58 const gfx::ImageSkia& pressed_image,
59 const base::string16& tooltip_text);
60 Action(const base::string16& label_text,
61 const base::string16& tooltip_text);
62 ~Action();
64 gfx::ImageSkia base_image;
65 gfx::ImageSkia hover_image;
66 gfx::ImageSkia pressed_image;
68 base::string16 tooltip_text;
69 base::string16 label_text;
71 typedef std::vector<Action> Actions;
73 SearchResult();
74 virtual ~SearchResult();
76 const gfx::ImageSkia& icon() const { return icon_; }
77 void SetIcon(const gfx::ImageSkia& icon);
79 const base::string16& title() const { return title_; }
80 void set_title(const base::string16& title) { title_ = title;}
82 const Tags& title_tags() const { return title_tags_; }
83 void set_title_tags(const Tags& tags) { title_tags_ = tags; }
85 const base::string16& details() const { return details_; }
86 void set_details(const base::string16& details) { details_ = details; }
88 const Tags& details_tags() const { return details_tags_; }
89 void set_details_tags(const Tags& tags) { details_tags_ = tags; }
91 const std::string& id() const { return id_; }
92 double relevance() { return relevance_; }
94 const Actions& actions() const {
95 return actions_;
97 void SetActions(const Actions& sets);
99 bool is_installing() const { return is_installing_; }
100 void SetIsInstalling(bool is_installing);
102 int percent_downloaded() const { return percent_downloaded_; }
103 void SetPercentDownloaded(int percent_downloaded);
105 void NotifyItemInstalled();
106 void NotifyItemUninstalled();
108 void AddObserver(SearchResultObserver* observer);
109 void RemoveObserver(SearchResultObserver* observer);
111 // Opens the result.
112 virtual void Open(int event_flags);
114 // Invokes a custom action on the result.
115 virtual void InvokeAction(int action_index, int event_flags);
117 // Returns the context menu model for this item, or NULL if there is currently
118 // no menu for the item (e.g. during install).
119 // Note the returned menu model is owned by this item.
120 virtual ui::MenuModel* GetContextMenuModel();
122 protected:
123 void set_id(const std::string& id) { id_ = id; }
124 void set_relevance(double relevance) { relevance_ = relevance; }
126 private:
127 gfx::ImageSkia icon_;
129 base::string16 title_;
130 Tags title_tags_;
132 base::string16 details_;
133 Tags details_tags_;
135 std::string id_;
136 double relevance_;
138 Actions actions_;
140 bool is_installing_;
141 int percent_downloaded_;
143 ObserverList<SearchResultObserver> observers_;
145 DISALLOW_COPY_AND_ASSIGN(SearchResult);
148 } // namespace app_list
150 #endif // UI_APP_LIST_SEARCH_RESULT_H_