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 "ui/gfx/image/image.h"
10 #include "ui/gfx/image/image_skia.h"
12 using extensions::Extension
;
13 using extensions::IconImage
;
15 ExtensionActionIconFactory::ExtensionActionIconFactory(
17 const Extension
* extension
,
18 ExtensionAction
* action
,
20 : extension_(extension
),
23 icon_image_observer_(this) {
24 extensions::IconImage
* default_icon_image
=
25 action
->LoadDefaultIconImage(*extension
, profile
);
26 if (default_icon_image
)
27 icon_image_observer_
.Add(default_icon_image
);
30 ExtensionActionIconFactory::~ExtensionActionIconFactory() {}
32 // extensions::IconImage::Observer overrides.
33 void ExtensionActionIconFactory::OnExtensionIconImageChanged(IconImage
* image
) {
35 observer_
->OnIconUpdated();
38 void ExtensionActionIconFactory::OnExtensionIconImageDestroyed(
40 icon_image_observer_
.RemoveAll();
43 gfx::Image
ExtensionActionIconFactory::GetIcon(int tab_id
) {
44 gfx::Image icon
= action_
->GetExplicitlySetIcon(tab_id
);
48 icon
= action_
->GetDeclarativeIcon(tab_id
);
52 return action_
->GetDefaultIconImage();