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_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 | |
15 namespace content { | |
16 class BrowserContext; | |
17 } | |
18 | |
19 namespace extensions { | |
20 | |
21 class Extension; | |
22 class ExtensionAppIconDelegate; | |
23 class ExtensionAppIconService; | |
24 class IconImage; | |
25 | |
26 class ExtensionAppIcon : public extensions::IconImage::Observer { | |
xiyuan
2017/04/18 20:43:00
Document the class
khmel
2017/04/20 00:13:37
Done.
| |
27 public: | |
28 ExtensionAppIcon(const base::WeakPtr<ExtensionAppIconService>& host, | |
29 ExtensionAppIconDelegate* delegate, | |
30 content::BrowserContext* context, | |
31 const std::string& app_id, | |
32 int resource_size_in_dip); | |
33 ~ExtensionAppIcon() override; | |
34 | |
35 void Reload(); | |
36 | |
37 // Returns true if icon is loaded and attached to valid extension. | |
38 bool IsValid() const; | |
39 | |
40 void UpdateIcon(); | |
41 | |
42 void EnsureRepsForSupportedScales(); | |
43 | |
44 const std::string& app_id() const { return app_id_; } | |
45 content::BrowserContext* context() { return context_; } | |
46 | |
47 private: | |
48 const extensions::Extension* GetExtension(); | |
49 | |
50 // extensions::IconImage::Observer: | |
51 void OnExtensionIconImageChanged(extensions::IconImage* image) override; | |
52 void OnExtensionIconImageDestroyed(extensions::IconImage* image) override; | |
53 | |
54 base::WeakPtr<ExtensionAppIconService> host_; | |
55 | |
56 // Unowned pointers. | |
57 ExtensionAppIconDelegate* const delegate_; | |
58 content::BrowserContext* const context_; | |
59 | |
60 const std::string app_id_; | |
61 | |
62 const int resource_size_in_dip_; | |
63 | |
64 std::unique_ptr<extensions::IconImage> icon_; | |
65 | |
66 DISALLOW_COPY_AND_ASSIGN(ExtensionAppIcon); | |
67 }; | |
68 | |
69 } // namespace extensions | |
70 | |
71 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_H_ | |
OLD | NEW |