Updating trunk VERSION from 2139.0 to 2140.0
[chromium-blink-merge.git] / ui / app_list / search_result.cc
blob653d08950d9a81911a5b4e2f8560c3ad6b518ff2
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 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) {
40 icon_ = icon;
41 FOR_EACH_OBSERVER(SearchResultObserver,
42 observers_,
43 OnIconChanged());
46 void SearchResult::SetActions(const Actions& sets) {
47 actions_ = sets;
48 FOR_EACH_OBSERVER(SearchResultObserver,
49 observers_,
50 OnActionsChanged());
53 void SearchResult::SetIsInstalling(bool is_installing) {
54 if (is_installing_ == is_installing)
55 return;
57 is_installing_ = is_installing;
58 FOR_EACH_OBSERVER(SearchResultObserver,
59 observers_,
60 OnIsInstallingChanged());
63 void SearchResult::SetPercentDownloaded(int percent_downloaded) {
64 if (percent_downloaded_ == percent_downloaded)
65 return;
67 percent_downloaded_ = percent_downloaded;
68 FOR_EACH_OBSERVER(SearchResultObserver,
69 observers_,
70 OnPercentDownloadedChanged());
73 int SearchResult::GetPreferredIconDimension() const {
74 switch (display_type_) {
75 case DISPLAY_TILE:
76 return kTileIconSize;
77 case DISPLAY_LIST:
78 return kListIconSize;
80 NOTREACHED();
81 return 0;
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() {
107 return NULL;
110 } // namespace app_list