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_WIN_JUMPLIST_H_ | 5 #ifndef CHROME_BROWSER_WIN_JUMPLIST_H_ |
6 #define CHROME_BROWSER_WIN_JUMPLIST_H_ | 6 #define CHROME_BROWSER_WIN_JUMPLIST_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 | 9 |
10 #include <list> | 10 #include <list> |
11 #include <string> | 11 #include <string> |
12 #include <utility> | 12 #include <utility> |
13 #include <vector> | 13 #include <vector> |
14 | 14 |
15 #include "base/files/file_path.h" | 15 #include "base/files/file_path.h" |
16 #include "base/macros.h" | 16 #include "base/macros.h" |
17 #include "base/memory/weak_ptr.h" | 17 #include "base/memory/weak_ptr.h" |
| 18 #include "base/strings/string16.h" |
18 #include "base/synchronization/lock.h" | 19 #include "base/synchronization/lock.h" |
19 #include "base/task/cancelable_task_tracker.h" | 20 #include "base/task/cancelable_task_tracker.h" |
20 #include "base/timer/timer.h" | 21 #include "base/timer/timer.h" |
21 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 22 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
22 #include "chrome/browser/win/jumplist_updater.h" | 23 #include "chrome/browser/win/jumplist_updater.h" |
23 #include "components/history/core/browser/history_service.h" | 24 #include "components/history/core/browser/history_service.h" |
24 #include "components/history/core/browser/history_types.h" | 25 #include "components/history/core/browser/history_types.h" |
25 #include "components/history/core/browser/top_sites_observer.h" | 26 #include "components/history/core/browser/top_sites_observer.h" |
26 #include "components/keyed_service/core/refcounted_keyed_service.h" | 27 #include "components/keyed_service/core/refcounted_keyed_service.h" |
27 #include "components/sessions/core/tab_restore_service.h" | 28 #include "components/sessions/core/tab_restore_service.h" |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 ChangeReason change_reason) override; | 171 ChangeReason change_reason) override; |
171 | 172 |
172 // Called on a timer to update the most visited URLs after requests storms | 173 // Called on a timer to update the most visited URLs after requests storms |
173 // have subsided. | 174 // have subsided. |
174 void DeferredTopSitesChanged(); | 175 void DeferredTopSitesChanged(); |
175 | 176 |
176 // Called on a timer to update the "Recently Closed" category of JumpList | 177 // Called on a timer to update the "Recently Closed" category of JumpList |
177 // after requests storms have subsided. | 178 // after requests storms have subsided. |
178 void DeferredTabRestoreServiceChanged(); | 179 void DeferredTabRestoreServiceChanged(); |
179 | 180 |
| 181 // Creates at most |max_items| icon files in |icon_dir| for the |
| 182 // asynchrounously loaded icons stored in |item_list|. |
| 183 void CreateIconFiles(const base::FilePath& icon_dir, |
| 184 const ShellLinkItemList& item_list, |
| 185 size_t max_items); |
| 186 |
| 187 // Updates icon files in |icon_dir|, which includes deleting old icons and |
| 188 // creating at most |slot_limit| new icons for |page_list|. |
| 189 void UpdateIconFiles(const base::FilePath& icon_dir, |
| 190 const ShellLinkItemList& page_list, |
| 191 size_t slot_limit); |
| 192 |
| 193 // Updates the jumplist, once all the data has been fetched. This method calls |
| 194 // UpdateJumpList() to do most of the work. |
| 195 void RunUpdateJumpList( |
| 196 IncognitoModePrefs::Availability incognito_availability, |
| 197 const base::string16& app_id, |
| 198 const base::FilePath& profile_dir, |
| 199 base::RefCountedData<JumpListData>* ref_counted_data); |
| 200 |
| 201 // Updates the application JumpList, which consists of 1) delete old icon |
| 202 // files; 2) create new icon files; 3) notify the OS. This method is called |
| 203 // from RunUpdateJumpList(). |
| 204 // Note that any timeout error along the way results in the old jumplist being |
| 205 // left as-is, while any non-timeout error results in the old jumplist being |
| 206 // left as-is, but without icon files. |
| 207 bool UpdateJumpList(const base::string16& app_id, |
| 208 const base::FilePath& profile_dir, |
| 209 const ShellLinkItemList& most_visited_pages, |
| 210 const ShellLinkItemList& recently_closed_pages, |
| 211 bool most_visited_pages_have_updates, |
| 212 bool recently_closed_pages_have_updates, |
| 213 IncognitoModePrefs::Availability incognito_availability); |
| 214 |
180 // Tracks FaviconService tasks. | 215 // Tracks FaviconService tasks. |
181 base::CancelableTaskTracker cancelable_task_tracker_; | 216 base::CancelableTaskTracker cancelable_task_tracker_; |
182 | 217 |
183 // The Profile object is used to listen for events | 218 // The Profile object is used to listen for events |
184 Profile* profile_; | 219 Profile* profile_; |
185 | 220 |
186 // Lives on the UI thread. | 221 // Lives on the UI thread. |
187 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; | 222 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; |
188 | 223 |
189 // App id to associate with the jump list. | 224 // App id to associate with the jump list. |
190 std::wstring app_id_; | 225 base::string16 app_id_; |
191 | 226 |
192 // Timer for requesting delayed updates of the "Most Visited" category of | 227 // Timer for requesting delayed updates of the "Most Visited" category of |
193 // jumplist. | 228 // jumplist. |
194 base::OneShotTimer timer_most_visited_; | 229 base::OneShotTimer timer_most_visited_; |
195 | 230 |
196 // Timer for requesting delayed updates of the "Recently Closed" category of | 231 // Timer for requesting delayed updates of the "Recently Closed" category of |
197 // jumplist. | 232 // jumplist. |
198 base::OneShotTimer timer_recently_closed_; | 233 base::OneShotTimer timer_recently_closed_; |
199 | 234 |
200 // Holds data that can be accessed from multiple threads. | 235 // Holds data that can be accessed from multiple threads. |
(...skipping 10 matching lines...) Expand all Loading... |
211 // JumpListIconsOld directory. | 246 // JumpListIconsOld directory. |
212 scoped_refptr<base::SequencedTaskRunner> delete_jumplisticons_task_runner_; | 247 scoped_refptr<base::SequencedTaskRunner> delete_jumplisticons_task_runner_; |
213 | 248 |
214 // For callbacks may be run after destruction. | 249 // For callbacks may be run after destruction. |
215 base::WeakPtrFactory<JumpList> weak_ptr_factory_; | 250 base::WeakPtrFactory<JumpList> weak_ptr_factory_; |
216 | 251 |
217 DISALLOW_COPY_AND_ASSIGN(JumpList); | 252 DISALLOW_COPY_AND_ASSIGN(JumpList); |
218 }; | 253 }; |
219 | 254 |
220 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_ | 255 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_ |
OLD | NEW |