summaryrefslogtreecommitdiffstats
path: root/athena
diff options
context:
space:
mode:
Diffstat (limited to 'athena')
-rw-r--r--athena/athena.gyp2
-rw-r--r--athena/content/DEPS2
-rw-r--r--athena/content/content_app_model_builder.cc57
-rw-r--r--athena/main/athena_main.cc13
4 files changed, 62 insertions, 12 deletions
diff --git a/athena/athena.gyp b/athena/athena.gyp
index b6ecb87..360dd1c 100644
--- a/athena/athena.gyp
+++ b/athena/athena.gyp
@@ -59,7 +59,7 @@
},
{
'target_name': 'athena_content_lib',
- 'type': '<(component)',
+ 'type': 'static_library',
'dependencies': [
'athena_lib',
'../content/content.gyp:content_browser',
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
diff --git a/athena/main/athena_main.cc b/athena/main/athena_main.cc
index 4a69779..d76dc66 100644
--- a/athena/main/athena_main.cc
+++ b/athena/main/athena_main.cc
@@ -29,12 +29,6 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
// apps::ShellBrowserMainDelegate:
virtual void Start(content::BrowserContext* context) OVERRIDE {
- athena::StartAthena(
- apps::ShellDesktopController::instance()->host()->window(),
- new athena::ContentActivityFactory(),
- new athena::ContentAppModelBuilder(context));
- athena::HomeCard::Get()->RegisterSearchProvider(
- new athena::UrlSearchProvider(context));
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
if (command_line->HasSwitch(kAppSwitch)) {
base::FilePath app_dir(command_line->GetSwitchValueNative(kAppSwitch));
@@ -44,6 +38,13 @@ class AthenaBrowserMainDelegate : public apps::ShellBrowserMainDelegate {
extensions::ExtensionSystem::Get(context));
extension_system->LoadApp(app_absolute_dir);
}
+
+ athena::StartAthena(
+ apps::ShellDesktopController::instance()->host()->window(),
+ new athena::ContentActivityFactory(),
+ new athena::ContentAppModelBuilder(context));
+ athena::HomeCard::Get()->RegisterSearchProvider(
+ new athena::UrlSearchProvider(context));
CreateTestPages(context);
}