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

Unified Diff: athena/content/content_app_model_builder.cc

Issue 543263002: Move ContentAppModelBuilder to athena/extensions. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DEPS fix Created 6 years, 3 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « athena/content/chrome/DEPS ('k') | athena/content/public/content_app_model_builder.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: athena/content/content_app_model_builder.cc
diff --git a/athena/content/content_app_model_builder.cc b/athena/content/content_app_model_builder.cc
deleted file mode 100644
index ee5156ae21f24c833ab15b8f04d97528c1476e0d..0000000000000000000000000000000000000000
--- 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
« no previous file with comments | « athena/content/chrome/DEPS ('k') | athena/content/public/content_app_model_builder.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698