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

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

Issue 2819413003: Refactor extension app icon. (Closed)
Patch Set: fixed tests on non-CrOS (use app_list deps only in CrOS) Created 3 years, 8 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/macros.h"
12 #include "base/memory/weak_ptr.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 ExtensionAppIconService;
25 class IconImage;
26
27 // This represents how an extension icon should finally look. As a base,
28 // extension icon is used and effects that depend on extension type, state and
29 // some external conditions are applied. Resulting image is sent via
30 // ExtensionAppIconDelegate. Several updates are expected in case extension
31 // state or some external conditions are changed.
32 class ExtensionAppIcon : public extensions::IconImage::Observer {
33 public:
34 ExtensionAppIcon(const base::WeakPtr<ExtensionAppIconService>& host,
35 ExtensionAppIconDelegate* delegate,
36 content::BrowserContext* context,
37 const std::string& app_id,
38 int resource_size_in_dip);
39 ~ExtensionAppIcon() override;
40
41 void Reload();
42
43 // Returns true if icon is loaded and attached to valid extension.
44 bool IsValid() const;
45
46 void UpdateIcon();
47
48 void EnsureRepsForSupportedScales();
49
50 const gfx::ImageSkia& image_skia() const { return image_skia_; }
51 const std::string& app_id() const { return app_id_; }
52 content::BrowserContext* context() { return context_; }
53
54 private:
55 const extensions::Extension* GetExtension();
56
57 // extensions::IconImage::Observer:
58 void OnExtensionIconImageChanged(extensions::IconImage* image) override;
59
60 base::WeakPtr<ExtensionAppIconService> host_;
61
62 // Unowned pointers.
63 ExtensionAppIconDelegate* const delegate_;
64 content::BrowserContext* const context_;
65
66 const std::string app_id_;
67
68 const int resource_size_in_dip_;
69
70 // Contains current icon image.
71 gfx::ImageSkia image_skia_;
72
73 std::unique_ptr<extensions::IconImage> icon_;
74
75 DISALLOW_COPY_AND_ASSIGN(ExtensionAppIcon);
76 };
77
78 } // namespace extensions
79
80 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698