Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(159)

Side by Side Diff: chrome/browser/win/jumplist.h

Issue 2941323002: Delete the right JumpList icons conditional on shell notification (Closed)
Patch Set: A much easier way of doing this, address comments Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/browser/win/jumplist.cc » ('j') | chrome/browser/win/jumplist.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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>
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
64 // Returns true if the custom JumpList is enabled. 64 // Returns true if the custom JumpList is enabled.
65 static bool Enabled(); 65 static bool Enabled();
66 66
67 // KeyedService: 67 // KeyedService:
68 void Shutdown() override; 68 void Shutdown() override;
69 69
70 private: 70 private:
71 using UrlAndLinkItem = std::pair<std::string, scoped_refptr<ShellLinkItem>>; 71 using UrlAndLinkItem = std::pair<std::string, scoped_refptr<ShellLinkItem>>;
72 using URLIconCache = base::flat_map<std::string, base::FilePath>; 72 using URLIconCache = base::flat_map<std::string, base::FilePath>;
73 73
74 // Holds results of the RunUpdateJumpList run. 74 // Holds results of a RunUpdateJumpList run.
75 struct UpdateResults { 75 // In-out params:
76 UpdateResults(); 76 // |most_visited_icons|, |recently_closed_icons|
77 ~UpdateResults(); 77 // Out params:
78 // |update_success|, |update_timeout|
79 struct UpdateTransaction {
80 UpdateTransaction();
81 ~UpdateTransaction();
78 82
79 // Icon file paths of the most visited links, indexed by tab url. 83 // Icon file paths of the most visited links, indexed by tab url.
80 // Holding a copy of most_visited_icons_ initially, it's updated by the 84 // Holding a copy of most_visited_icons_ initially, it's updated by the
81 // JumpList update run. If the update run succeeds, it overwrites 85 // JumpList update run. If the update run succeeds, it overwrites
82 // most_visited_icons_. 86 // most_visited_icons_.
83 URLIconCache most_visited_icons_in_update; 87 URLIconCache most_visited_icons;
84 88
85 // icon file paths of the recently closed links, indexed by tab url. 89 // Icon file paths of the recently closed links, indexed by tab url.
86 // Holding a copy of recently_closed_icons_ initially, it's updated by the 90 // Holding a copy of recently_closed_icons_ initially, it's updated by the
87 // JumpList update run. If the update run succeeds, it overwrites 91 // JumpList update run. If the update run succeeds, it overwrites
88 // recently_closed_icons_. 92 // recently_closed_icons_.
89 URLIconCache recently_closed_icons_in_update; 93 URLIconCache recently_closed_icons;
90 94
91 // A flag indicating if a JumpList update run is successful. 95 // A flag indicating if a JumpList update run is successful.
92 bool update_success = false; 96 bool update_success = false;
93 97
94 // A flag indicating if there is a timeout in notifying the JumpList update 98 // A flag indicating if there is a timeout in notifying the JumpList update
95 // to shell. Note that this variable is independent of update_success. 99 // to shell. Note that this variable is independent of update_success.
96 bool update_timeout = false; 100 bool update_timeout = false;
97 }; 101 };
98 102
99 friend JumpListFactory; 103 friend JumpListFactory;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 // |image_result| to a ShellLinkItem object. 160 // |image_result| to a ShellLinkItem object.
157 void OnFaviconDataAvailable( 161 void OnFaviconDataAvailable(
158 const favicon_base::FaviconImageResult& image_result); 162 const favicon_base::FaviconImageResult& image_result);
159 163
160 // Posts tasks to update the JumpList and delete any obsolete JumpList related 164 // Posts tasks to update the JumpList and delete any obsolete JumpList related
161 // folders. 165 // folders.
162 void PostRunUpdate(); 166 void PostRunUpdate();
163 167
164 // Callback for RunUpdateJumpList that notifies when it finishes running. 168 // Callback for RunUpdateJumpList that notifies when it finishes running.
165 // Updates certain JumpList member variables and/or triggers a new JumpList 169 // Updates certain JumpList member variables and/or triggers a new JumpList
166 // update based on |update_results|. 170 // update based on |update_results|, the flags |most_visited_should_update|
grt (UTC plus 2) 2017/06/23 09:36:14 nit: update_results -> update_transaction througho
chengx 2017/06/23 18:52:38 Done.
167 void OnRunUpdateCompletion(std::unique_ptr<UpdateResults> update_results); 171 // and |recently_closed_should_update|.
172 void OnRunUpdateCompletion(std::unique_ptr<UpdateTransaction> update_results,
173 bool most_visited_should_update,
174 bool recently_closed_should_update);
168 175
169 // Cancels a pending JumpList update. 176 // Cancels a pending JumpList update.
170 void CancelPendingUpdate(); 177 void CancelPendingUpdate();
171 178
172 // Terminates the JumpList, which includes cancelling any pending updates and 179 // Terminates the JumpList, which includes cancelling any pending updates and
173 // stopping observing the Profile and its services. This must be called before 180 // stopping observing the Profile and its services. This must be called before
174 // the |profile_| is destroyed. 181 // the |profile_| is destroyed.
175 void Terminate(); 182 void Terminate();
176 183
177 // Updates the application JumpList, which consists of 1) create new icon 184 // Updates the application JumpList, which consists of 1) create a new
178 // files; 2) delete obsolete icon files; 3) notify the OS. 185 // JumpList along with any icons that are not in the cache; 2) notify OS; 3)
179 // Note that any timeout error along the way results in the old JumpList being 186 // delete obsolete icon files. Any error along the way results in the old
180 // left as-is, while any non-timeout error results in the old JumpList being 187 // JumpList being left as-is.
181 // left as-is, but without icon files.
182 static void RunUpdateJumpList( 188 static void RunUpdateJumpList(
183 const base::string16& app_id, 189 const base::string16& app_id,
184 const base::FilePath& profile_dir, 190 const base::FilePath& profile_dir,
185 const ShellLinkItemList& most_visited_pages, 191 const ShellLinkItemList& most_visited_pages,
186 const ShellLinkItemList& recently_closed_pages, 192 const ShellLinkItemList& recently_closed_pages,
187 bool most_visited_pages_have_updates, 193 bool most_visited_should_update,
188 bool recently_closed_pages_have_updates, 194 bool recently_closed_should_update,
189 IncognitoModePrefs::Availability incognito_availability, 195 IncognitoModePrefs::Availability incognito_availability,
190 UpdateResults* update_results); 196 UpdateTransaction* update_results);
197
198 // Creates a new JumpList along with any icons that are not in the cache,
199 // and notifies OS.
grt (UTC plus 2) 2017/06/23 09:36:14 nit: "the OS."
chengx 2017/06/23 18:52:38 Done.
200 static void CreateNewJumpListAndNotifyOS(
201 const base::string16& app_id,
202 const base::FilePath& most_visited_icon_dir,
203 const base::FilePath& recently_closed_icon_dir,
204 const ShellLinkItemList& most_visited_pages,
205 const ShellLinkItemList& recently_closed_pages,
206 bool most_visited_should_update,
207 bool recently_closed_should_update,
208 IncognitoModePrefs::Availability incognito_availability,
209 UpdateTransaction* update_results);
191 210
192 // Updates icon files for |page_list| in |icon_dir|, which consists of 211 // Updates icon files for |page_list| in |icon_dir|, which consists of
193 // 1) creating at most |slot_limit| new icons which are not in |icon_cache|; 212 // 1) If certain safe conditions are not met, clean the folder at |icon_dir|.
194 // 2) deleting old icons which are not in |icon_cache|. 213 // If folder cleaning fails, skip step 2. Besides, clear |icon_cur| and
195 // Returns the number of new icon files created. 214 // |icon_next|.
215 // 2) Create at most |max_items| icon files which are not in |icon_cur| for
216 // the asynchrounously loaded icons stored in |item_list|.
196 static int UpdateIconFiles(const base::FilePath& icon_dir, 217 static int UpdateIconFiles(const base::FilePath& icon_dir,
197 const ShellLinkItemList& page_list, 218 const ShellLinkItemList& page_list,
198 size_t slot_limit, 219 size_t slot_limit,
199 URLIconCache* icon_cache); 220 URLIconCache* icon_cur,
221 URLIconCache* icon_next);
200 222
201 // In |icon_dir|, creates at most |max_items| icon files which are not in 223 // In |icon_dir|, creates at most |max_items| icon files which are not in
202 // |icon_cache| for the asynchrounously loaded icons stored in |item_list|. 224 // |icon_cur| for the asynchrounously loaded icons stored in |item_list|.
203 // |icon_cache| is also updated for newly created icons. 225 // |icon_next| are updated based on the reusable icons in |icon_cur| and the
204 // Returns the number of new icon files created. 226 // newly created icons. Returns the number of new icon files created.
205 static int CreateIconFiles(const base::FilePath& icon_dir, 227 static int CreateIconFiles(const base::FilePath& icon_dir,
206 const ShellLinkItemList& item_list, 228 const ShellLinkItemList& item_list,
207 size_t max_items, 229 size_t max_items,
208 URLIconCache* icon_cache); 230 URLIconCache* icon_cur,
231 URLIconCache* icon_next);
209 232
210 // Deletes icon files in |icon_dir| which are not in |icon_cache| anymore. 233 // Deletes icon files in |icon_dir| which are not in |icon_cache|.
211 static void DeleteIconFiles(const base::FilePath& icon_dir, 234 static void DeleteIconFiles(const base::FilePath& icon_dir,
212 URLIconCache* icon_cache); 235 const URLIconCache& icons_cache);
213 236
214 // Tracks FaviconService tasks. 237 // Tracks FaviconService tasks.
215 base::CancelableTaskTracker cancelable_task_tracker_; 238 base::CancelableTaskTracker cancelable_task_tracker_;
216 239
217 // The Profile object is used to listen for events. 240 // The Profile object is used to listen for events.
218 Profile* profile_; 241 Profile* profile_;
219 242
220 // Manages the registration of pref change observers. 243 // Manages the registration of pref change observers.
221 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_; 244 std::unique_ptr<PrefChangeRegistrar> pref_change_registrar_;
222 245
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 301
279 SEQUENCE_CHECKER(sequence_checker_); 302 SEQUENCE_CHECKER(sequence_checker_);
280 303
281 // For callbacks may run after destruction. 304 // For callbacks may run after destruction.
282 base::WeakPtrFactory<JumpList> weak_ptr_factory_; 305 base::WeakPtrFactory<JumpList> weak_ptr_factory_;
283 306
284 DISALLOW_COPY_AND_ASSIGN(JumpList); 307 DISALLOW_COPY_AND_ASSIGN(JumpList);
285 }; 308 };
286 309
287 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_ 310 #endif // CHROME_BROWSER_WIN_JUMPLIST_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/win/jumplist.cc » ('j') | chrome/browser/win/jumplist.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698