| 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 "base/base_paths.h" | 7 #include "base/base_paths.h" |
| 8 #include "base/bind.h" | 8 #include "base/bind.h" |
| 9 #include "base/bind_helpers.h" | 9 #include "base/bind_helpers.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 424 const history::MostVisitedURL& url = urls[i]; | 424 const history::MostVisitedURL& url = urls[i]; |
| 425 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | 425 scoped_refptr<ShellLinkItem> link = CreateShellLink(); |
| 426 std::string url_string = url.url.spec(); | 426 std::string url_string = url.url.spec(); |
| 427 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); | 427 base::string16 url_string_wide = base::UTF8ToUTF16(url_string); |
| 428 link->GetCommandLine()->AppendArgNative(url_string_wide); | 428 link->GetCommandLine()->AppendArgNative(url_string_wide); |
| 429 link->GetCommandLine()->AppendSwitchASCII(switches::kWinJumplistAction, | 429 link->GetCommandLine()->AppendSwitchASCII(switches::kWinJumplistAction, |
| 430 jumplist::kMostVisitedCategory); | 430 jumplist::kMostVisitedCategory); |
| 431 link->set_title(!url.title.empty() ? url.title : url_string_wide); | 431 link->set_title(!url.title.empty() ? url.title : url_string_wide); |
| 432 link->set_url(url_string); | 432 link->set_url(url_string); |
| 433 most_visited_pages_.push_back(link); | 433 most_visited_pages_.push_back(link); |
| 434 icon_urls_.emplace_back(std::move(url_string), std::move(link)); | 434 if (most_visited_icons_.find(url_string) == most_visited_icons_.end()) |
| 435 icon_urls_.emplace_back(std::move(url_string), std::move(link)); |
| 435 } | 436 } |
| 436 | 437 |
| 437 most_visited_should_update_ = true; | 438 most_visited_should_update_ = true; |
| 438 | 439 |
| 439 // Send a query that retrieves the first favicon. | 440 // Send a query that retrieves the first favicon. |
| 440 StartLoadingFavicon(); | 441 StartLoadingFavicon(); |
| 441 } | 442 } |
| 442 | 443 |
| 443 bool JumpList::AddTab(const sessions::TabRestoreService::Tab& tab, | 444 bool JumpList::AddTab(const sessions::TabRestoreService::Tab& tab, |
| 444 size_t max_items) { | 445 size_t max_items) { |
| 445 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 446 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 446 | 447 |
| 447 // This code adds the URL and the title strings of the given tab to the | 448 // This code adds the URL and the title strings of the given tab to the |
| 448 // JumpList variables. | 449 // JumpList variables. |
| 449 if (recently_closed_pages_.size() >= max_items) | 450 if (recently_closed_pages_.size() >= max_items) |
| 450 return false; | 451 return false; |
| 451 | 452 |
| 452 scoped_refptr<ShellLinkItem> link = CreateShellLink(); | 453 scoped_refptr<ShellLinkItem> link = CreateShellLink(); |
| 453 const sessions::SerializedNavigationEntry& current_navigation = | 454 const sessions::SerializedNavigationEntry& current_navigation = |
| 454 tab.navigations.at(tab.current_navigation_index); | 455 tab.navigations.at(tab.current_navigation_index); |
| 455 std::string url = current_navigation.virtual_url().spec(); | 456 std::string url = current_navigation.virtual_url().spec(); |
| 456 link->GetCommandLine()->AppendArgNative(base::UTF8ToUTF16(url)); | 457 link->GetCommandLine()->AppendArgNative(base::UTF8ToUTF16(url)); |
| 457 link->GetCommandLine()->AppendSwitchASCII(switches::kWinJumplistAction, | 458 link->GetCommandLine()->AppendSwitchASCII(switches::kWinJumplistAction, |
| 458 jumplist::kRecentlyClosedCategory); | 459 jumplist::kRecentlyClosedCategory); |
| 459 link->set_title(current_navigation.title()); | 460 link->set_title(current_navigation.title()); |
| 460 link->set_url(url); | 461 link->set_url(url); |
| 461 recently_closed_pages_.push_back(link); | 462 recently_closed_pages_.push_back(link); |
| 462 icon_urls_.emplace_back(std::move(url), std::move(link)); | 463 if (recently_closed_icons_.find(url) == recently_closed_icons_.end()) |
| 464 icon_urls_.emplace_back(std::move(url), std::move(link)); |
| 463 | 465 |
| 464 return true; | 466 return true; |
| 465 } | 467 } |
| 466 | 468 |
| 467 void JumpList::AddWindow(const sessions::TabRestoreService::Window& window, | 469 void JumpList::AddWindow(const sessions::TabRestoreService::Window& window, |
| 468 size_t max_items) { | 470 size_t max_items) { |
| 469 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); | 471 DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); |
| 470 DCHECK(!window.tabs.empty()); | 472 DCHECK(!window.tabs.empty()); |
| 471 | 473 |
| 472 for (const auto& tab : window.tabs) { | 474 for (const auto& tab : window.tabs) { |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 820 URLIconCache* icon_cache) { | 822 URLIconCache* icon_cache) { |
| 821 // Put all cached icon file paths into a set. | 823 // Put all cached icon file paths into a set. |
| 822 base::flat_set<base::FilePath> cached_files; | 824 base::flat_set<base::FilePath> cached_files; |
| 823 cached_files.reserve(icon_cache->size()); | 825 cached_files.reserve(icon_cache->size()); |
| 824 | 826 |
| 825 for (const auto& url_path_pair : *icon_cache) | 827 for (const auto& url_path_pair : *icon_cache) |
| 826 cached_files.insert(url_path_pair.second); | 828 cached_files.insert(url_path_pair.second); |
| 827 | 829 |
| 828 DeleteNonCachedFiles(icon_dir, cached_files); | 830 DeleteNonCachedFiles(icon_dir, cached_files); |
| 829 } | 831 } |
| OLD | NEW |