OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_APP_ICON_LOADER_IMPL_H_ | 5 #ifndef CHROME_BROWSER_EXTENSIONS_APP_ICON_LOADER_IMPL_H_ |
6 #define CHROME_BROWSER_EXTENSIONS_APP_ICON_LOADER_IMPL_H_ | 6 #define CHROME_BROWSER_EXTENSIONS_APP_ICON_LOADER_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "chrome/browser/extensions/app_icon_loader.h" | 11 #include "chrome/browser/extensions/app_icon_loader.h" |
12 #include "extensions/browser/extension_icon_image.h" | 12 #include "extensions/browser/extension_icon_image.h" |
13 | 13 |
14 class Profile; | 14 class Profile; |
15 | 15 |
16 namespace extensions { | 16 namespace extensions { |
17 class Extension; | 17 class Extension; |
18 | 18 |
19 // Default implementation of ash::AppIconLoader that interacts with the | 19 // Default implementation of ash::AppIconLoader that interacts with the |
20 // ExtensionService and ImageLoader to load images. | 20 // ExtensionService and ImageLoader to load images. |
21 class AppIconLoaderImpl : public AppIconLoader, | 21 class AppIconLoaderImpl : public AppIconLoader, |
22 public extensions::IconImage::Observer { | 22 public extensions::IconImage::Observer { |
23 public: | 23 public: |
24 AppIconLoaderImpl(Profile* profile, int icon_size, | 24 AppIconLoaderImpl(Profile* profile, int icon_size, |
25 AppIconLoader::Delegate* delegate); | 25 AppIconLoader::Delegate* delegate); |
26 virtual ~AppIconLoaderImpl(); | 26 ~AppIconLoaderImpl() override; |
27 | 27 |
28 // AppIconLoader overrides: | 28 // AppIconLoader overrides: |
29 virtual void FetchImage(const std::string& id) override; | 29 void FetchImage(const std::string& id) override; |
30 virtual void ClearImage(const std::string& id) override; | 30 void ClearImage(const std::string& id) override; |
31 virtual void UpdateImage(const std::string& id) override; | 31 void UpdateImage(const std::string& id) override; |
32 | 32 |
33 // extensions::IconImage::Observer overrides: | 33 // extensions::IconImage::Observer overrides: |
34 virtual void OnExtensionIconImageChanged( | 34 void OnExtensionIconImageChanged(extensions::IconImage* image) override; |
35 extensions::IconImage* image) override; | |
36 | 35 |
37 private: | 36 private: |
38 typedef std::map<extensions::IconImage*, std::string> ImageToExtensionIDMap; | 37 typedef std::map<extensions::IconImage*, std::string> ImageToExtensionIDMap; |
39 | 38 |
40 // Builds image for given |id| and |icon|. | 39 // Builds image for given |id| and |icon|. |
41 void BuildImage(const std::string& id, const gfx::ImageSkia& icon); | 40 void BuildImage(const std::string& id, const gfx::ImageSkia& icon); |
42 | 41 |
43 Profile* profile_; | 42 Profile* profile_; |
44 | 43 |
45 // The delegate object which receives the icon images. No ownership. | 44 // The delegate object which receives the icon images. No ownership. |
46 AppIconLoader::Delegate* delegate_; | 45 AppIconLoader::Delegate* delegate_; |
47 | 46 |
48 // Maps from IconImage pointer to the extension id. | 47 // Maps from IconImage pointer to the extension id. |
49 ImageToExtensionIDMap map_; | 48 ImageToExtensionIDMap map_; |
50 | 49 |
51 const int icon_size_; | 50 const int icon_size_; |
52 | 51 |
53 DISALLOW_COPY_AND_ASSIGN(AppIconLoaderImpl); | 52 DISALLOW_COPY_AND_ASSIGN(AppIconLoaderImpl); |
54 }; | 53 }; |
55 | 54 |
56 } // namespace extensions | 55 } // namespace extensions |
57 | 56 |
58 #endif // CHROME_BROWSER_EXTENSIONS_APP_ICON_LOADER_IMPL_H_ | 57 #endif // CHROME_BROWSER_EXTENSIONS_APP_ICON_LOADER_IMPL_H_ |
OLD | NEW |