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_VIEWS_ASH_LAUNCHER_LAUNCHER_FAVICON_LOADER_H_ | |
6 #define CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_FAVICON_LOADER_H_ | |
7 | |
8 #include <vector> | |
9 | |
10 #include "base/basictypes.h" | |
11 #include "base/callback.h" | |
12 #include "chrome/common/favicon_url.h" | |
13 #include "content/public/browser/web_contents_observer.h" | |
14 | |
15 class GURL; | |
16 class SkBitmap; | |
17 | |
18 namespace internal { | |
19 class FaviconBitmapHandler; | |
20 } | |
21 | |
22 // LauncherFaviconLoader handles updates to the list of favicon urls and | |
23 // retrieves the appropriately sized favicon for panels in the Launcher. | |
24 | |
25 class LauncherFaviconLoader : public content::WebContentsObserver { | |
26 public: | |
27 class Delegate { | |
28 public: | |
29 virtual void FaviconUpdated() = 0; | |
30 | |
31 protected: | |
32 virtual ~Delegate() {} | |
33 }; | |
34 | |
35 LauncherFaviconLoader(Delegate* delegate, | |
36 content::WebContents* web_contents); | |
37 virtual ~LauncherFaviconLoader(); | |
38 | |
39 // content::WebContentsObserver overrides. | |
40 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
41 | |
42 content::WebContents* web_contents() { | |
43 return content::WebContentsObserver::web_contents(); | |
44 } | |
45 | |
46 // Returns an appropriately sized favicon for the Launcher. If none are | |
47 // available will return an isNull bitmap. | |
48 SkBitmap GetFavicon() const; | |
49 | |
50 private: | |
51 // Message Handlers. | |
52 void OnUpdateFaviconURL(int32 page_id, | |
53 const std::vector<FaviconURL>& candidates); | |
54 | |
55 void OnDidDownloadFavicon(int id, | |
56 const GURL& image_url, | |
57 bool errored, | |
58 int requested_size, | |
59 const std::vector<SkBitmap>& bitmaps); | |
60 | |
61 scoped_ptr<internal::FaviconBitmapHandler> favicon_handler_; | |
62 | |
63 DISALLOW_COPY_AND_ASSIGN(LauncherFaviconLoader); | |
64 }; | |
65 | |
66 #endif // CHROME_BROWSER_UI_VIEWS_ASH_LAUNCHER_LAUNCHER_FAVICON_LOADER_H_ | |
OLD | NEW |