Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2017 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. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "extensions/browser/extension_icon_image.h" | |
| 14 #include "ui/gfx/image/image_skia.h" | |
| 15 | |
| 16 namespace content { | |
| 17 class BrowserContext; | |
| 18 } | |
| 19 | |
| 20 namespace extensions { | |
| 21 | |
| 22 class Extension; | |
| 23 class ExtensionAppIconDelegate; | |
| 24 class IconImage; | |
| 25 | |
| 26 // This represents how an extension icon should finally look. As a base, | |
| 27 // extension icon is used and effects that depend on extension type, state and | |
| 28 // some external conditions are applied. Resulting image is sent via | |
| 29 // ExtensionAppIconDelegate. Several updates are expected in case extension | |
| 30 // state or some external conditions are changed. | |
| 31 class ExtensionAppIcon : public extensions::IconImage::Observer { | |
| 32 public: | |
| 33 using Closure = base::Callback<void(ExtensionAppIcon*)>; | |
|
xiyuan
2017/04/20 17:52:46
nit: Closure -> CloseCallback (or DestroyCallback)
khmel
2017/04/20 18:01:11
Done.
| |
| 34 | |
| 35 ExtensionAppIcon(ExtensionAppIconDelegate* delegate, | |
| 36 content::BrowserContext* context, | |
| 37 Closure close_callback, | |
| 38 const std::string& app_id, | |
| 39 int resource_size_in_dip); | |
| 40 ~ExtensionAppIcon() override; | |
| 41 | |
| 42 void Reload(); | |
| 43 | |
| 44 // Returns true if icon is loaded and attached to valid extension. | |
| 45 bool IsValid() const; | |
| 46 | |
| 47 void UpdateIcon(); | |
| 48 | |
| 49 void EnsureRepsForSupportedScales(); | |
| 50 | |
| 51 const gfx::ImageSkia& image_skia() const { return image_skia_; } | |
| 52 const std::string& app_id() const { return app_id_; } | |
| 53 content::BrowserContext* context() { return context_; } | |
| 54 | |
| 55 private: | |
| 56 const extensions::Extension* GetExtension(); | |
| 57 | |
| 58 // extensions::IconImage::Observer: | |
| 59 void OnExtensionIconImageChanged(extensions::IconImage* image) override; | |
| 60 | |
| 61 // Unowned pointers. | |
| 62 ExtensionAppIconDelegate* const delegate_; | |
| 63 content::BrowserContext* const context_; | |
| 64 | |
| 65 Closure close_callback_; | |
| 66 | |
| 67 const std::string app_id_; | |
| 68 | |
| 69 const int resource_size_in_dip_; | |
| 70 | |
| 71 // Contains current icon image. | |
| 72 gfx::ImageSkia image_skia_; | |
| 73 | |
| 74 std::unique_ptr<extensions::IconImage> icon_; | |
| 75 | |
| 76 DISALLOW_COPY_AND_ASSIGN(ExtensionAppIcon); | |
| 77 }; | |
| 78 | |
| 79 } // namespace extensions | |
| 80 | |
| 81 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_ | |
| OLD | NEW |