Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(803)

Side by Side Diff: chrome/browser/extensions/extension_app_icon.h

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: Devlin's comments Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(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 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 // ExtensionAppIconDelegate. Several updates are expected in case extension
30 // state or some external conditions are changed.
31 class ExtensionAppIcon : public IconImage::Observer {
32 public:
33 using DestroyedCallback = base::OnceCallback<void(ExtensionAppIcon*)>;
34
35 ExtensionAppIcon(ExtensionAppIconDelegate* delegate,
36 content::BrowserContext* context,
37 DestroyedCallback destroyed_callback,
38 const std::string& app_id,
39 int resource_size_in_dip);
40 ~ExtensionAppIcon() override;
41
42 // Reloads icon.
43 void Reload();
44
45 // Returns true if icon is loaded and attached to valid extension.
46 bool IsValid() const;
47
48 void UpdateIcon();
49
50 // Generates all images for supported scale factors.
51 void EnsureRepsForSupportedScales();
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_; }
56
57 private:
58 const extensions::Extension* GetExtension();
59
60 // extensions::IconImage::Observer:
61 void OnExtensionIconImageChanged(extensions::IconImage* image) override;
62
63 // Unowned pointers.
64 ExtensionAppIconDelegate* const delegate_;
65 content::BrowserContext* const context_;
66
67 DestroyedCallback destroyed_callback_;
68
69 const std::string app_id_;
70
71 const int resource_size_in_dip_;
72
73 // Contains current icon image.
74 gfx::ImageSkia image_skia_;
75
76 std::unique_ptr<extensions::IconImage> icon_;
77
78 DISALLOW_COPY_AND_ASSIGN(ExtensionAppIcon);
79 };
80
81 } // namespace extensions
82
83 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698