summaryrefslogtreecommitdiffstats
path: root/athena/content
diff options
context:
space:
mode:
authormukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 08:22:47 +0000
committermukai@chromium.org <mukai@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-17 08:22:47 +0000
commit06ab83c188942061620a6e88e03a939bb0ffb3b7 (patch)
tree57f58ebc95011539dfd664f85929ab33e169fd39 /athena/content
parent3c08a8b453a35715e70bae92e11065b937885920 (diff)
downloadchromium_src-06ab83c188942061620a6e88e03a939bb0ffb3b7.zip
chromium_src-06ab83c188942061620a6e88e03a939bb0ffb3b7.tar.gz
chromium_src-06ab83c188942061620a6e88e03a939bb0ffb3b7.tar.bz2
Adds an item for loaded app.
A big todo is to load the icon correctly. extension_icon_image is still under chrome/browser for multiple reasons. BUG=380421 R=jamescook@chromium.org, oshima@chromium.org TBR=miket@chromium.org TEST=manually Review URL: https://codereview.chromium.org/336263002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@277668 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'athena/content')
-rw-r--r--athena/content/DEPS2
-rw-r--r--athena/content/content_app_model_builder.cc57
2 files changed, 54 insertions, 5 deletions
diff --git a/athena/content/DEPS b/athena/content/DEPS
index 170a27e..f674843 100644
--- a/athena/content/DEPS
+++ b/athena/content/DEPS
@@ -1,8 +1,10 @@
include_rules = [
+ "+apps/shell/browser",
"+athena/activity/public",
"+athena/home/public",
"+athena/input/public",
"+content/public",
+ "+extensions/common",
"+ui/app_list",
"+ui/views",
]
diff --git a/athena/content/content_app_model_builder.cc b/athena/content/content_app_model_builder.cc
index 56bad71..7fcad45 100644
--- a/athena/content/content_app_model_builder.cc
+++ b/athena/content/content_app_model_builder.cc
@@ -4,17 +4,35 @@
#include "athena/content/public/content_app_model_builder.h"
+#include "apps/shell/browser/shell_extension_system.h"
#include "athena/activity/public/activity_factory.h"
#include "athena/activity/public/activity_manager.h"
+#include "extensions/common/extension.h"
#include "ui/app_list/app_list_item.h"
#include "ui/app_list/app_list_model.h"
+using extensions::ShellExtensionSystem;
+
namespace athena {
namespace {
const int kIconSize = 64;
+ShellExtensionSystem* GetShellExtensionSystem(
+ content::BrowserContext* context) {
+ return static_cast<ShellExtensionSystem*>(
+ extensions::ExtensionSystem::Get(context));
+}
+
+gfx::ImageSkia CreateFlatColorImage(SkColor color) {
+ SkBitmap bitmap;
+ bitmap.setConfig(SkBitmap::kARGB_8888_Config, kIconSize, kIconSize);
+ bitmap.allocPixels();
+ bitmap.eraseColor(color);
+ return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
+}
+
// Same dummy item.
class DummyItem : public app_list::AppListItem {
public:
@@ -25,11 +43,7 @@ class DummyItem : public app_list::AppListItem {
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 */);
+ SetIcon(CreateFlatColorImage(color), false /* has_shadow */);
SetName(id);
}
@@ -47,6 +61,32 @@ class DummyItem : public app_list::AppListItem {
DISALLOW_COPY_AND_ASSIGN(DummyItem);
};
+class AppItem : public app_list::AppListItem {
+ public:
+ AppItem(scoped_refptr<extensions::Extension> extension,
+ content::BrowserContext* browser_context)
+ : app_list::AppListItem(extension->id()),
+ extension_(extension),
+ browser_context_(browser_context) {
+ // TODO(mukai): componentize extension_icon_image and use it.
+ SetIcon(CreateFlatColorImage(SK_ColorBLACK), false);
+ SetName(extension->name());
+ }
+
+ private:
+ // Overridden from app_list::AppListItem:
+ virtual void Activate(int event_flags) OVERRIDE {
+ // TODO(mukai): Pass |extension_| when the extension system supports
+ // multiple extensions.
+ GetShellExtensionSystem(browser_context_)->LaunchApp();
+ }
+
+ scoped_refptr<extensions::Extension> extension_;
+ content::BrowserContext* browser_context_;
+
+ DISALLOW_COPY_AND_ASSIGN(AppItem);
+};
+
} // namespace
ContentAppModelBuilder::ContentAppModelBuilder(
@@ -68,6 +108,13 @@ void ContentAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
new DummyItem("music", SK_ColorYELLOW, browser_context_)));
model->AddItem(scoped_ptr<app_list::AppListItem>(
new DummyItem("contact", SK_ColorCYAN, browser_context_)));
+
+ ShellExtensionSystem* extension_system =
+ GetShellExtensionSystem(browser_context_);
+ if (extension_system && extension_system->extension()) {
+ model->AddItem(scoped_ptr<app_list::AppListItem>(
+ new AppItem(extension_system->extension(), browser_context_)));
+ }
}
} // namespace athena