OLD | NEW |
| (Empty) |
1 // Copyright 2016 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_LOADER_H_ | |
6 #define CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_LOADER_H_ | |
7 | |
8 #include <map> | |
9 #include <memory> | |
10 #include <string> | |
11 | |
12 #include "base/macros.h" | |
13 #include "chrome/browser/ui/app_icon_loader.h" | |
14 #include "extensions/browser/extension_icon_image.h" | |
15 | |
16 class Profile; | |
17 | |
18 namespace extensions { | |
19 | |
20 // Implementation of AppIconLoader that interacts with the ExtensionService and | |
21 // ImageLoader to load images. | |
22 class ExtensionAppIconLoader : public AppIconLoader, | |
23 public extensions::IconImage::Observer { | |
24 public: | |
25 ExtensionAppIconLoader(Profile* profile, int icon_size, | |
26 AppIconLoaderDelegate* delegate); | |
27 ~ExtensionAppIconLoader() override; | |
28 | |
29 // AppIconLoader overrides: | |
30 bool CanLoadImageForApp(const std::string& id) override; | |
31 void FetchImage(const std::string& id) override; | |
32 void ClearImage(const std::string& id) override; | |
33 void UpdateImage(const std::string& id) override; | |
34 | |
35 // extensions::IconImage::Observer overrides: | |
36 void OnExtensionIconImageChanged(extensions::IconImage* image) override; | |
37 | |
38 private: | |
39 using ExtensionIDToImageMap = | |
40 std::map<std::string, std::unique_ptr<extensions::IconImage>>; | |
41 | |
42 // Builds image for given |id| and |icon|. | |
43 void BuildImage(const std::string& id, const gfx::ImageSkia& icon); | |
44 | |
45 // Maps from extension id to IconImage pointer. | |
46 ExtensionIDToImageMap map_; | |
47 | |
48 DISALLOW_COPY_AND_ASSIGN(ExtensionAppIconLoader); | |
49 }; | |
50 | |
51 } // namespace extensions | |
52 | |
53 #endif // CHROME_BROWSER_EXTENSIONS_EXTENSION_APP_ICON_LOADER_H_ | |
OLD | NEW |