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 | |
25 // This represents how an extension app icon should finally look. As a base, | |
26 // extension icon is used and effects that depend on extension type, state and | |
27 // some external conditions are applied. Resulting image is sent via | |
28 // ChromeAppIconDelegate. Several updates are expected in case extension | |
29 // state or some external conditions are changed. | |
30 class ChromeAppIcon : public IconImage::Observer { | |
msw
2017/05/08 19:59:53
I'd be very interested to see if all this refactor
khmel
2017/05/09 00:05:04
You might miss that but I already described reason
msw
2017/05/10 19:05:21
Having a single object to monitor extension change
khmel
2017/05/10 20:26:22
1. AppIconLoader is base class, we have ArcAppIcon
| |
31 public: | |
32 using DestroyedCallback = base::OnceCallback<void(ChromeAppIcon*)>; | |
33 | |
34 ChromeAppIcon(ChromeAppIconDelegate* delegate, | |
35 content::BrowserContext* browser_context, | |
36 DestroyedCallback destroyed_callback, | |
37 const std::string& app_id, | |
38 int resource_size_in_dip); | |
39 ~ChromeAppIcon() override; | |
40 | |
41 // Reloads icon. | |
42 void Reload(); | |
43 | |
44 // Returns true if icon is loaded and attached to valid extension. | |
45 bool IsValid() const; | |
46 | |
47 // Re-applies app effects over the current extension icon and dispatches the | |
48 // result via |delegate_|. | |
49 void UpdateIcon(); | |
50 | |
51 // Generates all images for supported scale factors. | |
52 void EnsureRepsForSupportedScales(); | |
msw
2017/05/08 19:59:53
It seems like this is only called in tests; if so
khmel
2017/05/09 00:05:04
Actually you are right. I thought that once we app
| |
53 | |
54 const gfx::ImageSkia& image_skia() const { return image_skia_; } | |
55 const std::string& app_id() const { return app_id_; } | |
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 browser_context_; | |
66 | |
67 // Called when this instance of ChromeAppIcon is destroyed. | |
68 DestroyedCallback destroyed_callback_; | |
69 | |
70 const std::string app_id_; | |
71 | |
72 // Contains current icon image. This is static image with applied effects and | |
73 // it is updated each time when |icon_| is updated. | |
74 gfx::ImageSkia image_skia_; | |
75 | |
76 const int resource_size_in_dip_; | |
77 | |
78 std::unique_ptr<IconImage> icon_; | |
79 | |
80 DISALLOW_COPY_AND_ASSIGN(ChromeAppIcon); | |
81 }; | |
82 | |
83 } // namespace extensions | |
84 | |
85 #endif // CHROME_BROWSER_EXTENSIONS_CHROME_APP_ICON_H_ | |
OLD | NEW |