OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
11 | 11 |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "chrome/browser/extensions/image_loading_tracker.h" | 13 #include "chrome/browser/extensions/image_loading_tracker.h" |
14 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" | 14 #include "chrome/browser/ui/views/ash/launcher/chrome_launcher_controller.h" |
15 | 15 |
| 16 class Profile; |
| 17 |
| 18 namespace extensions { |
16 class Extension; | 19 class Extension; |
17 class Profile; | 20 } |
| 21 |
18 | 22 |
19 // Default implementation of LauncherUpdater::AppIconLoader that interacts | 23 // Default implementation of LauncherUpdater::AppIconLoader that interacts |
20 // with the ExtensionService and ImageLoadingTracker to load images. | 24 // with the ExtensionService and ImageLoadingTracker to load images. |
21 class LauncherAppIconLoader : public ChromeLauncherController::AppIconLoader, | 25 class LauncherAppIconLoader : public ChromeLauncherController::AppIconLoader, |
22 public ImageLoadingTracker::Observer { | 26 public ImageLoadingTracker::Observer { |
23 public: | 27 public: |
24 LauncherAppIconLoader(Profile* profile, ChromeLauncherController* host); | 28 LauncherAppIconLoader(Profile* profile, ChromeLauncherController* host); |
25 virtual ~LauncherAppIconLoader(); | 29 virtual ~LauncherAppIconLoader(); |
26 | 30 |
27 // AppIconLoader: | 31 // AppIconLoader: |
28 virtual std::string GetAppID(TabContentsWrapper* tab) OVERRIDE; | 32 virtual std::string GetAppID(TabContentsWrapper* tab) OVERRIDE; |
29 virtual bool IsValidID(const std::string& id) OVERRIDE; | 33 virtual bool IsValidID(const std::string& id) OVERRIDE; |
30 virtual void FetchImage(const std::string& id) OVERRIDE; | 34 virtual void FetchImage(const std::string& id) OVERRIDE; |
31 | 35 |
32 // ImageLoadingTracker::Observer: | 36 // ImageLoadingTracker::Observer: |
33 virtual void OnImageLoaded(const gfx::Image& image, | 37 virtual void OnImageLoaded(const gfx::Image& image, |
34 const std::string& extension_id, | 38 const std::string& extension_id, |
35 int index) OVERRIDE; | 39 int index) OVERRIDE; |
36 | 40 |
37 private: | 41 private: |
38 typedef std::map<int, std::string> ImageLoaderIDToExtensionIDMap; | 42 typedef std::map<int, std::string> ImageLoaderIDToExtensionIDMap; |
39 | 43 |
40 // Returns the extension for the specified tab. | 44 // Returns the extension for the specified tab. |
41 const Extension* GetExtensionForTab(TabContentsWrapper* tab); | 45 const extensions::Extension* GetExtensionForTab(TabContentsWrapper* tab); |
42 | 46 |
43 // Returns the extension by ID. | 47 // Returns the extension by ID. |
44 const Extension* GetExtensionByID(const std::string& id); | 48 const extensions::Extension* GetExtensionByID(const std::string& id); |
45 | 49 |
46 Profile* profile_; | 50 Profile* profile_; |
47 | 51 |
48 // ChromeLauncherController we're associated with (and owned by). | 52 // ChromeLauncherController we're associated with (and owned by). |
49 ChromeLauncherController* host_; | 53 ChromeLauncherController* host_; |
50 | 54 |
51 // Used to load images. | 55 // Used to load images. |
52 scoped_ptr<ImageLoadingTracker> image_loader_; | 56 scoped_ptr<ImageLoadingTracker> image_loader_; |
53 | 57 |
54 // Maps from id from the ImageLoadingTracker to the extension id. | 58 // Maps from id from the ImageLoadingTracker to the extension id. |
55 ImageLoaderIDToExtensionIDMap map_; | 59 ImageLoaderIDToExtensionIDMap map_; |
56 | 60 |
57 DISALLOW_COPY_AND_ASSIGN(LauncherAppIconLoader); | 61 DISALLOW_COPY_AND_ASSIGN(LauncherAppIconLoader); |
58 }; | 62 }; |
59 | 63 |
60 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ | 64 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_APP_ICON_LOADER_H_ |
OLD | NEW |