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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "athena/content/public/content_app_model_builder.h"
6
7 #include "athena/activity/public/activity_factory.h"
8 #include "athena/activity/public/activity_manager.h"
9 #include "ui/app_list/app_list_item.h"
10 #include "ui/app_list/app_list_model.h"
11
12 namespace athena {
13
14 namespace {
15
16 const int kIconSize = 64;
17
18 // Same dummy item.
19 class DummyItem : public app_list::AppListItem {
20 public:
21 DummyItem(const std::string& id,
22 SkColor color,
23 content::BrowserContext* browser_context)
24 : app_list::AppListItem(id),
25 id_(id),
26 browser_context_(browser_context) {
27
28 SkBitmap bitmap;
29 bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
30 bitmap.allocPixels();
31 bitmap.eraseColor(color);
32 SetIcon(gfx::ImageSkia::CreateFrom1xBitmap(bitmap), false /* has_shadow */);
33 SetName(id);
34 }
35
36 private:
37 // Overridden from app_list::AppListItem:
38 virtual void Activate(int event_flags) OVERRIDE {
39 ActivityManager::Get()->AddActivity(
40 ActivityFactory::Get()->CreateAppActivity(
41 browser_context_, id_));
42 }
43
44 std::string id_;
45 content::BrowserContext* browser_context_;
46
47 DISALLOW_COPY_AND_ASSIGN(DummyItem);
48 };
49
50 } // namespace
51
52 ContentAppModelBuilder::ContentAppModelBuilder(
53 content::BrowserContext* browser_context)
54 : browser_context_(browser_context) {
55 }
56
57 ContentAppModelBuilder::~ContentAppModelBuilder() {
58 }
59
60 void ContentAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
61 model->AddItem(scoped_ptr<app_list::AppListItem>(
62 new DummyItem("mail", SK_ColorRED, browser_context_)));
63 model->AddItem(scoped_ptr<app_list::AppListItem>(
64 new DummyItem("calendar", SK_ColorBLUE, browser_context_)));
65 model->AddItem(scoped_ptr<app_list::AppListItem>(
66 new DummyItem("video", SK_ColorGREEN, browser_context_)));
67 model->AddItem(scoped_ptr<app_list::AppListItem>(
68 new DummyItem("music", SK_ColorYELLOW, browser_context_)));
69 model->AddItem(scoped_ptr<app_list::AppListItem>(
70 new DummyItem("contact", SK_ColorCYAN, browser_context_)));
71 }
72
73 } // namespace athena
OLDNEW
« 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