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

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

Issue 2778513002: Delete JumpListIconsOld and update revised links in every update (Closed)
Patch Set: Update jumplist links anyway Created 3 years, 8 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
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/win/jumplist.h" 5 #include "chrome/browser/win/jumplist.h"
6 6
7 #include <Shlwapi.h>
8
9 #include "base/bind.h" 7 #include "base/bind.h"
10 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
11 #include "base/command_line.h" 9 #include "base/command_line.h"
12 #include "base/files/file_util.h" 10 #include "base/files/file_util.h"
13 #include "base/macros.h" 11 #include "base/macros.h"
14 #include "base/metrics/histogram_macros.h" 12 #include "base/metrics/histogram_macros.h"
15 #include "base/path_service.h" 13 #include "base/path_service.h"
16 #include "base/sequenced_task_runner.h" 14 #include "base/sequenced_task_runner.h"
17 #include "base/strings/string_util.h" 15 #include "base/strings/string_util.h"
18 #include "base/strings/utf_string_conversions.h" 16 #include "base/strings/utf_string_conversions.h"
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 } 251 }
254 252
255 // Delete the contents in JumpListIcons directory and log the delete status 253 // Delete the contents in JumpListIcons directory and log the delete status
256 // to UMA. 254 // to UMA.
257 FolderDeleteResult delete_status = 255 FolderDeleteResult delete_status =
258 DeleteDirectoryContent(icon_dir, kFileDeleteLimit); 256 DeleteDirectoryContent(icon_dir, kFileDeleteLimit);
259 257
260 UMA_HISTOGRAM_ENUMERATION("WinJumplist.DeleteStatusJumpListIcons", 258 UMA_HISTOGRAM_ENUMERATION("WinJumplist.DeleteStatusJumpListIcons",
261 delete_status, END); 259 delete_status, END);
262 260
263 // If JumpListIcons directory is not empty, skip jumplist update and return 261 // If JumpListIcons directory is not empty, skip updating the jumplist icons.
264 // early. If the directory doesn't exist which shouldn't though, try to create 262 // If the directory doesn't exist which shouldn't though, try to create
265 // a new JumpListIcons directory. If the creation fails, return early. 263 // a new JumpListIcons directory. If the creation fails, skip updating the
266 if (base::DirectoryExists(icon_dir)) { 264 // jumplist icons. The jumplist links should be updated anyway, as it doesn't
267 DirectoryEmptyStatus empty_status = 265 // involve disk IO.
268 ::PathIsDirectoryEmpty(icon_dir.value().c_str()) ? EMPTY : NON_EMPTY; 266
269 UMA_HISTOGRAM_ENUMERATION("WinJumplist.EmptyStatusJumpListIcons", 267 DirectoryStatus dir_status = NON_EXIST;
270 empty_status, EMPTY_STATUS_END); 268 if (base::DirectoryExists(icon_dir))
271 if (empty_status == NON_EMPTY) 269 dir_status = base::IsDirectoryEmpty(icon_dir) ? EMPTY : NON_EMPTY;
272 return; 270
273 } else if (!base::CreateDirectory(icon_dir)) { 271 if (dir_status == NON_EXIST && base::CreateDirectory(icon_dir))
274 return; 272 dir_status = EMPTY;
273
grt (UTC plus 2) 2017/03/27 19:18:47 UMA WinJumplist.DirectoryStatusJumpListIcons here?
chengx 2017/03/27 20:26:08 Ah, my bad. Now it is back.
274 if (dir_status == EMPTY) {
275 // Create temporary icon files for shortcuts in the "Most Visited" category.
grt (UTC plus 2) 2017/03/27 19:18:47 the files aren't really temporary, are they? their
chengx 2017/03/27 20:26:08 Those are old comments existed for a very long tim
276 CreateIconFiles(icon_dir, local_most_visited_pages);
277
278 // Create temporary icon files for shortcuts in the "Recently Closed"
279 // category.
280 CreateIconFiles(icon_dir, local_recently_closed_pages);
275 } 281 }
276 282
277 // Create temporary icon files for shortcuts in the "Most Visited" category. 283 // Create a new JumpList and replace the current JumpList with it. The
278 CreateIconFiles(icon_dir, local_most_visited_pages); 284 // jumplist links are updated anyway, while the jumplist icons may not as
279 285 // mentioned above.
280 // Create temporary icon files for shortcuts in the "Recently Closed"
281 // category.
282 CreateIconFiles(icon_dir, local_recently_closed_pages);
283
284 // We finished collecting all resources needed for updating an application
285 // JumpList. So, create a new JumpList and replace the current JumpList
286 // with it.
287 UpdateJumpList(app_id.c_str(), local_most_visited_pages, 286 UpdateJumpList(app_id.c_str(), local_most_visited_pages,
288 local_recently_closed_pages, incognito_availability); 287 local_recently_closed_pages, incognito_availability);
289 288
290 // Post a background task to delete JumpListIconsOld folder if it exists and 289 // Post a background task to delete JumpListIconsOld folder if it exists and
291 // log the delete results to UMA. 290 // log the delete results to UMA.
292 base::FilePath icon_dir_old = icon_dir.DirName().Append( 291 base::FilePath icon_dir_old = icon_dir.DirName().Append(
293 icon_dir.BaseName().value() + FILE_PATH_LITERAL("Old")); 292 icon_dir.BaseName().value() + FILE_PATH_LITERAL("Old"));
294 293
295 if (base::DirectoryExists(icon_dir_old)) { 294 if (base::DirectoryExists(icon_dir_old)) {
296 sequenced_task_runner->PostTask( 295 sequenced_task_runner->PostTask(
(...skipping 326 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 622 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
624 } 623 }
625 624
626 void JumpList::TopSitesChanged(history::TopSites* top_sites, 625 void JumpList::TopSitesChanged(history::TopSites* top_sites,
627 ChangeReason change_reason) { 626 ChangeReason change_reason) {
628 top_sites->GetMostVisitedURLs( 627 top_sites->GetMostVisitedURLs(
629 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 628 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
630 weak_ptr_factory_.GetWeakPtr()), 629 weak_ptr_factory_.GetWeakPtr()),
631 false); 630 false);
632 } 631 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/win/jumplist_file_util.h » ('j') | chrome/browser/win/jumplist_file_util.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698