Index: athena/home/app_list_view_delegate.cc |
diff --git a/athena/home/app_list_view_delegate.cc b/athena/home/app_list_view_delegate.cc |
index b7f45fb8c666f162d8d0b8eeab983df59e59c01b..1fd57c9cdab1c1cd9e196a3082833953a90be481 100644 |
--- a/athena/home/app_list_view_delegate.cc |
+++ b/athena/home/app_list_view_delegate.cc |
@@ -6,13 +6,12 @@ |
#include <string> |
+#include "athena/home/public/app_model_builder.h" |
#include "base/basictypes.h" |
#include "base/callback.h" |
#include "base/files/file_path.h" |
#include "base/strings/utf_string_conversions.h" |
#include "third_party/skia/include/core/SkBitmap.h" |
-#include "ui/app_list/app_list_item.h" |
-#include "ui/app_list/app_list_item_list.h" |
#include "ui/app_list/app_list_model.h" |
#include "ui/app_list/search_box_model.h" |
#include "ui/app_list/search_result.h" |
@@ -21,93 +20,11 @@ |
namespace athena { |
-namespace { |
- |
-const int kIconSize = 64; |
- |
-class DummyItem : public app_list::AppListItem { |
- public: |
- enum Type { |
- DUMMY_MAIL, |
- DUMMY_CALENDAR, |
- DUMMY_VIDEO, |
- DUMMY_MUSIC, |
- DUMMY_CONTACT, |
- LAST_TYPE, |
- }; |
- |
- static std::string GetTitle(Type type) { |
- switch (type) { |
- case DUMMY_MAIL: |
- return "mail"; |
- case DUMMY_CALENDAR: |
- return "calendar"; |
- case DUMMY_VIDEO: |
- return "video"; |
- case DUMMY_MUSIC: |
- return "music"; |
- case DUMMY_CONTACT: |
- return "contact"; |
- case LAST_TYPE: |
- break; |
- } |
- NOTREACHED(); |
- return ""; |
- } |
- |
- static std::string GetId(Type type) { |
- return std::string("id-") + GetTitle(type); |
- } |
- |
- explicit DummyItem(Type type) |
- : app_list::AppListItem(GetId(type)), |
- type_(type) { |
- SetIcon(GetIcon(), false /* has_shadow */); |
- SetName(GetTitle(type_)); |
- } |
- |
- private: |
- gfx::ImageSkia GetIcon() const { |
- SkColor color = SK_ColorWHITE; |
- switch (type_) { |
- case DUMMY_MAIL: |
- color = SK_ColorRED; |
- break; |
- case DUMMY_CALENDAR: |
- color = SK_ColorBLUE; |
- break; |
- case DUMMY_VIDEO: |
- color = SK_ColorGREEN; |
- break; |
- case DUMMY_MUSIC: |
- color = SK_ColorYELLOW; |
- break; |
- case DUMMY_CONTACT: |
- color = SK_ColorCYAN; |
- break; |
- case LAST_TYPE: |
- NOTREACHED(); |
- break; |
- } |
- SkBitmap bitmap; |
- bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize); |
- bitmap.allocPixels(); |
- bitmap.eraseColor(color); |
- return gfx::ImageSkia::CreateFrom1xBitmap(bitmap); |
- } |
- |
- Type type_; |
- |
- DISALLOW_COPY_AND_ASSIGN(DummyItem); |
-}; |
- |
-} // namespace |
- |
-AppListViewDelegate::AppListViewDelegate() |
+AppListViewDelegate::AppListViewDelegate(AppModelBuilder* model_builder) |
: model_(new app_list::AppListModel), |
speech_ui_(new app_list::SpeechUIModel( |
app_list::SPEECH_RECOGNITION_OFF)) { |
- PopulateApps(); |
+ model_builder->PopulateApps(model_.get()); |
// TODO(mukai): get the text from the resources. |
model_->search_box()->SetHintText(base::ASCIIToUTF16("Search")); |
} |
@@ -115,13 +32,6 @@ AppListViewDelegate::AppListViewDelegate() |
AppListViewDelegate::~AppListViewDelegate() { |
} |
-void AppListViewDelegate::PopulateApps() { |
- for (int i = 0; i < static_cast<int>(DummyItem::LAST_TYPE); ++i) { |
- model_->AddItem(scoped_ptr<app_list::AppListItem>( |
- new DummyItem(static_cast<DummyItem::Type>(i)))); |
- } |
-} |
- |
bool AppListViewDelegate::ForceNativeDesktop() const { |
return false; |
} |