OLD | NEW |
| (Empty) |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_ | |
6 #define CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_ | |
7 | |
8 #include "base/memory/weak_ptr.h" | |
9 #include "chrome/browser/favicon/favicon_service.h" | |
10 #include "chrome/common/cancelable_task_tracker.h" | |
11 | |
12 class Profile; | |
13 class WebIntentPickerModel; | |
14 | |
15 namespace net { | |
16 class URLFetcher; | |
17 } | |
18 | |
19 namespace web_intents { | |
20 | |
21 class IconLoader { | |
22 public: | |
23 IconLoader(Profile* profile, WebIntentPickerModel* model); | |
24 ~IconLoader(); | |
25 | |
26 // Load the favicon associated with |url|. | |
27 void LoadFavicon(const GURL& url); | |
28 | |
29 // Load an extension icon | |
30 void LoadExtensionIcon(const GURL& url, const std::string& extension_id); | |
31 | |
32 private: | |
33 // Called when a favicon is returned from the FaviconService. | |
34 void OnFaviconDataAvailable(const GURL& url, | |
35 const history::FaviconImageResult& image_result); | |
36 | |
37 // Called when a suggested extension's icon is fetched. | |
38 void OnExtensionIconURLFetchComplete(const std::string& extension_id, | |
39 const net::URLFetcher* source); | |
40 | |
41 // Called when an extension's icon is successfully decoded and resized. | |
42 void OnExtensionIconAvailable(const std::string& extension_id, | |
43 const gfx::Image& icon_image); | |
44 | |
45 // A weak pointer to the profile for the web contents. | |
46 Profile* profile_; | |
47 | |
48 // A weak pointer to the model being updated. | |
49 WebIntentPickerModel* model_; | |
50 | |
51 // Used to asynchronously load favicons. | |
52 CancelableTaskTracker cancelable_task_tracker_; | |
53 | |
54 // Factory for weak pointers used in callbacks for async calls to load icon. | |
55 base::WeakPtrFactory<IconLoader> weak_ptr_factory_; | |
56 | |
57 DISALLOW_COPY_AND_ASSIGN(IconLoader); | |
58 }; | |
59 | |
60 } // namespace web_intents; | |
61 | |
62 #endif // CHROME_BROWSER_UI_INTENTS_WEB_INTENT_ICON_LOADER_H_ | |
OLD | NEW |