| 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 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407. |
| 125 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.CreateIconFilesDuration"); |
| 126 |
| 124 for (ShellLinkItemList::const_iterator item = item_list.begin(); | 127 for (ShellLinkItemList::const_iterator item = item_list.begin(); |
| 125 item != item_list.end(); ++item) { | 128 item != item_list.end(); ++item) { |
| 126 base::FilePath icon_path; | 129 base::FilePath icon_path; |
| 127 if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path)) | 130 if (CreateIconFile((*item)->icon_image(), icon_dir, &icon_path)) |
| 128 (*item)->set_icon(icon_path.value(), 0); | 131 (*item)->set_icon(icon_path.value(), 0); |
| 129 } | 132 } |
| 130 } | 133 } |
| 131 | 134 |
| 132 // Updates the "Tasks" category of the JumpList. | 135 // Updates the "Tasks" category of the JumpList. |
| 133 bool UpdateTaskCategory( | 136 bool UpdateTaskCategory( |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 170 } | 173 } |
| 171 | 174 |
| 172 return jumplist_updater->AddTasks(items); | 175 return jumplist_updater->AddTasks(items); |
| 173 } | 176 } |
| 174 | 177 |
| 175 // Updates the application JumpList. | 178 // Updates the application JumpList. |
| 176 bool UpdateJumpList(const wchar_t* app_id, | 179 bool UpdateJumpList(const wchar_t* app_id, |
| 177 const ShellLinkItemList& most_visited_pages, | 180 const ShellLinkItemList& most_visited_pages, |
| 178 const ShellLinkItemList& recently_closed_pages, | 181 const ShellLinkItemList& recently_closed_pages, |
| 179 IncognitoModePrefs::Availability incognito_availability) { | 182 IncognitoModePrefs::Availability incognito_availability) { |
| 183 // TODO(chengx): Remove the UMA histogram after fixing http://crbug.com/40407. |
| 184 SCOPED_UMA_HISTOGRAM_TIMER("WinJumplist.UpdateJumpListDuration"); |
| 185 |
| 180 // JumpList is implemented only on Windows 7 or later. | 186 // JumpList is implemented only on Windows 7 or later. |
| 181 // So, we should return now when this function is called on earlier versions | 187 // So, we should return now when this function is called on earlier versions |
| 182 // of Windows. | 188 // of Windows. |
| 183 if (!JumpListUpdater::IsEnabled()) | 189 if (!JumpListUpdater::IsEnabled()) |
| 184 return true; | 190 return true; |
| 185 | 191 |
| 186 JumpListUpdater jumplist_updater(app_id); | 192 JumpListUpdater jumplist_updater(app_id); |
| 187 if (!jumplist_updater.BeginUpdate()) | 193 if (!jumplist_updater.BeginUpdate()) |
| 188 return false; | 194 return false; |
| 189 | 195 |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 248 | 254 |
| 249 // Make local copies of lists so we can release the lock. | 255 // Make local copies of lists so we can release the lock. |
| 250 local_most_visited_pages = data->most_visited_pages_; | 256 local_most_visited_pages = data->most_visited_pages_; |
| 251 local_recently_closed_pages = data->recently_closed_pages_; | 257 local_recently_closed_pages = data->recently_closed_pages_; |
| 252 } | 258 } |
| 253 | 259 |
| 254 // If JumpListIcons directory doesn't exist or is not empty, skip updating the | 260 // If JumpListIcons directory doesn't exist or is not empty, skip updating the |
| 255 // jumplist icons. The jumplist links should be updated anyway, as it doesn't | 261 // jumplist icons. The jumplist links should be updated anyway, as it doesn't |
| 256 // involve disk IO. | 262 // involve disk IO. |
| 257 if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) { | 263 if (base::DirectoryExists(icon_dir) && base::IsDirectoryEmpty(icon_dir)) { |
| 264 // TODO(chengx): Remove the UMA histogram after fixing |
| 265 // http://crbug.com/40407. |
| 266 UMA_HISTOGRAM_COUNTS_100( |
| 267 "WinJumplist.CreateIconFilesCount", |
| 268 local_most_visited_pages.size() + local_recently_closed_pages.size()); |
| 269 |
| 258 // Create icon files for shortcuts in the "Most Visited" category. | 270 // Create icon files for shortcuts in the "Most Visited" category. |
| 259 CreateIconFiles(icon_dir, local_most_visited_pages); | 271 CreateIconFiles(icon_dir, local_most_visited_pages); |
| 260 | 272 |
| 261 // Create icon files for shortcuts in the "Recently Closed" | 273 // Create icon files for shortcuts in the "Recently Closed" |
| 262 // category. | 274 // category. |
| 263 CreateIconFiles(icon_dir, local_recently_closed_pages); | 275 CreateIconFiles(icon_dir, local_recently_closed_pages); |
| 264 } | 276 } |
| 265 | 277 |
| 266 // Create a new JumpList and replace the current JumpList with it. The | 278 // Create a new JumpList and replace the current JumpList with it. The |
| 267 // jumplist links are updated anyway, while the jumplist icons may not as | 279 // jumplist links are updated anyway, while the jumplist icons may not as |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 615 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 627 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
| 616 } | 628 } |
| 617 | 629 |
| 618 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 630 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
| 619 ChangeReason change_reason) { | 631 ChangeReason change_reason) { |
| 620 top_sites->GetMostVisitedURLs( | 632 top_sites->GetMostVisitedURLs( |
| 621 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 633 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
| 622 weak_ptr_factory_.GetWeakPtr()), | 634 weak_ptr_factory_.GetWeakPtr()), |
| 623 false); | 635 false); |
| 624 } | 636 } |
| OLD | NEW |