Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/bind_helpers.h" | 10 #include "base/bind_helpers.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 // Add this icon file to the list and return its absolute path. | 114 // Add this icon file to the list and return its absolute path. |
| 115 // The IShellLink::SetIcon() function needs the absolute path to an icon. | 115 // The IShellLink::SetIcon() function needs the absolute path to an icon. |
| 116 *icon_path = path; | 116 *icon_path = path; |
| 117 return true; | 117 return true; |
| 118 } | 118 } |
| 119 | 119 |
| 120 // Helper method for RunUpdate to create icon files for the asynchrounously | 120 // Helper method for RunUpdate to create icon files for the asynchrounously |
| 121 // loaded icons. | 121 // loaded icons. |
| 122 void CreateIconFiles(const base::FilePath& icon_dir, | 122 void CreateIconFiles(const base::FilePath& icon_dir, |
| 123 const ShellLinkItemList& item_list) { | 123 const ShellLinkItemList& item_list) { |
| 124 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.CreateIconFilesDuration"); | |
|
gab
2017/04/13 15:14:22
Add
// TODO(chengx): Remove after settling http:/
chengx
2017/04/13 19:21:52
Done.
| |
| 124 for (ShellLinkItemList::const_iterator item = item_list.begin(); | 125 for (ShellLinkItemList::const_iterator item = item_list.begin(); |
| 125 item != item_list.end(); ++item) { | 126 item != item_list.end(); ++item) { |
| 126 base::FilePath icon_path; | 127 base::FilePath icon_path; |
| 127 if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path)) | 128 if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path)) |
| 128 (*item)->set_icon(icon_path.value(), 0); | 129 (*item)->set_icon(icon_path.value(), 0); |
| 129 } | 130 } |
| 130 } | 131 } |
| 131 | 132 |
| 132 // Updates the "Tasks" category of the JumpList. | 133 // Updates the "Tasks" category of the JumpList. |
| 133 bool UpdateTaskCategory( | 134 bool UpdateTaskCategory( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 170 } | 171 } |
| 171 | 172 |
| 172 return jumplist_updater->AddTasks(items); | 173 return jumplist_updater->AddTasks(items); |
| 173 } | 174 } |
| 174 | 175 |
| 175 // Updates the application JumpList. | 176 // Updates the application JumpList. |
| 176 bool UpdateJumpList(const wchar_t* app_id, | 177 bool UpdateJumpList(const wchar_t* app_id, |
| 177 const ShellLinkItemList& most_visited_pages, | 178 const ShellLinkItemList& most_visited_pages, |
| 178 const ShellLinkItemList& recently_closed_pages, | 179 const ShellLinkItemList& recently_closed_pages, |
| 179 IncognitoModePrefs::Availability incognito_availability) { | 180 IncognitoModePrefs::Availability incognito_availability) { |
| 181 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration"); | |
| 180 // JumpList is implemented only on Windows 7 or later. | 182 // JumpList is implemented only on Windows 7 or later. |
| 181 // So, we should return now when this function is called on earlier versions | 183 // So, we should return now when this function is called on earlier versions |
| 182 // of Windows. | 184 // of Windows. |
| 183 if (!JumpListUpdater::IsEnabled()) | 185 if (!JumpListUpdater::IsEnabled()) |
| 184 return true; | 186 return true; |
| 185 | 187 |
| 186 JumpListUpdater jumplist_updater(app_id); | 188 JumpListUpdater jumplist_updater(app_id); |
| 187 if (!jumplist_updater.BeginUpdate()) | 189 if (!jumplist_updater.BeginUpdate()) |
| 188 return false; | 190 return false; |
| 189 | 191 |
| (...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 249 | 251 |
| 250 // Make local copies of lists so we can release the lock. | 252 // Make local copies of lists so we can release the lock. |
| 251 local_most_visited_pages = data->most_visited_pages_; | 253 local_most_visited_pages = data->most_visited_pages_; |
| 252 local_recently_closed_pages = data->recently_closed_pages_; | 254 local_recently_closed_pages = data->recently_closed_pages_; |
| 253 } | 255 } |
| 254 | 256 |
| 255 // If JumpListIcons directory doesn't exist or is not empty, skip updating the | 257 // If JumpListIcons directory doesn't exist or is not empty, skip updating the |
| 256 // jumplist icons. The jumplist links should be updated anyway, as it doesn't | 258 // jumplist icons. The jumplist links should be updated anyway, as it doesn't |
| 257 // involve disk IO. | 259 // involve disk IO. |
| 258 if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) { | 260 if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) { |
| 261 UMA_HISTOGRAM_COUNTS_100( | |
| 262 "WinJumplist.CreateIconFilesCount", | |
| 263 local_most_visited_pages.size() + local_recently_closed_pages.size()); | |
| 264 | |
| 259 // Create icon files for shortcuts in the "Most Visited" category. | 265 // Create icon files for shortcuts in the "Most Visited" category. |
| 260 CreateIconFiles(icon_dir, local_most_visited_pages); | 266 CreateIconFiles(icon_dir, local_most_visited_pages); |
| 261 | 267 |
| 262 // Create icon files for shortcuts in the "Recently Closed" | 268 // Create icon files for shortcuts in the "Recently Closed" |
| 263 // category. | 269 // category. |
| 264 CreateIconFiles(icon_dir, local_recently_closed_pages); | 270 CreateIconFiles(icon_dir, local_recently_closed_pages); |
| 265 } | 271 } |
| 266 | 272 |
| 267 // Create a new JumpList and replace the current JumpList with it. The | 273 // Create a new JumpList and replace the current JumpList with it. The |
| 268 // jumplist links are updated anyway, while the jumplist icons may not as | 274 // jumplist links are updated anyway, while the jumplist icons may not as |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 618 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 624 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
| 619 } | 625 } |
| 620 | 626 |
| 621 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 627 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
| 622 ChangeReason change_reason) { | 628 ChangeReason change_reason) { |
| 623 top_sites->GetMostVisitedURLs( | 629 top_sites->GetMostVisitedURLs( |
| 624 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 630 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
| 625 weak_ptr_factory_.GetWeakPtr()), | 631 weak_ptr_factory_.GetWeakPtr()), |
| 626 false); | 632 false); |
| 627 } | 633 } |
| OLD | NEW |