OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "athena/content/public/content_app_model_builder.h" | 5 #include "athena/content/public/content_app_model_builder.h" |
6 | 6 |
7 #include "athena/activity/public/activity_factory.h" | 7 #include "athena/activity/public/activity_factory.h" |
8 #include "athena/activity/public/activity_manager.h" | 8 #include "athena/activity/public/activity_manager.h" |
9 #include "athena/extensions/public/extensions_delegate.h" | 9 #include "athena/extensions/public/extensions_delegate.h" |
10 #include "extensions/browser/extension_icon_image.h" | 10 #include "extensions/browser/extension_icon_image.h" |
11 #include "extensions/common/constants.h" | 11 #include "extensions/common/constants.h" |
12 #include "extensions/common/extension_set.h" | 12 #include "extensions/common/extension_set.h" |
13 #include "extensions/common/manifest_handlers/icons_handler.h" | 13 #include "extensions/common/manifest_handlers/icons_handler.h" |
| 14 #include "extensions/grit/extensions_browser_resources.h" |
14 #include "ui/app_list/app_list_item.h" | 15 #include "ui/app_list/app_list_item.h" |
15 #include "ui/app_list/app_list_model.h" | 16 #include "ui/app_list/app_list_model.h" |
| 17 #include "ui/base/resource/resource_bundle.h" |
16 | 18 |
17 namespace athena { | 19 namespace athena { |
18 | 20 |
19 namespace { | 21 namespace { |
20 | 22 |
21 gfx::ImageSkia CreateFlatColorImage(SkColor color) { | 23 gfx::ImageSkia CreateFlatColorImage(SkColor color) { |
22 SkBitmap bitmap; | 24 SkBitmap bitmap; |
23 bitmap.allocN32Pixels(extension_misc::EXTENSION_ICON_MEDIUM, | 25 bitmap.allocN32Pixels(extension_misc::EXTENSION_ICON_MEDIUM, |
24 extension_misc::EXTENSION_ICON_MEDIUM); | 26 extension_misc::EXTENSION_ICON_MEDIUM); |
25 bitmap.eraseColor(color); | 27 bitmap.eraseColor(color); |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 public: | 60 public: |
59 AppItem(scoped_refptr<const extensions::Extension> extension, | 61 AppItem(scoped_refptr<const extensions::Extension> extension, |
60 content::BrowserContext* browser_context) | 62 content::BrowserContext* browser_context) |
61 : app_list::AppListItem(extension->id()), | 63 : app_list::AppListItem(extension->id()), |
62 extension_(extension), | 64 extension_(extension), |
63 browser_context_(browser_context), | 65 browser_context_(browser_context), |
64 icon_image_(browser_context_, | 66 icon_image_(browser_context_, |
65 extension.get(), | 67 extension.get(), |
66 extensions::IconsInfo::GetIcons(extension.get()), | 68 extensions::IconsInfo::GetIcons(extension.get()), |
67 extension_misc::EXTENSION_ICON_MEDIUM, | 69 extension_misc::EXTENSION_ICON_MEDIUM, |
68 // TODO(mukai): better default icon | 70 *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed( |
69 CreateFlatColorImage(SK_ColorBLACK), | 71 IDR_APP_DEFAULT_ICON), |
70 NULL) { | 72 NULL) { |
71 icon_image_.image_skia().EnsureRepsForSupportedScales(); | 73 icon_image_.image_skia().EnsureRepsForSupportedScales(); |
72 SetIcon(icon_image_.image_skia(), false); | 74 SetIcon(icon_image_.image_skia(), false); |
73 SetName(extension->name()); | 75 SetName(extension->name()); |
74 } | 76 } |
75 | 77 |
76 private: | 78 private: |
77 // Overridden from app_list::AppListItem: | 79 // Overridden from app_list::AppListItem: |
78 virtual void Activate(int event_flags) OVERRIDE { | 80 virtual void Activate(int event_flags) OVERRIDE { |
79 ExtensionsDelegate::Get(browser_context_)->LaunchApp(extension_->id()); | 81 ExtensionsDelegate::Get(browser_context_)->LaunchApp(extension_->id()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
118 "video", GURL("http://youtube.com/"), SK_ColorGREEN, browser_context_))); | 120 "video", GURL("http://youtube.com/"), SK_ColorGREEN, browser_context_))); |
119 model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem( | 121 model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem( |
120 "music", GURL("http://play.google.com/music"), | 122 "music", GURL("http://play.google.com/music"), |
121 SK_ColorYELLOW, browser_context_))); | 123 SK_ColorYELLOW, browser_context_))); |
122 model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem( | 124 model->AddItem(scoped_ptr<app_list::AppListItem>(new DummyItem( |
123 "contact", GURL("https://www.google.com/contacts"), | 125 "contact", GURL("https://www.google.com/contacts"), |
124 SK_ColorCYAN, browser_context_))); | 126 SK_ColorCYAN, browser_context_))); |
125 } | 127 } |
126 | 128 |
127 } // namespace athena | 129 } // namespace athena |
OLD | NEW |