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_JUMPLIST_WIN_H_ | 5 #ifndef CHROME_BROWSER_JUMPLIST_WIN_H_ |
6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ | 6 #define CHROME_BROWSER_JUMPLIST_WIN_H_ |
7 | 7 |
8 #include <list> | 8 #include <list> |
9 #include <string> | 9 #include <string> |
10 #include <utility> | 10 #include <utility> |
11 #include <vector> | 11 #include <vector> |
12 | 12 |
13 #include "base/memory/ref_counted.h" | 13 #include "base/memory/ref_counted.h" |
14 #include "base/synchronization/lock.h" | 14 #include "base/synchronization/lock.h" |
15 #include "chrome/browser/cancelable_request.h" | 15 #include "chrome/browser/cancelable_request.h" |
16 #include "chrome/browser/history/history.h" | 16 #include "chrome/browser/history/history.h" |
17 #include "chrome/browser/history/history_types.h" | 17 #include "chrome/browser/history/history_types.h" |
18 #include "chrome/browser/sessions/tab_restore_service.h" | 18 #include "chrome/browser/sessions/tab_restore_service.h" |
19 #include "chrome/browser/sessions/tab_restore_service_observer.h" | 19 #include "chrome/browser/sessions/tab_restore_service_observer.h" |
| 20 #include "third_party/skia/include/core/SkBitmap.h" |
20 | 21 |
21 namespace content { | 22 namespace content { |
22 class NotificationRegistrar; | 23 class NotificationRegistrar; |
23 } | 24 } |
24 class FilePath; | 25 class FilePath; |
25 class Profile; | 26 class Profile; |
26 class PageUsageData; | 27 class PageUsageData; |
27 | 28 |
28 // Represents a class used for creating an IShellLink object by the utility | 29 // Represents a class used for creating an IShellLink object by the utility |
29 // functions in this file. | 30 // functions in this file. |
(...skipping 14 matching lines...) Expand all Loading... |
44 // need it. | 45 // need it. |
45 class ShellLinkItem : public base::RefCountedThreadSafe<ShellLinkItem> { | 46 class ShellLinkItem : public base::RefCountedThreadSafe<ShellLinkItem> { |
46 public: | 47 public: |
47 ShellLinkItem() : index_(0), favicon_(false) { | 48 ShellLinkItem() : index_(0), favicon_(false) { |
48 } | 49 } |
49 | 50 |
50 const std::wstring& arguments() const { return arguments_; } | 51 const std::wstring& arguments() const { return arguments_; } |
51 const std::wstring& title() const { return title_; } | 52 const std::wstring& title() const { return title_; } |
52 const std::wstring& icon() const { return icon_; } | 53 const std::wstring& icon() const { return icon_; } |
53 int index() const { return index_; } | 54 int index() const { return index_; } |
54 scoped_refptr<base::RefCountedMemory> data() const { return data_; } | 55 const SkBitmap& data() const { return data_; } |
55 | 56 |
56 void SetArguments(const std::wstring& arguments) { | 57 void SetArguments(const std::wstring& arguments) { |
57 arguments_ = arguments; | 58 arguments_ = arguments; |
58 } | 59 } |
59 | 60 |
60 void SetTitle(const std::wstring& title) { | 61 void SetTitle(const std::wstring& title) { |
61 title_ = title; | 62 title_ = title; |
62 } | 63 } |
63 | 64 |
64 void SetIcon(const std::wstring& icon, int index, bool favicon) { | 65 void SetIcon(const std::wstring& icon, int index, bool favicon) { |
65 icon_ = icon; | 66 icon_ = icon; |
66 index_ = index; | 67 index_ = index; |
67 favicon_ = favicon; | 68 favicon_ = favicon; |
68 } | 69 } |
69 | 70 |
70 void SetIconData(scoped_refptr<base::RefCountedMemory> data) { | 71 void SetIconData(const SkBitmap& data) { |
71 data_ = data; | 72 data_ = data; |
72 } | 73 } |
73 | 74 |
74 private: | 75 private: |
75 friend class base::RefCountedThreadSafe<ShellLinkItem>; | 76 friend class base::RefCountedThreadSafe<ShellLinkItem>; |
76 | 77 |
77 ~ShellLinkItem() {} | 78 ~ShellLinkItem() {} |
78 | 79 |
79 std::wstring arguments_; | 80 std::wstring arguments_; |
80 std::wstring title_; | 81 std::wstring title_; |
81 std::wstring icon_; | 82 std::wstring icon_; |
82 scoped_refptr<base::RefCountedMemory> data_; | 83 SkBitmap data_; |
83 int index_; | 84 int index_; |
84 bool favicon_; | 85 bool favicon_; |
85 | 86 |
86 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); | 87 DISALLOW_COPY_AND_ASSIGN(ShellLinkItem); |
87 }; | 88 }; |
88 | 89 |
89 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; | 90 typedef std::vector<scoped_refptr<ShellLinkItem> > ShellLinkItemList; |
90 | 91 |
91 // A class which implements an application JumpList. | 92 // A class which implements an application JumpList. |
92 // This class encapsulates operations required for updating an application | 93 // This class encapsulates operations required for updating an application |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
169 // that retrieves a favicon for each URL in the list. | 170 // that retrieves a favicon for each URL in the list. |
170 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, | 171 void OnSegmentUsageAvailable(CancelableRequestProvider::Handle handle, |
171 std::vector<PageUsageData*>* data); | 172 std::vector<PageUsageData*>* data); |
172 | 173 |
173 // A callback function for HistoryService that notify when a requested favicon | 174 // A callback function for HistoryService that notify when a requested favicon |
174 // is available. | 175 // is available. |
175 // To avoid file operations, this function just attaches the given data to | 176 // To avoid file operations, this function just attaches the given data to |
176 // a ShellLinkItem object. | 177 // a ShellLinkItem object. |
177 // When finishing loading all favicons, this function posts a task that | 178 // When finishing loading all favicons, this function posts a task that |
178 // decompresses collected favicons and updates a JumpList. | 179 // decompresses collected favicons and updates a JumpList. |
179 void OnFaviconDataAvailable(HistoryService::Handle handle, | 180 void OnFaviconDataAvailable( |
180 history::FaviconData favicon); | 181 HistoryService::Handle handle, |
| 182 const history::FaviconImageResult& image_result); |
181 | 183 |
182 // Callback for TopSites that notifies when the "Most | 184 // Callback for TopSites that notifies when the "Most |
183 // Visited" list is available. This function updates the ShellLinkItemList | 185 // Visited" list is available. This function updates the ShellLinkItemList |
184 // objects and send another query that retrieves a favicon for each URL in | 186 // objects and send another query that retrieves a favicon for each URL in |
185 // the list. | 187 // the list. |
186 void OnMostVisitedURLsAvailable( | 188 void OnMostVisitedURLsAvailable( |
187 const history::MostVisitedURLList& data); | 189 const history::MostVisitedURLList& data); |
188 | 190 |
189 // Runnable method that updates the jumplist, once all the data | 191 // Runnable method that updates the jumplist, once all the data |
190 // has been fetched. | 192 // has been fetched. |
191 void RunUpdate(); | 193 void RunUpdate(); |
192 | 194 |
193 // Helper method for RunUpdate to decode the data about the asynchrounously | 195 // Helper method for RunUpdate to create icon files for the asynchrounously |
194 // loaded icons. | 196 // loaded icons. |
195 void DecodeIconData(const ShellLinkItemList& item_list); | 197 void CreateIconFiles(const ShellLinkItemList& item_list); |
196 | 198 |
197 private: | 199 private: |
198 friend class base::RefCountedThreadSafe<JumpList>; | 200 friend class base::RefCountedThreadSafe<JumpList>; |
199 ~JumpList(); | 201 ~JumpList(); |
200 | 202 |
201 // Our consumers for HistoryService. | 203 // Our consumers for HistoryService. |
202 CancelableRequestConsumer most_visited_consumer_; | 204 CancelableRequestConsumer most_visited_consumer_; |
203 CancelableRequestConsumer favicon_consumer_; | 205 CancelableRequestConsumer favicon_consumer_; |
204 CancelableRequestConsumer topsites_consumer_; | 206 CancelableRequestConsumer topsites_consumer_; |
205 | 207 |
(...skipping 25 matching lines...) Expand all Loading... |
231 // Handle of last favicon request used to cancel if a new request | 233 // Handle of last favicon request used to cancel if a new request |
232 // comes in before the current one returns. | 234 // comes in before the current one returns. |
233 FaviconService::Handle handle_; | 235 FaviconService::Handle handle_; |
234 | 236 |
235 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ | 237 // Lock for most_visited_pages_, recently_closed_pages_, icon_urls_ |
236 // as they may be used by up to 3 threads. | 238 // as they may be used by up to 3 threads. |
237 base::Lock list_lock_; | 239 base::Lock list_lock_; |
238 }; | 240 }; |
239 | 241 |
240 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ | 242 #endif // CHROME_BROWSER_JUMPLIST_WIN_H_ |
OLD | NEW |