OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ui/app_list/app_list_model.h" | 5 #include "ui/app_list/app_list_model.h" |
6 | 6 |
7 #include "ui/app_list/app_list_item_model.h" | 7 #include "ui/app_list/app_list_item_model.h" |
8 #include "ui/app_list/app_list_model_observer.h" | 8 #include "ui/app_list/app_list_model_observer.h" |
9 #include "ui/app_list/search_box_model.h" | 9 #include "ui/app_list/search_box_model.h" |
10 #include "ui/app_list/search_result.h" | 10 #include "ui/app_list/search_result.h" |
11 | 11 |
12 namespace app_list { | 12 namespace app_list { |
13 | 13 |
14 AppListModel::User::User() : active(false) {} | |
15 | |
16 AppListModel::User::~User() {} | |
17 | |
18 AppListModel::AppListModel() | 14 AppListModel::AppListModel() |
19 : item_list_(new AppListItemList), | 15 : item_list_(new AppListItemList), |
20 search_box_(new SearchBoxModel), | 16 search_box_(new SearchBoxModel), |
21 results_(new SearchResults), | 17 results_(new SearchResults), |
22 signed_in_(false), | 18 signed_in_(false), |
23 status_(STATUS_NORMAL) { | 19 status_(STATUS_NORMAL) { |
24 } | 20 } |
25 | 21 |
26 AppListModel::~AppListModel() { | 22 AppListModel::~AppListModel() { |
27 } | 23 } |
28 | 24 |
29 void AppListModel::AddObserver(AppListModelObserver* observer) { | 25 void AppListModel::AddObserver(AppListModelObserver* observer) { |
30 observers_.AddObserver(observer); | 26 observers_.AddObserver(observer); |
31 } | 27 } |
32 | 28 |
33 void AppListModel::RemoveObserver(AppListModelObserver* observer) { | 29 void AppListModel::RemoveObserver(AppListModelObserver* observer) { |
34 observers_.RemoveObserver(observer); | 30 observers_.RemoveObserver(observer); |
35 } | 31 } |
36 | 32 |
37 void AppListModel::SetStatus(Status status) { | 33 void AppListModel::SetStatus(Status status) { |
38 if (status_ == status) | 34 if (status_ == status) |
39 return; | 35 return; |
40 | 36 |
41 status_ = status; | 37 status_ = status; |
42 FOR_EACH_OBSERVER(AppListModelObserver, | 38 FOR_EACH_OBSERVER(AppListModelObserver, |
43 observers_, | 39 observers_, |
44 OnAppListModelStatusChanged()); | 40 OnAppListModelStatusChanged()); |
45 } | 41 } |
46 | 42 |
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) { | 43 void AppListModel::SetSignedIn(bool signed_in) { |
55 if (signed_in_ == signed_in) | 44 if (signed_in_ == signed_in) |
56 return; | 45 return; |
57 | 46 |
58 signed_in_ = signed_in; | 47 signed_in_ = signed_in; |
59 FOR_EACH_OBSERVER(AppListModelObserver, | 48 FOR_EACH_OBSERVER(AppListModelObserver, |
60 observers_, | 49 observers_, |
61 OnAppListModelSigninStatusChanged()); | 50 OnAppListModelSigninStatusChanged()); |
62 } | 51 } |
63 | 52 |
64 } // namespace app_list | 53 } // namespace app_list |
OLD | NEW |