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.
4
5 #include "ui/app_list/search_result.h"
6
7 #include "ui/app_list/search_result_observer.h"
8
9 namespace app_list {
10
Action(const gfx::ImageSkia & base_image,const gfx::ImageSkia & hover_image,const gfx::ImageSkia & pressed_image,const base::string16 & tooltip_text)11 SearchResult::Action::Action(const gfx::ImageSkia& base_image,
12 const gfx::ImageSkia& hover_image,
13 const gfx::ImageSkia& pressed_image,
14 const base::string16& tooltip_text)
15 : base_image(base_image),
16 hover_image(hover_image),
17 pressed_image(pressed_image),
18 tooltip_text(tooltip_text) {}
19
Action(const base::string16 & label_text,const base::string16 & tooltip_text)20 SearchResult::Action::Action(const base::string16& label_text,
21 const base::string16& tooltip_text)
22 : tooltip_text(tooltip_text),
23 label_text(label_text) {}
24
~Action()25 SearchResult::Action::~Action() {}
26
SearchResult()27 SearchResult::SearchResult() : is_installing_(false), percent_downloaded_(0) {}
28
~SearchResult()29 SearchResult::~SearchResult() {}
30
SetIcon(const gfx::ImageSkia & icon)31 void SearchResult::SetIcon(const gfx::ImageSkia& icon) {
32 icon_ = icon;
33 FOR_EACH_OBSERVER(SearchResultObserver,
34 observers_,
35 OnIconChanged());
36 }
37
SetActions(const Actions & sets)38 void SearchResult::SetActions(const Actions& sets) {
39 actions_ = sets;
40 FOR_EACH_OBSERVER(SearchResultObserver,
41 observers_,
42 OnActionsChanged());
43 }
44
SetIsInstalling(bool is_installing)45 void SearchResult::SetIsInstalling(bool is_installing) {
46 if (is_installing_ == is_installing)
47 return;
48
49 is_installing_ = is_installing;
50 FOR_EACH_OBSERVER(SearchResultObserver,
51 observers_,
52 OnIsInstallingChanged());
53 }
54
SetPercentDownloaded(int percent_downloaded)55 void SearchResult::SetPercentDownloaded(int percent_downloaded) {
56 if (percent_downloaded_ == percent_downloaded)
57 return;
58
59 percent_downloaded_ = percent_downloaded;
60 FOR_EACH_OBSERVER(SearchResultObserver,
61 observers_,
62 OnPercentDownloadedChanged());
63 }
64
NotifyItemInstalled()65 void SearchResult::NotifyItemInstalled() {
66 FOR_EACH_OBSERVER(SearchResultObserver, observers_, OnItemInstalled());
67 }
68
NotifyItemUninstalled()69 void SearchResult::NotifyItemUninstalled() {
70 FOR_EACH_OBSERVER(SearchResultObserver, observers_, OnItemUninstalled());
71 }
72
AddObserver(SearchResultObserver * observer)73 void SearchResult::AddObserver(SearchResultObserver* observer) {
74 observers_.AddObserver(observer);
75 }
76
RemoveObserver(SearchResultObserver * observer)77 void SearchResult::RemoveObserver(SearchResultObserver* observer) {
78 observers_.RemoveObserver(observer);
79 }
80
GetContextMenuModel()81 ui::MenuModel* SearchResult::GetContextMenuModel() {
82 return NULL;
83 }
84
85 } // namespace app_list
86