Index: athena/content/content_app_model_builder.cc |
diff --git a/athena/content/content_app_model_builder.cc b/athena/content/content_app_model_builder.cc |
new file mode 100644 |
index 0000000000000000000000000000000000000000..d9a36730f41210722cb2822a16885773fd5b49a0 |
--- /dev/null |
+++ b/athena/content/content_app_model_builder.cc |
@@ -0,0 +1,73 @@ |
+// Copyright 2014 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
+ |
+#include "athena/content/public/content_app_model_builder.h" |
+ |
+#include "athena/activity/public/activity_factory.h" |
+#include "athena/activity/public/activity_manager.h" |
+#include "ui/app_list/app_list_item.h" |
+#include "ui/app_list/app_list_model.h" |
+ |
+namespace athena { |
+ |
+namespace { |
+ |
+const int kIconSize = 64; |
+ |
+// Same dummy item. |
+class DummyItem : public app_list::AppListItem { |
+ public: |
+ explicit DummyItem(const std::string& id, |
oshima
2014/06/09 22:44:52
remove explicit
|
+ SkColor color, |
+ content::BrowserContext* browser_context) |
+ : app_list::AppListItem(id), |
+ id_(id), |
+ browser_context_(browser_context) { |
+ |
+ SkBitmap bitmap; |
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize); |
+ bitmap.allocPixels(); |
+ bitmap.eraseColor(color); |
+ SetIcon(gfx::ImageSkia::CreateFrom1xBitmap(bitmap), false /* has_shadow */); |
+ SetName(id); |
+ } |
+ |
+ private: |
+ // Overridden from app_list::AppListItem: |
+ virtual void Activate(int event_flags) OVERRIDE { |
+ ActivityManager::Get()->AddActivity( |
+ ActivityFactory::Get()->CreateAppActivity( |
+ browser_context_, id_)); |
+ } |
+ |
+ std::string id_; |
+ content::BrowserContext* browser_context_; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(DummyItem); |
+}; |
+ |
+} // namespace |
+ |
+ContentAppModelBuilder::ContentAppModelBuilder( |
+ content::BrowserContext* browser_context) |
+ : browser_context_(browser_context) { |
+} |
+ |
+ContentAppModelBuilder::~ContentAppModelBuilder() { |
+} |
+ |
+void ContentAppModelBuilder::PopulateApps(app_list::AppListModel* model) { |
+ model->AddItem(scoped_ptr<app_list::AppListItem>( |
+ new DummyItem("mail", SK_COlorRED, browser_context_))); |
+ model->AddItem(scoped_ptr<app_list::AppListItem>( |
+ new DummyItem("calendar", SK_COlorBLUE, browser_context_))); |
+ model->AddItem(scoped_ptr<app_list::AppListItem>( |
+ new DummyItem("video", SK_COlorGREEN, browser_context_))); |
+ model->AddItem(scoped_ptr<app_list::AppListItem>( |
+ new DummyItem("music", SK_COlorYELLOW, browser_context_))); |
+ model->AddItem(scoped_ptr<app_list::AppListItem>( |
+ new DummyItem("contact", SK_COlorCYAN, browser_context_))); |
+} |
+ |
+} // namespace athena |