- add sources.
[platform/framework/web/crosswalk.git] / src / ui / app_list / app_list_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_model.h"
6
7 #include "ui/app_list/app_list_item_model.h"
8 #include "ui/app_list/app_list_model_observer.h"
9 #include "ui/app_list/search_box_model.h"
10 #include "ui/app_list/search_result.h"
11
12 namespace app_list {
13
14 AppListModel::User::User() : active(false) {}
15
16 AppListModel::User::~User() {}
17
18 AppListModel::AppListModel()
19     : item_list_(new AppListItemList),
20       search_box_(new SearchBoxModel),
21       results_(new SearchResults),
22       signed_in_(false),
23       status_(STATUS_NORMAL) {
24 }
25
26 AppListModel::~AppListModel() {
27 }
28
29 void AppListModel::AddObserver(AppListModelObserver* observer) {
30   observers_.AddObserver(observer);
31 }
32
33 void AppListModel::RemoveObserver(AppListModelObserver* observer) {
34   observers_.RemoveObserver(observer);
35 }
36
37 void AppListModel::SetStatus(Status status) {
38   if (status_ == status)
39     return;
40
41   status_ = status;
42   FOR_EACH_OBSERVER(AppListModelObserver,
43                     observers_,
44                     OnAppListModelStatusChanged());
45 }
46
47 void AppListModel::SetUsers(const Users& users) {
48   users_ = users;
49   FOR_EACH_OBSERVER(AppListModelObserver,
50                     observers_,
51                     OnAppListModelUsersChanged());
52 }
53
54 void AppListModel::SetSignedIn(bool signed_in) {
55   if (signed_in_ == signed_in)
56     return;
57
58   signed_in_ = signed_in;
59   FOR_EACH_OBSERVER(AppListModelObserver,
60                     observers_,
61                     OnAppListModelSigninStatusChanged());
62 }
63
64 }  // namespace app_list