| 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 <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "ui/app_list/app_list_folder_item.h" | 9 #include "ui/app_list/app_list_folder_item.h" |
| 10 #include "ui/app_list/app_list_item.h" | 10 #include "ui/app_list/app_list_item.h" |
| 11 #include "ui/app_list/app_list_model_observer.h" | 11 #include "ui/app_list/app_list_model_observer.h" |
| 12 #include "ui/app_list/search_box_model.h" | 12 #include "ui/app_list/search_box_model.h" |
| 13 | 13 |
| 14 namespace app_list { | 14 namespace app_list { |
| 15 | 15 |
| 16 AppListModel::AppListModel() | 16 AppListModel::AppListModel() |
| 17 : top_level_item_list_(new AppListItemList), | 17 : top_level_item_list_(new AppListItemList), |
| 18 search_box_(new SearchBoxModel), | 18 search_box_(new SearchBoxModel), |
| 19 results_(new SearchResults), | 19 results_(new SearchResults), |
| 20 status_(STATUS_NORMAL), | 20 status_(STATUS_NORMAL), |
| 21 state_(INVALID_STATE), | 21 state_(INVALID_STATE), |
| 22 folders_enabled_(false), | 22 folders_enabled_(false), |
| 23 custom_launcher_page_enabled_(true) { | 23 custom_launcher_page_enabled_(true) { |
| 24 top_level_item_list_->AddObserver(this); | 24 top_level_item_list_->AddObserver(this); |
| 25 } | 25 } |
| 26 | 26 |
| 27 AppListModel::~AppListModel() { top_level_item_list_->RemoveObserver(this); } | 27 AppListModel::~AppListModel() { top_level_item_list_->RemoveObserver(this); } |
| 28 | 28 |
| 29 void AppListModel::AddObserver(AppListModelObserver* observer) { | 29 void AppListModel::AddObserver(AppListModelObserver* observer) { |
| 30 DLOG(ERROR) << "Adding " << observer; |
| 30 observers_.AddObserver(observer); | 31 observers_.AddObserver(observer); |
| 31 } | 32 } |
| 32 | 33 |
| 33 void AppListModel::RemoveObserver(AppListModelObserver* observer) { | 34 void AppListModel::RemoveObserver(AppListModelObserver* observer) { |
| 34 observers_.RemoveObserver(observer); | 35 DLOG(ERROR) << "Removing " << observer; |
| 36 observers_.RemoveObserver(observer); |
| 35 } | 37 } |
| 36 | 38 |
| 37 void AppListModel::SetStatus(Status status) { | 39 void AppListModel::SetStatus(Status status) { |
| 38 if (status_ == status) | 40 if (status_ == status) |
| 39 return; | 41 return; |
| 40 | 42 |
| 41 status_ = status; | 43 status_ = status; |
| 42 FOR_EACH_OBSERVER(AppListModelObserver, | 44 FOR_EACH_OBSERVER(AppListModelObserver, |
| 43 observers_, | 45 observers_, |
| 44 OnAppListModelStatusChanged()); | 46 OnAppListModelStatusChanged()); |
| (...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); | 430 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); |
| 429 result->set_folder_id(""); | 431 result->set_folder_id(""); |
| 430 if (folder->item_list()->item_count() == 0) { | 432 if (folder->item_list()->item_count() == 0) { |
| 431 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); | 433 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); |
| 432 DeleteItem(folder_id); | 434 DeleteItem(folder_id); |
| 433 } | 435 } |
| 434 return result.Pass(); | 436 return result.Pass(); |
| 435 } | 437 } |
| 436 | 438 |
| 437 } // namespace app_list | 439 } // namespace app_list |
| OLD | NEW |