WebKit roll 130275:130304
[chromium-blink-merge.git] / ui / app_list / search_result.h
blobc7b2760abcdf99c92371add02c5fa90b6c64603b
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/string16.h"
13 #include "ui/app_list/app_list_export.h"
14 #include "ui/base/models/list_model.h"
15 #include "ui/base/range/range.h"
16 #include "ui/gfx/image/image_skia.h"
18 namespace app_list {
20 class SearchResultObserver;
22 // SearchResult consists of an icon, title text and details text. Title and
23 // details text can have tagged ranges that are displayed differently from
24 // default style.
25 class APP_LIST_EXPORT SearchResult {
26 public:
27 // A tagged range in search result text.
28 struct Tag {
29 // Similar to ACMatchClassification::Style, the style values are not
30 // mutually exclusive.
31 enum Style {
32 NONE = 0,
33 URL = 1 << 0,
34 MATCH = 1 << 1,
35 DIM = 1 << 2,
38 Tag(int styles, size_t start, size_t end)
39 : styles(styles),
40 range(start, end) {
43 int styles;
44 ui::Range range;
46 typedef std::vector<Tag> Tags;
48 // A collection of images representing an action that can be performed on this
49 // search result.
50 struct ActionIconSet {
51 ActionIconSet(const gfx::ImageSkia& base_image,
52 const gfx::ImageSkia& hover_image,
53 const gfx::ImageSkia& pressed_image,
54 const string16& tooltip_text);
55 ~ActionIconSet();
57 gfx::ImageSkia base_image;
58 gfx::ImageSkia hover_image;
59 gfx::ImageSkia pressed_image;
61 string16 tooltip_text;
63 typedef std::vector<ActionIconSet> ActionIconSets;
65 SearchResult();
66 virtual ~SearchResult();
68 const gfx::ImageSkia& icon() const { return icon_; }
69 void SetIcon(const gfx::ImageSkia& icon);
71 const string16& title() const { return title_; }
72 void set_title(const string16& title) { title_ = title;}
74 const Tags& title_tags() const { return title_tags_; }
75 void set_title_tags(const Tags& tags) { title_tags_ = tags; }
77 const string16& details() const { return details_; }
78 void set_details(const string16& details) { details_ = details; }
80 const Tags& details_tags() const { return details_tags_; }
81 void set_details_tags(const Tags& tags) { details_tags_ = tags; }
83 const ActionIconSets& action_icons() const {
84 return action_icons_;
86 void SetActionIcons(const ActionIconSets& sets);
88 void AddObserver(SearchResultObserver* observer);
89 void RemoveObserver(SearchResultObserver* observer);
91 private:
92 gfx::ImageSkia icon_;
94 string16 title_;
95 Tags title_tags_;
97 string16 details_;
98 Tags details_tags_;
100 // Optional list of icons representing additional actions that can be
101 // performed on this result.
102 ActionIconSets action_icons_;
104 ObserverList<SearchResultObserver> observers_;
106 DISALLOW_COPY_AND_ASSIGN(SearchResult);
109 } // namespace app_list
111 #endif // UI_APP_LIST_SEARCH_RESULT_H_