Update broken references to image assets
[chromium-blink-merge.git] / chrome / browser / extensions / extension_action_icon_factory.cc
bloba7e8df3043b89b0c226df33c89ce1830a5b539f4
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(
16 Profile* profile,
17 const Extension* extension,
18 ExtensionAction* action,
19 Observer* observer)
20 : extension_(extension),
21 action_(action),
22 observer_(observer),
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) {
34 if (observer_)
35 observer_->OnIconUpdated();
38 void ExtensionActionIconFactory::OnExtensionIconImageDestroyed(
39 IconImage* image) {
40 icon_image_observer_.RemoveAll();
43 gfx::Image ExtensionActionIconFactory::GetIcon(int tab_id) {
44 gfx::Image icon = action_->GetExplicitlySetIcon(tab_id);
45 if (!icon.IsEmpty())
46 return icon;
48 icon = action_->GetDeclarativeIcon(tab_id);
49 if (!icon.IsEmpty())
50 return icon;
52 return action_->GetDefaultIconImage();