Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(595)

Unified Diff: athena/content/content_app_model_builder.cc

Issue 311113005: AppModelBuilder to athena. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/content/content_activity_factory.cc ('k') | athena/content/public/content_activity_factory.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« no previous file with comments | « athena/content/content_activity_factory.cc ('k') | athena/content/public/content_activity_factory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698