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