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 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 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 25 SearchResult::Action::~Action() {} 26 27 SearchResult::SearchResult() 28 : relevance_(0), is_installing_(false), percent_downloaded_(0) { 29 } 30 31 SearchResult::~SearchResult() {} 32 33 void SearchResult::SetIcon(const gfx::ImageSkia& icon) { 34 icon_ = icon; 35 FOR_EACH_OBSERVER(SearchResultObserver, 36 observers_, 37 OnIconChanged()); 38 } 39 40 void SearchResult::SetActions(const Actions& sets) { 41 actions_ = sets; 42 FOR_EACH_OBSERVER(SearchResultObserver, 43 observers_, 44 OnActionsChanged()); 45 } 46 47 void SearchResult::SetIsInstalling(bool is_installing) { 48 if (is_installing_ == is_installing) 49 return; 50 51 is_installing_ = is_installing; 52 FOR_EACH_OBSERVER(SearchResultObserver, 53 observers_, 54 OnIsInstallingChanged()); 55 } 56 57 void SearchResult::SetPercentDownloaded(int percent_downloaded) { 58 if (percent_downloaded_ == percent_downloaded) 59 return; 60 61 percent_downloaded_ = percent_downloaded; 62 FOR_EACH_OBSERVER(SearchResultObserver, 63 observers_, 64 OnPercentDownloadedChanged()); 65 } 66 67 void SearchResult::NotifyItemInstalled() { 68 FOR_EACH_OBSERVER(SearchResultObserver, observers_, OnItemInstalled()); 69 } 70 71 void SearchResult::NotifyItemUninstalled() { 72 FOR_EACH_OBSERVER(SearchResultObserver, observers_, OnItemUninstalled()); 73 } 74 75 void SearchResult::AddObserver(SearchResultObserver* observer) { 76 observers_.AddObserver(observer); 77 } 78 79 void SearchResult::RemoveObserver(SearchResultObserver* observer) { 80 observers_.RemoveObserver(observer); 81 } 82 83 void SearchResult::Open(int event_flags) { 84 } 85 86 void SearchResult::InvokeAction(int action_index, int event_flags) { 87 } 88 89 ui::MenuModel* SearchResult::GetContextMenuModel() { 90 return NULL; 91 } 92 93 } // namespace app_list 94