| 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 | 66 |
| 67 // The delay before updating the JumpList to prevent update storms. | 67 // The delay before updating the JumpList to prevent update storms. |
| 68 constexpr base::TimeDelta kDelayForJumplistUpdate = | 68 constexpr base::TimeDelta kDelayForJumplistUpdate = |
| 69 base::TimeDelta::FromMilliseconds(3500); | 69 base::TimeDelta::FromMilliseconds(3500); |
| 70 | 70 |
| 71 // The maximum allowed time for JumpListUpdater::BeginUpdate. Updates taking | 71 // The maximum allowed time for JumpListUpdater::BeginUpdate. Updates taking |
| 72 // longer than this are discarded to prevent bogging down slow machines. | 72 // longer than this are discarded to prevent bogging down slow machines. |
| 73 constexpr base::TimeDelta kTimeOutForJumplistUpdate = | 73 constexpr base::TimeDelta kTimeOutForJumplistUpdate = |
| 74 base::TimeDelta::FromMilliseconds(500); | 74 base::TimeDelta::FromMilliseconds(500); |
| 75 | 75 |
| 76 // Append the common switches to each shell link. | 76 // Appends the common switches to each shell link. |
| 77 void AppendCommonSwitches(ShellLinkItem* shell_link) { | 77 void AppendCommonSwitches(ShellLinkItem* shell_link) { |
| 78 const char* kSwitchNames[] = { switches::kUserDataDir }; | 78 const char* kSwitchNames[] = { switches::kUserDataDir }; |
| 79 const base::CommandLine& command_line = | 79 const base::CommandLine& command_line = |
| 80 *base::CommandLine::ForCurrentProcess(); | 80 *base::CommandLine::ForCurrentProcess(); |
| 81 shell_link->GetCommandLine()->CopySwitchesFrom(command_line, | 81 shell_link->GetCommandLine()->CopySwitchesFrom(command_line, |
| 82 kSwitchNames, | 82 kSwitchNames, |
| 83 arraysize(kSwitchNames)); | 83 arraysize(kSwitchNames)); |
| 84 } | 84 } |
| 85 | 85 |
| 86 // Create a ShellLinkItem preloaded with common switches. | 86 // Creates a ShellLinkItem preloaded with common switches. |
| 87 scoped_refptr<ShellLinkItem> CreateShellLink() { | 87 scoped_refptr<ShellLinkItem> CreateShellLink() { |
| 88 scoped_refptr<ShellLinkItem> link(new ShellLinkItem); | 88 scoped_refptr<ShellLinkItem> link(new ShellLinkItem); |
| 89 AppendCommonSwitches(link.get()); | 89 AppendCommonSwitches(link.get()); |
| 90 return link; | 90 return link; |
| 91 } | 91 } |
| 92 | 92 |
| 93 // Creates a temporary icon file to be shown in JumpList. | 93 // Creates a temporary icon file to be shown in JumpList. |
| 94 bool CreateIconFile(const gfx::ImageSkia& image_skia, | 94 bool CreateIconFile(const gfx::ImageSkia& image_skia, |
| 95 const base::FilePath& icon_dir, | 95 const base::FilePath& icon_dir, |
| 96 base::FilePath* icon_path) { | 96 base::FilePath* icon_path) { |
| (...skipping 400 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 | 497 |
| 498 // Create a list of ShellLinkItems from the "Recently Closed" pages. | 498 // Create a list of ShellLinkItems from the "Recently Closed" pages. |
| 499 // As noted above, we create a ShellLinkItem objects with the following | 499 // As noted above, we create a ShellLinkItem objects with the following |
| 500 // parameters. | 500 // parameters. |
| 501 // * arguments | 501 // * arguments |
| 502 // The last URL of the tab object. | 502 // The last URL of the tab object. |
| 503 // * title | 503 // * title |
| 504 // The title of the last URL. | 504 // The title of the last URL. |
| 505 // * icon | 505 // * icon |
| 506 // An empty string. This value is to be updated in OnFaviconDataAvailable(). | 506 // An empty string. This value is to be updated in OnFaviconDataAvailable(). |
| 507 // This code is copied from | |
| 508 // RecentlyClosedTabsHandler::TabRestoreServiceChanged() to emulate it. | |
| 509 const int kRecentlyClosedCount = 3; | 507 const int kRecentlyClosedCount = 3; |
| 510 sessions::TabRestoreService* tab_restore_service = | 508 sessions::TabRestoreService* tab_restore_service = |
| 511 TabRestoreServiceFactory::GetForProfile(profile_); | 509 TabRestoreServiceFactory::GetForProfile(profile_); |
| 512 | 510 |
| 513 { | 511 { |
| 514 JumpListData* data = &jumplist_data_->data; | 512 JumpListData* data = &jumplist_data_->data; |
| 515 base::AutoLock auto_lock(data->list_lock_); | 513 base::AutoLock auto_lock(data->list_lock_); |
| 516 data->recently_closed_pages_.clear(); | 514 data->recently_closed_pages_.clear(); |
| 517 | 515 |
| 518 for (const auto& entry : tab_restore_service->entries()) { | 516 for (const auto& entry : tab_restore_service->entries()) { |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 706 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { | 704 void JumpList::TopSitesLoaded(history::TopSites* top_sites) { |
| 707 } | 705 } |
| 708 | 706 |
| 709 void JumpList::TopSitesChanged(history::TopSites* top_sites, | 707 void JumpList::TopSitesChanged(history::TopSites* top_sites, |
| 710 ChangeReason change_reason) { | 708 ChangeReason change_reason) { |
| 711 top_sites->GetMostVisitedURLs( | 709 top_sites->GetMostVisitedURLs( |
| 712 base::Bind(&JumpList::OnMostVisitedURLsAvailable, | 710 base::Bind(&JumpList::OnMostVisitedURLsAvailable, |
| 713 weak_ptr_factory_.GetWeakPtr()), | 711 weak_ptr_factory_.GetWeakPtr()), |
| 714 false); | 712 false); |
| 715 } | 713 } |
| OLD | NEW |