| 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 search_engine_is_google_(false) { |
| 24 top_level_item_list_->AddObserver(this); | 25 top_level_item_list_->AddObserver(this); |
| 25 } | 26 } |
| 26 | 27 |
| 27 AppListModel::~AppListModel() { top_level_item_list_->RemoveObserver(this); } | 28 AppListModel::~AppListModel() { top_level_item_list_->RemoveObserver(this); } |
| 28 | 29 |
| 29 void AppListModel::AddObserver(AppListModelObserver* observer) { | 30 void AppListModel::AddObserver(AppListModelObserver* 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) { |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 340 return false; | 341 return false; |
| 341 | 342 |
| 342 --custom_launcher_page_subpage_depth_; | 343 --custom_launcher_page_subpage_depth_; |
| 343 return true; | 344 return true; |
| 344 } | 345 } |
| 345 | 346 |
| 346 void AppListModel::ClearCustomLauncherPageSubpages() { | 347 void AppListModel::ClearCustomLauncherPageSubpages() { |
| 347 custom_launcher_page_subpage_depth_ = 0; | 348 custom_launcher_page_subpage_depth_ = 0; |
| 348 } | 349 } |
| 349 | 350 |
| 351 void AppListModel::SetSearchEngineIsGoogle(bool is_google) { |
| 352 search_engine_is_google_ = is_google; |
| 353 FOR_EACH_OBSERVER(AppListModelObserver, observers_, |
| 354 OnSearchEngineIsGoogleChanged(is_google)); |
| 355 } |
| 356 |
| 350 // Private methods | 357 // Private methods |
| 351 | 358 |
| 352 void AppListModel::OnListItemMoved(size_t from_index, | 359 void AppListModel::OnListItemMoved(size_t from_index, |
| 353 size_t to_index, | 360 size_t to_index, |
| 354 AppListItem* item) { | 361 AppListItem* item) { |
| 355 FOR_EACH_OBSERVER(AppListModelObserver, | 362 FOR_EACH_OBSERVER(AppListModelObserver, |
| 356 observers_, | 363 observers_, |
| 357 OnAppListItemUpdated(item)); | 364 OnAppListItemUpdated(item)); |
| 358 } | 365 } |
| 359 | 366 |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 428 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); | 435 scoped_ptr<AppListItem> result = folder->item_list()->RemoveItem(item->id()); |
| 429 result->set_folder_id(""); | 436 result->set_folder_id(""); |
| 430 if (folder->item_list()->item_count() == 0) { | 437 if (folder->item_list()->item_count() == 0) { |
| 431 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); | 438 DVLOG(2) << "Deleting empty folder: " << folder->ToDebugString(); |
| 432 DeleteItem(folder_id); | 439 DeleteItem(folder_id); |
| 433 } | 440 } |
| 434 return result.Pass(); | 441 return result.Pass(); |
| 435 } | 442 } |
| 436 | 443 |
| 437 } // namespace app_list | 444 } // namespace app_list |
| OLD | NEW |