| 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 |
| 14 AppListModel::AppListModel() | 18 AppListModel::AppListModel() |
| 15 : apps_(new Apps), | 19 : apps_(new Apps), |
| 16 search_box_(new SearchBoxModel), | 20 search_box_(new SearchBoxModel), |
| 17 results_(new SearchResults), | 21 results_(new SearchResults), |
| 18 signed_in_(false), | 22 signed_in_(false), |
| 19 status_(STATUS_NORMAL) { | 23 status_(STATUS_NORMAL) { |
| 20 } | 24 } |
| 21 | 25 |
| 22 AppListModel::~AppListModel() { | 26 AppListModel::~AppListModel() { |
| 23 } | 27 } |
| 24 | 28 |
| 25 void AppListModel::AddObserver(AppListModelObserver* observer) { | 29 void AppListModel::AddObserver(AppListModelObserver* observer) { |
| 26 observers_.AddObserver(observer); | 30 observers_.AddObserver(observer); |
| 27 } | 31 } |
| 28 | 32 |
| 29 void AppListModel::RemoveObserver(AppListModelObserver* observer) { | 33 void AppListModel::RemoveObserver(AppListModelObserver* observer) { |
| 30 observers_.RemoveObserver(observer); | 34 observers_.RemoveObserver(observer); |
| 31 } | 35 } |
| 32 | 36 |
| 33 void AppListModel::SetStatus(Status status) { | 37 void AppListModel::SetStatus(Status status) { |
| 34 if (status_ == status) | 38 if (status_ == status) |
| 35 return; | 39 return; |
| 36 | 40 |
| 37 status_ = status; | 41 status_ = status; |
| 38 FOR_EACH_OBSERVER(AppListModelObserver, | 42 FOR_EACH_OBSERVER(AppListModelObserver, |
| 39 observers_, | 43 observers_, |
| 40 OnAppListModelStatusChanged()); | 44 OnAppListModelStatusChanged()); |
| 41 } | 45 } |
| 42 | 46 |
| 43 void AppListModel::SetCurrentUser(const base::string16& current_user_name, | 47 void AppListModel::SetUsers(const Users& users) { |
| 44 const base::string16& current_user_email) { | 48 users_ = users; |
| 45 if (current_user_name_ == current_user_name && | |
| 46 current_user_email_ == current_user_email) { | |
| 47 return; | |
| 48 } | |
| 49 current_user_name_ = current_user_name; | |
| 50 current_user_email_ = current_user_email; | |
| 51 FOR_EACH_OBSERVER(AppListModelObserver, | 49 FOR_EACH_OBSERVER(AppListModelObserver, |
| 52 observers_, | 50 observers_, |
| 53 OnAppListModelCurrentUserChanged()); | 51 OnAppListModelUsersChanged()); |
| 54 } | 52 } |
| 55 | 53 |
| 56 void AppListModel::SetSignedIn(bool signed_in) { | 54 void AppListModel::SetSignedIn(bool signed_in) { |
| 57 if (signed_in_ == signed_in) | 55 if (signed_in_ == signed_in) |
| 58 return; | 56 return; |
| 59 | 57 |
| 60 signed_in_ = signed_in; | 58 signed_in_ = signed_in; |
| 61 FOR_EACH_OBSERVER(AppListModelObserver, | 59 FOR_EACH_OBSERVER(AppListModelObserver, |
| 62 observers_, | 60 observers_, |
| 63 OnAppListModelSigninStatusChanged()); | 61 OnAppListModelSigninStatusChanged()); |
| 64 } | 62 } |
| 65 | 63 |
| 66 } // namespace app_list | 64 } // namespace app_list |
| OLD | NEW |