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

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
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..b209aece87245c48c256d4b2dd5bb9977aff93c3
--- /dev/null
+++ b/athena/content/content_app_model_builder.cc
@@ -0,0 +1,85 @@
+// 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,
+ content::BrowserContext* browser_context)
+ : app_list::AppListItem(id),
+ id_(id),
+ browser_context_(browser_context) {
+ SetIcon(GetIcon(), false /* has_shadow */);
+ SetName(id);
+ }
+
+ private:
+ gfx::ImageSkia GetIcon() const {
oshima 2014/06/09 22:24:38 and you can pass the color to this function and ma
Jun Mukai 2014/06/09 22:35:25 Done.
+ SkColor color = SK_ColorWHITE;
+ if (id_ == "mail")
+ color = SK_ColorRED;
+ else if (id_ == "calendar")
+ color = SK_ColorBLUE;
+ else if (id_ == "video")
+ color = SK_ColorGREEN;
+ else if (id_ == "music")
+ color = SK_ColorYELLOW;
+ else if (id_ == "contact")
+ color = SK_ColorCYAN;
+ else
+ NOTREACHED();
+
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
+ bitmap.allocPixels();
+ bitmap.eraseColor(color);
+ return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
+ }
+
+ // 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) {
+ const char* kDummyItemIds[] = {
+ "mail", "calendar", "video", "music", "contact"};
oshima 2014/06/09 22:24:38 you should just pass the name and color. My recomm
Jun Mukai 2014/06/09 22:35:25 Done.
+ for (size_t i = 0; i < arraysize(kDummyItemIds); ++i) {
+ model->AddItem(scoped_ptr<app_list::AppListItem>(
+ new DummyItem(kDummyItemIds[i], browser_context_)));
+ }
+}
+
+} // namespace athena

Powered by Google App Engine
This is Rietveld 408576698