summaryrefslogtreecommitdiffstats
path: root/athena/content
diff options
context:
space:
mode:
authormukai <mukai@chromium.org>2014-09-09 14:26:31 -0700
committerCommit bot <commit-bot@chromium.org>2014-09-09 21:50:53 +0000
commit1fed1b5fe736ea42a505a0b54445e86f8f195f33 (patch)
treec83d3bed0fd7f4244e643c991d255018284e1c20 /athena/content
parent3914c25088c75525c0aa3cfcdf544faa1ec09bce (diff)
downloadchromium_src-1fed1b5fe736ea42a505a0b54445e86f8f195f33.zip
chromium_src-1fed1b5fe736ea42a505a0b54445e86f8f195f33.tar.gz
chromium_src-1fed1b5fe736ea42a505a0b54445e86f8f195f33.tar.bz2
Move ContentAppModelBuilder to athena/extensions.
The AppModelBuilder does not rely on content so much, rather it's highly related to the extension system. Therefore, it's better to be in athena/extensions, and its name should be ExtensionAppModelBuilder instead. This will simplifies DEPS rules of athena/content. BUG=None R=oshima@chromium.org TBR=yoz@chromium.org, xiyuan@chromium.org, tony@chromium.org TEST=build Review URL: https://codereview.chromium.org/543263002 Cr-Commit-Position: refs/heads/master@{#294011}
Diffstat (limited to 'athena/content')
-rw-r--r--athena/content/DEPS11
-rw-r--r--athena/content/chrome/DEPS2
-rw-r--r--athena/content/content_app_model_builder.cc130
-rw-r--r--athena/content/public/content_app_model_builder.h32
4 files changed, 7 insertions, 168 deletions
diff --git a/athena/content/DEPS b/athena/content/DEPS
index 9384749..6bda5ed 100644
--- a/athena/content/DEPS
+++ b/athena/content/DEPS
@@ -7,12 +7,7 @@ include_rules = [
"+components/renderer_context_menu",
"+components/web_modal",
"+content/public",
- "+extensions/browser",
- "+extensions/common",
- "+extensions/grit",
- "+ui/app_list",
"+ui/aura",
- "+ui/base/resource",
"+ui/compositor",
"+ui/gfx",
"+ui/views",
@@ -21,3 +16,9 @@ include_rules = [
# strictly enum/POD, header-only types, and some selected common code.
"+third_party/WebKit/public/web/WebContextMenuData.h",
]
+
+specific_include_rules = {
+ "app_activity_unittest.cc": [
+ "+extensions/common",
+ ],
+}
diff --git a/athena/content/chrome/DEPS b/athena/content/chrome/DEPS
index 0c95146..1ed430c 100644
--- a/athena/content/chrome/DEPS
+++ b/athena/content/chrome/DEPS
@@ -1,3 +1,3 @@
include_rules = [
- "+apps/app_window.h",
+ "+extensions/browser/app_window/app_window.h",
]
diff --git a/athena/content/content_app_model_builder.cc b/athena/content/content_app_model_builder.cc
deleted file mode 100644
index ee5156a..0000000
--- a/athena/content/content_app_model_builder.cc
+++ /dev/null
@@ -1,130 +0,0 @@
-// 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 "athena/extensions/public/extensions_delegate.h"
-#include "extensions/browser/extension_icon_image.h"
-#include "extensions/common/constants.h"
-#include "extensions/common/extension_set.h"
-#include "extensions/common/manifest_handlers/icons_handler.h"
-#include "extensions/grit/extensions_browser_resources.h"
-#include "ui/app_list/app_list_item.h"
-#include "ui/app_list/app_list_model.h"
-#include "ui/base/resource/resource_bundle.h"
-
-namespace athena {
-
-namespace {
-
-gfx::ImageSkia CreateFlatColorImage(SkColor color) {
- SkBitmap bitmap;
- bitmap.allocN32Pixels(extension_misc::EXTENSION_ICON_MEDIUM,
- extension_misc::EXTENSION_ICON_MEDIUM);
- bitmap.eraseColor(color);
- return gfx::ImageSkia::CreateFrom1xBitmap(bitmap);
-}
-
-// Same dummy item.
-class DummyItem : public app_list::AppListItem {
- public:
- DummyItem(const std::string& id,
- const GURL& url,
- SkColor color,
- content::BrowserContext* browser_context)
- : app_list::AppListItem(id),
- url_(url),
- browser_context_(browser_context) {
-
- SetIcon(CreateFlatColorImage(color), false /* has_shadow */);
- SetName(id);
- }
-
- private:
- // Overridden from app_list::AppListItem:
- virtual void Activate(int event_flags) OVERRIDE {
- ActivityManager::Get()->AddActivity(
- ActivityFactory::Get()->CreateWebActivity(
- browser_context_, base::string16(), url_));
- }
-
- GURL url_;
- content::BrowserContext* browser_context_;
-
- DISALLOW_COPY_AND_ASSIGN(DummyItem);
-};
-
-class AppItem : public app_list::AppListItem {
- public:
- AppItem(scoped_refptr<const extensions::Extension> extension,
- content::BrowserContext* browser_context)
- : app_list::AppListItem(extension->id()),
- extension_(extension),
- browser_context_(browser_context),
- icon_image_(browser_context_,
- extension.get(),
- extensions::IconsInfo::GetIcons(extension.get()),
- extension_misc::EXTENSION_ICON_MEDIUM,
- *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
- IDR_APP_DEFAULT_ICON),
- NULL) {
- icon_image_.image_skia().EnsureRepsForSupportedScales();
- SetIcon(icon_image_.image_skia(), false);
- SetName(extension->name());
- }
-
- private:
- // Overridden from app_list::AppListItem:
- virtual void Activate(int event_flags) OVERRIDE {
- ExtensionsDelegate::Get(browser_context_)->LaunchApp(extension_->id());
- }
-
- scoped_refptr<const extensions::Extension> extension_;
- content::BrowserContext* browser_context_;
- extensions::IconImage icon_image_;
-
- DISALLOW_COPY_AND_ASSIGN(AppItem);
-};
-
-} // namespace
-
-ContentAppModelBuilder::ContentAppModelBuilder(
- content::BrowserContext* browser_context)
- : browser_context_(browser_context) {
-}
-
-ContentAppModelBuilder::~ContentAppModelBuilder() {
-}
-
-void ContentAppModelBuilder::PopulateApps(app_list::AppListModel* model) {
- ExtensionsDelegate* bridge = ExtensionsDelegate::Get(browser_context_);
- const extensions::ExtensionSet& extensions = bridge->GetInstalledExtensions();
- for (extensions::ExtensionSet::const_iterator iter = extensions.begin();
- iter != extensions.end();
- ++iter) {
- // TODO(mukai): use chrome/browser/extension_ui_util.
- if ((*iter)->ShouldDisplayInAppLauncher()) {
- model->AddItem(scoped_ptr<app_list::AppListItem>(
- new AppItem(*iter, browser_context_)));
- }
- }
-
- model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
- "mail", GURL("http://gmail.com/"), SK_ColorRED, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
- "calendar", GURL("https://calendar.google.com/"),
- SK_ColorBLUE, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
- "video", GURL("http://youtube.com/"), SK_ColorGREEN, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
- "music", GURL("http://play.google.com/music"),
- SK_ColorYELLOW, browser_context_)));
- model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem(
- "contact", GURL("https://www.google.com/contacts"),
- SK_ColorCYAN, browser_context_)));
-}
-
-} // namespace athena
diff --git a/athena/content/public/content_app_model_builder.h b/athena/content/public/content_app_model_builder.h
deleted file mode 100644
index 85c7999..0000000
--- a/athena/content/public/content_app_model_builder.h
+++ /dev/null
@@ -1,32 +0,0 @@
-// 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.
-
-#ifndef ATHENA_CONTENT_PUBLIC_CONTENT_APP_MODEL_BUILDER_H_
-#define ATHENA_CONTENT_PUBLIC_CONTENT_APP_MODEL_BUILDER_H_
-
-#include "athena/home/public/app_model_builder.h"
-#include "base/macros.h"
-
-namespace content {
-class BrowserContext;
-}
-
-namespace athena {
-
-class ATHENA_EXPORT ContentAppModelBuilder : public AppModelBuilder {
- public:
- explicit ContentAppModelBuilder(content::BrowserContext* browser_context);
- virtual ~ContentAppModelBuilder();
-
- virtual void PopulateApps(app_list::AppListModel* model) OVERRIDE;
-
- private:
- content::BrowserContext* browser_context_;
-
- DISALLOW_COPY_AND_ASSIGN(ContentAppModelBuilder);
-};
-
-} // namespace athena
-
-#endif // ATHENA_CONTENT_PUBLIC_CONTENT_APP_MODEL_BUILDER_H_