Home | History | Annotate | Download | only in app_list
      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/app_list_item_model.h"
      6 
      7 #include "base/logging.h"
      8 #include "ui/app_list/app_list_item_model_observer.h"
      9 
     10 namespace app_list {
     11 
     12 AppListItemModel::AppListItemModel()
     13     : highlighted_(false),
     14       is_installing_(false),
     15       percent_downloaded_(-1) {
     16 }
     17 
     18 AppListItemModel::~AppListItemModel() {
     19 }
     20 
     21 void AppListItemModel::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) {
     22   icon_ = icon;
     23   has_shadow_ = has_shadow;
     24   FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemIconChanged());
     25 }
     26 
     27 void AppListItemModel::SetTitle(const std::string& title) {
     28   if (title_ == title)
     29     return;
     30 
     31   title_ = title;
     32   FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemTitleChanged());
     33 }
     34 
     35 void AppListItemModel::SetHighlighted(bool highlighted) {
     36   if (highlighted_ == highlighted)
     37     return;
     38 
     39   highlighted_ = highlighted;
     40   FOR_EACH_OBSERVER(AppListItemModelObserver,
     41                     observers_,
     42                     ItemHighlightedChanged());
     43 }
     44 
     45 void AppListItemModel::SetIsInstalling(bool is_installing) {
     46   if (is_installing_ == is_installing)
     47     return;
     48 
     49   is_installing_ = is_installing;
     50   FOR_EACH_OBSERVER(AppListItemModelObserver,
     51                     observers_,
     52                     ItemIsInstallingChanged());
     53 }
     54 
     55 void AppListItemModel::SetPercentDownloaded(int percent_downloaded) {
     56   if (percent_downloaded_ == percent_downloaded)
     57     return;
     58 
     59   percent_downloaded_ = percent_downloaded;
     60   FOR_EACH_OBSERVER(AppListItemModelObserver,
     61                     observers_,
     62                     ItemPercentDownloadedChanged());
     63 }
     64 
     65 void AppListItemModel::AddObserver(AppListItemModelObserver* observer) {
     66   observers_.AddObserver(observer);
     67 }
     68 
     69 void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) {
     70   observers_.RemoveObserver(observer);
     71 }
     72 
     73 ui::MenuModel* AppListItemModel::GetContextMenuModel() {
     74   return NULL;
     75 }
     76 
     77 }  // namespace app_list
     78