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_CHROME_APP_ICON_H_ | |
| 6 #define CHROME_BROWSER_EXTENSIONS_CHROME_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 ChromeAppIconDelegate; | |
| 24 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.
| |
| 25 | |
| 26 // This represents how an extension app 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 // ChromeAppIconDelegate. Several updates are expected in case extension | |
| 30 // state or some external conditions are changed. | |
| 31 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
| |
| 32 public: | |
| 33 using DestroyedCallback = base::OnceCallback<void(ChromeAppIcon*)>; | |
| 34 | |
| 35 ChromeAppIcon(ChromeAppIconDelegate* delegate, | |
| 36 content::BrowserContext* context, | |
| 37 DestroyedCallback destroyed_callback, | |
| 38 const std::string& app_id, | |
| 39 int resource_size_in_dip); | |
| 40 ~ChromeAppIcon() override; | |
| 41 | |
| 42 // Reloads icon. | |
| 43 void Reload(); | |
| 44 | |
| 45 // 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
| |
| 46 bool IsValid() const; | |
| 47 | |
| 48 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.
| |
| 49 | |
| 50 // Generates all images for supported scale factors. | |
| 51 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
| |
| 52 | |
| 53 const gfx::ImageSkia& image_skia() const { return image_skia_; } | |
| 54 const std::string& app_id() const { return app_id_; } | |
| 55 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.
| |
| 56 | |
| 57 private: | |
| 58 const Extension* GetExtension(); | |
| 59 | |
| 60 // IconImage::Observer: | |
| 61 void OnExtensionIconImageChanged(IconImage* image) override; | |
| 62 | |
| 63 // Unowned pointers. | |
| 64 ChromeAppIconDelegate* const delegate_; | |
| 65 content::BrowserContext* const context_; | |
|
msw
2017/05/03 01:17:38
nit: browser_context_
khmel
2017/05/03 02:15:22
Done.
| |
| 66 | |
| 67 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.
| |
| 68 | |
| 69 const std::string app_id_; | |
| 70 | |
| 71 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
| |
| 72 | |
| 73 // Contains current icon image. | |
| 74 gfx::ImageSkia image_skia_; | |
| 75 | |
| 76 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
| |
| 77 | |
| 78 DISALLOW_COPY_AND_ASSIGN(ChromeAppIcon); | |
| 79 }; | |
| 80 | |
| 81 } // namespace extensions | |
| 82 | |
| 83 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_H_ | |
| OLD | NEW |