Index: chrome/browser/extensions/chrome_app_icon.h |
diff --git a/chrome/browser/extensions/chrome_app_icon.h b/chrome/browser/extensions/chrome_app_icon.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..22093ff47122b0450d7257653f36ac6aa20bd27f |
--- /dev/null |
+++ b/chrome/browser/extensions/chrome_app_icon.h |
@@ -0,0 +1,83 @@ |
+// Copyright 2017 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_CHROME_APP_ICON_H_ |
+#define CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_H_ |
+ |
+#include <memory> |
+#include <string> |
+ |
+#include "base/callback.h" |
+#include "base/macros.h" |
+#include "extensions/browser/extension_icon_image.h" |
+#include "ui/gfx/image/image_skia.h" |
+ |
+namespace content { |
+class BrowserContext; |
+} |
+ |
+namespace extensions { |
+ |
+class Extension; |
+class ChromeAppIconDelegate; |
+class IconImage; |
msw
2017/05/03 01:17:38
nit: not needed; defined in extension_icon_image.h
khmel
2017/05/03 02:15:22
Done.
|
+ |
+// This represents how an extension app icon should finally look. As a base, |
+// extension icon is used and effects that depend on extension type, state and |
+// some external conditions are applied. Resulting image is sent via |
+// ChromeAppIconDelegate. Several updates are expected in case extension |
+// state or some external conditions are changed. |
+class ChromeAppIcon : public IconImage::Observer { |
msw
2017/05/03 01:17:38
If each ChromeAppIcon is owned by the transient UI
khmel
2017/05/03 02:15:22
Having cache is actually good idea. I have this id
msw
2017/05/08 19:59:53
Sorry, I don't think my comment was clear. I think
khmel
2017/05/09 00:05:04
Yes, this is correct. Service does not own icon. I
|
+ public: |
+ using DestroyedCallback = base::OnceCallback<void(ChromeAppIcon*)>; |
+ |
+ ChromeAppIcon(ChromeAppIconDelegate* delegate, |
+ content::BrowserContext* context, |
+ DestroyedCallback destroyed_callback, |
+ const std::string& app_id, |
+ int resource_size_in_dip); |
+ ~ChromeAppIcon() override; |
+ |
+ // Reloads icon. |
+ void Reload(); |
+ |
+ // Returns true if icon is loaded and attached to valid extension. |
msw
2017/05/03 01:17:38
What does it mean for the icon to be attached to a
khmel
2017/05/03 02:15:22
When extension is disabled, IconImage discards thi
msw
2017/05/08 19:59:53
So the icon becomes invalid? Please clarify the co
khmel
2017/05/09 00:05:04
In recent revision we creates icon_ at CTOR. That
|
+ bool IsValid() const; |
+ |
+ void UpdateIcon(); |
msw
2017/05/03 01:17:38
nit: comment; maybe allude to how UpdateIcon diffe
khmel
2017/05/03 02:15:21
Done.
|
+ |
+ // Generates all images for supported scale factors. |
+ void EnsureRepsForSupportedScales(); |
msw
2017/05/03 01:17:38
nit: remove this, let the one non-test caller (Chr
khmel
2017/05/03 02:15:22
image_skia() from this class is static image with
|
+ |
+ const gfx::ImageSkia& image_skia() const { return image_skia_; } |
+ const std::string& app_id() const { return app_id_; } |
+ content::BrowserContext* context() { return context_; } |
msw
2017/05/03 01:17:38
Remove this if it's not used anywhere, otherwise r
khmel
2017/05/03 02:15:22
Done.
|
+ |
+ private: |
+ const Extension* GetExtension(); |
+ |
+ // IconImage::Observer: |
+ void OnExtensionIconImageChanged(IconImage* image) override; |
+ |
+ // Unowned pointers. |
+ ChromeAppIconDelegate* const delegate_; |
+ content::BrowserContext* const context_; |
msw
2017/05/03 01:17:38
nit: browser_context_
khmel
2017/05/03 02:15:22
Done.
|
+ |
+ DestroyedCallback destroyed_callback_; |
msw
2017/05/03 01:17:38
nit: comment, describe when this is called (when t
khmel
2017/05/03 02:15:22
Somebody needs to clean the icon from icon_map_, r
msw
2017/05/08 19:59:53
I suppose that's fine. Holding weak pointers also
khmel
2017/05/09 00:05:04
Acknowledged.
|
+ |
+ const std::string app_id_; |
+ |
+ const int resource_size_in_dip_; |
msw
2017/05/03 01:17:38
Would it make sense to just expose the underlying
khmel
2017/05/03 02:15:22
resource_size_in_dip_ is actually used to create/r
|
+ |
+ // Contains current icon image. |
+ gfx::ImageSkia image_skia_; |
+ |
+ std::unique_ptr<IconImage> icon_; |
msw
2017/05/03 01:17:38
How does this IconImage |icon_|, which contains an
khmel
2017/05/03 02:15:22
Done in comment
|
+ |
+ DISALLOW_COPY_AND_ASSIGN(ChromeAppIcon); |
+}; |
+ |
+} // namespace extensions |
+ |
+#endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_H_ |