- add sources.
[platform/framework/web/crosswalk.git] / src / ui / app_list / app_list_item_model.cc
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(const std::string& id)
13     : id_(id),
14       highlighted_(false),
15       is_installing_(false),
16       percent_downloaded_(-1) {
17 }
18
19 AppListItemModel::~AppListItemModel() {
20 }
21
22 void AppListItemModel::SetIcon(const gfx::ImageSkia& icon, bool has_shadow) {
23   icon_ = icon;
24   has_shadow_ = has_shadow;
25   FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemIconChanged());
26 }
27
28 void AppListItemModel::SetTitleAndFullName(const std::string& title,
29                                            const std::string& full_name) {
30   if (title_ == title && full_name_ == full_name)
31     return;
32
33   title_ = title;
34   full_name_ = full_name;
35   FOR_EACH_OBSERVER(AppListItemModelObserver, observers_, ItemTitleChanged());
36 }
37
38 void AppListItemModel::SetHighlighted(bool highlighted) {
39   if (highlighted_ == highlighted)
40     return;
41
42   highlighted_ = highlighted;
43   FOR_EACH_OBSERVER(AppListItemModelObserver,
44                     observers_,
45                     ItemHighlightedChanged());
46 }
47
48 void AppListItemModel::SetIsInstalling(bool is_installing) {
49   if (is_installing_ == is_installing)
50     return;
51
52   is_installing_ = is_installing;
53   FOR_EACH_OBSERVER(AppListItemModelObserver,
54                     observers_,
55                     ItemIsInstallingChanged());
56 }
57
58 void AppListItemModel::SetPercentDownloaded(int percent_downloaded) {
59   if (percent_downloaded_ == percent_downloaded)
60     return;
61
62   percent_downloaded_ = percent_downloaded;
63   FOR_EACH_OBSERVER(AppListItemModelObserver,
64                     observers_,
65                     ItemPercentDownloadedChanged());
66 }
67
68 void AppListItemModel::AddObserver(AppListItemModelObserver* observer) {
69   observers_.AddObserver(observer);
70 }
71
72 void AppListItemModel::RemoveObserver(AppListItemModelObserver* observer) {
73   observers_.RemoveObserver(observer);
74 }
75
76 void AppListItemModel::Activate(int event_flags) {
77 }
78
79 const char* AppListItemModel::GetAppType() const {
80   static const char* app_type = "";
81   return app_type;
82 }
83
84 ui::MenuModel* AppListItemModel::GetContextMenuModel() {
85   return NULL;
86 }
87
88 }  // namespace app_list