Remove wpr.archive_info dependancy on page to avoid circular dependancies.
[chromium-blink-merge.git] / ui / app_list / search_result.cc
blob87bea21334f15fe203c441f86ec9f532dc00fa1a
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"
10 namespace app_list {
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()
29 : relevance_(0),
30 display_type_(DISPLAY_LIST),
31 voice_result_(false),
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) {
41 icon_ = icon;
42 FOR_EACH_OBSERVER(SearchResultObserver,
43 observers_,
44 OnIconChanged());
47 void SearchResult::SetActions(const Actions& sets) {
48 actions_ = sets;
49 FOR_EACH_OBSERVER(SearchResultObserver,
50 observers_,
51 OnActionsChanged());
54 void SearchResult::SetIsInstalling(bool is_installing) {
55 if (is_installing_ == is_installing)
56 return;
58 is_installing_ = is_installing;
59 FOR_EACH_OBSERVER(SearchResultObserver,
60 observers_,
61 OnIsInstallingChanged());
64 void SearchResult::SetPercentDownloaded(int percent_downloaded) {
65 if (percent_downloaded_ == percent_downloaded)
66 return;
68 percent_downloaded_ = percent_downloaded;
69 FOR_EACH_OBSERVER(SearchResultObserver,
70 observers_,
71 OnPercentDownloadedChanged());
74 int SearchResult::GetPreferredIconDimension() const {
75 switch (display_type_) {
76 case DISPLAY_RECOMMENDATION: // Falls through.
77 case DISPLAY_TILE:
78 return kTileIconSize;
79 case DISPLAY_LIST:
80 return kListIconSize;
81 case DISPLAY_NONE:
82 return 0;
83 case DISPLAY_TYPE_LAST:
84 break;
86 NOTREACHED();
87 return 0;
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() {
109 return NULL;
112 } // namespace app_list