1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/extension_action_icon_factory.h"
7 #include "chrome/browser/extensions/extension_action.h"
8 #include "chrome/browser/profiles/profile.h"
9 #include "chrome/common/extensions/extension_icon_set.h"
10 #include "extensions/common/extension.h"
11 #include "grit/theme_resources.h"
12 #include "ui/base/resource/resource_bundle.h"
13 #include "ui/gfx/image/image_skia.h"
15 using extensions::Extension
;
16 using extensions::IconImage
;
20 gfx::ImageSkia
GetDefaultIcon() {
21 return *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
22 IDR_EXTENSIONS_FAVICON
).ToImageSkia();
27 ExtensionActionIconFactory::ExtensionActionIconFactory(
29 const Extension
* extension
,
30 const ExtensionAction
* action
,
32 : extension_(extension
),
35 if (action_
->default_icon()) {
36 default_icon_
.reset(new IconImage(
39 *action_
->default_icon(),
40 ExtensionAction::GetIconSizeForType(action_
->action_type()),
46 ExtensionActionIconFactory::~ExtensionActionIconFactory() {}
48 // extensions::IconImage::Observer overrides.
49 void ExtensionActionIconFactory::OnExtensionIconImageChanged(IconImage
* image
) {
51 observer_
->OnIconUpdated();
54 gfx::Image
ExtensionActionIconFactory::GetIcon(int tab_id
) {
55 gfx::ImageSkia base_icon
= GetBaseIconFromAction(tab_id
);
56 return action_
->ApplyAttentionAndAnimation(base_icon
, tab_id
);
59 gfx::ImageSkia
ExtensionActionIconFactory::GetBaseIconFromAction(int tab_id
) {
60 gfx::ImageSkia icon
= action_
->GetExplicitlySetIcon(tab_id
);
65 return default_icon_
->image_skia();
67 return GetDefaultIcon();