| Index: chrome/browser/extensions/extension_action_icon_factory.h
|
| diff --git a/chrome/browser/extensions/extension_action_icon_factory.h b/chrome/browser/extensions/extension_action_icon_factory.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e3cc4ecf3b437158631ced9bcef02c70a316b943
|
| --- /dev/null
|
| +++ b/chrome/browser/extensions/extension_action_icon_factory.h
|
| @@ -0,0 +1,62 @@
|
| +// Copyright (c) 2012 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.
|
| +
|
| +#ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
|
| +#define CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
|
| +
|
| +#include "base/memory/scoped_ptr.h"
|
| +#include "chrome/browser/extensions/extension_icon_image.h"
|
| +#include "chrome/common/extensions/extension_icon_factory_delegate.h"
|
| +
|
| +class ExtensionIconSet;
|
| +
|
| +namespace extensions {
|
| +class Extension;
|
| +}
|
| +
|
| +// Used to creates new image skia icon for extension actions using
|
| +// extensions::IconImage.
|
| +// It observes underlaying IconImage and notifies its own observer when the icon
|
| +// image changes.
|
| +class ExtensionActionIconFactory : public extensions::IconImage::Observer,
|
| + public ExtensionIconFactoryDelegate {
|
| + public:
|
| + class Observer {
|
| + public:
|
| + virtual ~Observer() {}
|
| + // Called when the underlying image changes.
|
| + virtual void OnIconUpdated() = 0;
|
| + };
|
| +
|
| + // Observer should outlive this.
|
| + ExtensionActionIconFactory(const extensions::Extension* extension,
|
| + Observer* observer);
|
| + virtual ~ExtensionActionIconFactory();
|
| +
|
| + // extensions::IconImage override.
|
| + virtual void OnExtensionIconImageChanged(
|
| + extensions::IconImage* image) OVERRIDE;
|
| +
|
| + // ExtensionIconFactoryDelegate override.
|
| + // Returns icon created using extensions::IconImage from |icon_set| with the
|
| + // desired size. If the previous requested icon had the same icon set, that
|
| + // icon is returned. Else, new IconImage is created.
|
| + // It is assumed that request with the same |icon_set| also have the same
|
| + // |desired_size|.
|
| + // The icon can be loaded asynchronously. In that case the observer will be
|
| + // notified when the icon gets updated.
|
| + virtual gfx::ImageSkia GetIcon(const ExtensionIconSet* icon_set,
|
| + int desired_size) OVERRIDE;
|
| +
|
| + private:
|
| + const extensions::Extension* extension_;
|
| + Observer* observer_;
|
| + const ExtensionIconSet* last_icon_set_;
|
| + int last_size_;
|
| + scoped_ptr<extensions::IconImage> icon_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(ExtensionActionIconFactory);
|
| +};
|
| +
|
| +#endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_ACTION_ICON_FACTORY_H_
|
|
|