Fix case-sensitivity problems in extension content verification
[chromium-blink-merge.git] / ui / app_list / search_result.h
blob7e7524fafc2472cf50c83a50a88db069ebc9696c
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 // How the result should be displayed.
31 enum DisplayType {
32 DISPLAY_LIST,
33 DISPLAY_TILE,
36 // A tagged range in search result text.
37 struct APP_LIST_EXPORT Tag {
38 // Similar to ACMatchClassification::Style, the style values are not
39 // mutually exclusive.
40 enum Style {
41 NONE = 0,
42 URL = 1 << 0,
43 MATCH = 1 << 1,
44 DIM = 1 << 2,
47 Tag(int styles, size_t start, size_t end)
48 : styles(styles),
49 range(start, end) {
52 int styles;
53 gfx::Range range;
55 typedef std::vector<Tag> Tags;
57 // Data representing an action that can be performed on this search result.
58 // An action could be represented as an icon set or as a blue button with
59 // a label. Icon set is chosen if label text is empty. Otherwise, a blue
60 // button with the label text will be used.
61 struct APP_LIST_EXPORT Action {
62 Action(const gfx::ImageSkia& base_image,
63 const gfx::ImageSkia& hover_image,
64 const gfx::ImageSkia& pressed_image,
65 const base::string16& tooltip_text);
66 Action(const base::string16& label_text,
67 const base::string16& tooltip_text);
68 ~Action();
70 gfx::ImageSkia base_image;
71 gfx::ImageSkia hover_image;
72 gfx::ImageSkia pressed_image;
74 base::string16 tooltip_text;
75 base::string16 label_text;
77 typedef std::vector<Action> Actions;
79 SearchResult();
80 virtual ~SearchResult();
82 const gfx::ImageSkia& icon() const { return icon_; }
83 void SetIcon(const gfx::ImageSkia& icon);
85 const base::string16& title() const { return title_; }
86 void set_title(const base::string16& title) { title_ = title;}
88 const Tags& title_tags() const { return title_tags_; }
89 void set_title_tags(const Tags& tags) { title_tags_ = tags; }
91 const base::string16& details() const { return details_; }
92 void set_details(const base::string16& details) { details_ = details; }
94 const Tags& details_tags() const { return details_tags_; }
95 void set_details_tags(const Tags& tags) { details_tags_ = tags; }
97 const std::string& id() const { return id_; }
98 double relevance() const { return relevance_; }
99 DisplayType display_type() const { return display_type_; }
101 const Actions& actions() const {
102 return actions_;
104 void SetActions(const Actions& sets);
106 bool is_installing() const { return is_installing_; }
107 void SetIsInstalling(bool is_installing);
109 int percent_downloaded() const { return percent_downloaded_; }
110 void SetPercentDownloaded(int percent_downloaded);
112 // Returns the dimension at which this result's icon should be displayed.
113 int GetPreferredIconDimension() const;
115 void NotifyItemInstalled();
116 void NotifyItemUninstalled();
118 void AddObserver(SearchResultObserver* observer);
119 void RemoveObserver(SearchResultObserver* observer);
121 // Opens the result.
122 virtual void Open(int event_flags);
124 // Invokes a custom action on the result.
125 virtual void InvokeAction(int action_index, int event_flags);
127 // Returns the context menu model for this item, or NULL if there is currently
128 // no menu for the item (e.g. during install).
129 // Note the returned menu model is owned by this item.
130 virtual ui::MenuModel* GetContextMenuModel();
132 protected:
133 void set_id(const std::string& id) { id_ = id; }
134 void set_relevance(double relevance) { relevance_ = relevance; }
135 void set_display_type(DisplayType display_type) {
136 display_type_ = display_type;
139 private:
140 gfx::ImageSkia icon_;
142 base::string16 title_;
143 Tags title_tags_;
145 base::string16 details_;
146 Tags details_tags_;
148 std::string id_;
149 double relevance_;
150 DisplayType display_type_;
152 Actions actions_;
154 bool is_installing_;
155 int percent_downloaded_;
157 ObserverList<SearchResultObserver> observers_;
159 DISALLOW_COPY_AND_ASSIGN(SearchResult);
162 } // namespace app_list
164 #endif // UI_APP_LIST_SEARCH_RESULT_H_