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
),
31 is_installing_(false),
32 percent_downloaded_(0) {
35 SearchResult::~SearchResult() {
36 FOR_EACH_OBSERVER(SearchResultObserver
, observers_
, OnResultDestroying());
39 void SearchResult::SetIcon(const gfx::ImageSkia
& icon
) {
41 FOR_EACH_OBSERVER(SearchResultObserver
,
46 void SearchResult::SetActions(const Actions
& sets
) {
48 FOR_EACH_OBSERVER(SearchResultObserver
,
53 void SearchResult::SetIsInstalling(bool is_installing
) {
54 if (is_installing_
== is_installing
)
57 is_installing_
= is_installing
;
58 FOR_EACH_OBSERVER(SearchResultObserver
,
60 OnIsInstallingChanged());
63 void SearchResult::SetPercentDownloaded(int percent_downloaded
) {
64 if (percent_downloaded_
== percent_downloaded
)
67 percent_downloaded_
= percent_downloaded
;
68 FOR_EACH_OBSERVER(SearchResultObserver
,
70 OnPercentDownloadedChanged());
73 int SearchResult::GetPreferredIconDimension() const {
74 switch (display_type_
) {
84 void SearchResult::NotifyItemInstalled() {
85 FOR_EACH_OBSERVER(SearchResultObserver
, observers_
, OnItemInstalled());
88 void SearchResult::NotifyItemUninstalled() {
89 FOR_EACH_OBSERVER(SearchResultObserver
, observers_
, OnItemUninstalled());
92 void SearchResult::AddObserver(SearchResultObserver
* observer
) {
93 observers_
.AddObserver(observer
);
96 void SearchResult::RemoveObserver(SearchResultObserver
* observer
) {
97 observers_
.RemoveObserver(observer
);
100 void SearchResult::Open(int event_flags
) {
103 void SearchResult::InvokeAction(int action_index
, int event_flags
) {
106 ui::MenuModel
* SearchResult::GetContextMenuModel() {
110 } // namespace app_list