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