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.cc

Issue 2778513002: Delete JumpListIconsOld and update revised links in every update (Closed)
Patch Set: Fix nits in histograms.xml Created 3 years, 9 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.
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
264 // jumplist.
265
266 DirectoryStatus dir_status = NON_EXIST;
266 if (base::DirectoryExists(icon_dir)) { 267 if (base::DirectoryExists(icon_dir)) {
grt (UTC plus 2) 2017/03/27 08:03:39 nit: omit braces for single-line conditional and b
chengx 2017/03/27 18:32:41 Done.
267 DirectoryEmptyStatus empty_status = 268 dir_status = base::IsDirectoryEmpty(icon_dir) ? EMPTY : NON_EMPTY;
268 ::PathIsDirectoryEmpty(icon_dir.value().c_str()) ? EMPTY : NON_EMPTY;
269 UMA_HISTOGRAM_ENUMERATION("WinJumplist.EmptyStatusJumpListIcons",
270 empty_status, EMPTY_STATUS_END);
271 if (empty_status == NON_EMPTY)
272 return;
273 } else if (!base::CreateDirectory(icon_dir)) {
274 return;
275 } 269 }
276 270
277 // Create temporary icon files for shortcuts in the "Most Visited" category. 271 if (dir_status == NON_EXIST && base::CreateDirectory(icon_dir)) {
grt (UTC plus 2) 2017/03/27 08:03:39 nit: omit braces
chengx 2017/03/27 18:32:41 Done.
278 CreateIconFiles(icon_dir, local_most_visited_pages); 272 dir_status = EMPTY;
273 }
279 274
280 // Create temporary icon files for shortcuts in the "Recently Closed" 275 if (dir_status == EMPTY) {
281 // category. 276 // Create temporary icon files for shortcuts in the "Most Visited" category.
282 CreateIconFiles(icon_dir, local_recently_closed_pages); 277 CreateIconFiles(icon_dir, local_most_visited_pages);
283 278
284 // We finished collecting all resources needed for updating an application 279 // Create temporary icon files for shortcuts in the "Recently Closed"
285 // JumpList. So, create a new JumpList and replace the current JumpList 280 // category.
286 // with it. 281 CreateIconFiles(icon_dir, local_recently_closed_pages);
287 UpdateJumpList(app_id.c_str(), local_most_visited_pages, 282
288 local_recently_closed_pages, incognito_availability); 283 // We finished collecting all resources needed for updating an application
284 // JumpList. So, create a new JumpList and replace the current JumpList
285 // with it.
286 UpdateJumpList(app_id.c_str(), local_most_visited_pages,
287 local_recently_closed_pages, incognito_availability);
288 }
grt (UTC plus 2) 2017/03/27 08:03:39 in the "else" case, the jumplist retains the old m
chengx 2017/03/27 18:32:41 Correct, in this case, the jumplist retains the ol
grt (UTC plus 2) 2017/03/27 19:18:47 how does the shell handle this -- is Chrome's icon
chengx 2017/03/27 20:26:08 In this case, Chrome's icon will be used. The ca
289 289
290 // Post a background task to delete JumpListIconsOld folder if it exists and 290 // Post a background task to delete JumpListIconsOld folder if it exists and
291 // log the delete results to UMA. 291 // log the delete results to UMA.
292 base::FilePath icon_dir_old = icon_dir.DirName().Append( 292 base::FilePath icon_dir_old = icon_dir.DirName().Append(
293 icon_dir.BaseName().value() + FILE_PATH_LITERAL("Old")); 293 icon_dir.BaseName().value() + FILE_PATH_LITERAL("Old"));
294 294
295 if (base::DirectoryExists(icon_dir_old)) { 295 if (base::DirectoryExists(icon_dir_old)) {
296 sequenced_task_runner->PostTask( 296 sequenced_task_runner->PostTask(
297 FROM_HERE, base::Bind(&DeleteDirectoryAndLogResults, icon_dir_old, 297 FROM_HERE, base::Bind(&DeleteDirectoryAndLogResults, icon_dir_old,
298 kFileDeleteLimit)); 298 kFileDeleteLimit));
(...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { 623 void JumpList::TopSitesLoaded(history::TopSites* top_sites) {
624 } 624 }
625 625
626 void JumpList::TopSitesChanged(history::TopSites* top_sites, 626 void JumpList::TopSitesChanged(history::TopSites* top_sites,
627 ChangeReason change_reason) { 627 ChangeReason change_reason) {
628 top_sites->GetMostVisitedURLs( 628 top_sites->GetMostVisitedURLs(
629 base::Bind(&JumpList::OnMostVisitedURLsAvailable, 629 base::Bind(&JumpList::OnMostVisitedURLsAvailable,
630 weak_ptr_factory_.GetWeakPtr()), 630 weak_ptr_factory_.GetWeakPtr()),
631 false); 631 false);
632 } 632 }
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