OLD | NEW |
(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 |
OLD | NEW |