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 #include "ui/app_list/search_result.h"
7 #include "ui/app_list/app_list_constants.h"
8 #include "ui/app_list/search_result_observer.h"
12 SearchResult::Action::Action(const gfx::ImageSkia
& base_image
,
13 const gfx::ImageSkia
& hover_image
,
14 const gfx::ImageSkia
& pressed_image
,
15 const base::string16
& tooltip_text
)
16 : base_image(base_image
),
17 hover_image(hover_image
),
18 pressed_image(pressed_image
),
19 tooltip_text(tooltip_text
) {}
21 SearchResult::Action::Action(const base::string16
& label_text
,
22 const base::string16
& tooltip_text
)
23 : tooltip_text(tooltip_text
),
24 label_text(label_text
) {}
26 SearchResult::Action::~Action() {}
28 SearchResult::SearchResult()
30 display_type_(DISPLAY_LIST
),
32 is_installing_(false),
33 percent_downloaded_(0) {
36 SearchResult::~SearchResult() {
37 FOR_EACH_OBSERVER(SearchResultObserver
, observers_
, OnResultDestroying());
40 void SearchResult::SetIcon(const gfx::ImageSkia
& icon
) {
42 FOR_EACH_OBSERVER(SearchResultObserver
,
47 void SearchResult::SetActions(const Actions
& sets
) {
49 FOR_EACH_OBSERVER(SearchResultObserver
,
54 void SearchResult::SetIsInstalling(bool is_installing
) {
55 if (is_installing_
== is_installing
)
58 is_installing_
= is_installing
;
59 FOR_EACH_OBSERVER(SearchResultObserver
,
61 OnIsInstallingChanged());
64 void SearchResult::SetPercentDownloaded(int percent_downloaded
) {
65 if (percent_downloaded_
== percent_downloaded
)
68 percent_downloaded_
= percent_downloaded
;
69 FOR_EACH_OBSERVER(SearchResultObserver
,
71 OnPercentDownloadedChanged());
74 int SearchResult::GetPreferredIconDimension() const {
75 switch (display_type_
) {
76 case DISPLAY_RECOMMENDATION
: // Falls through.
83 case DISPLAY_TYPE_LAST
:
90 void SearchResult::NotifyItemInstalled() {
91 FOR_EACH_OBSERVER(SearchResultObserver
, observers_
, OnItemInstalled());
94 void SearchResult::AddObserver(SearchResultObserver
* observer
) {
95 observers_
.AddObserver(observer
);
98 void SearchResult::RemoveObserver(SearchResultObserver
* observer
) {
99 observers_
.RemoveObserver(observer
);
102 void SearchResult::Open(int event_flags
) {
105 void SearchResult::InvokeAction(int action_index
, int event_flags
) {
108 ui::MenuModel
* SearchResult::GetContextMenuModel() {
112 } // namespace app_list