Avi Drissman | 4a8573c | 2022-09-09 19:35:54 | [diff] [blame] | 1 | // Copyright 2017 The Chromium Authors |
chengx | 61e622b | 2017-05-31 20:59:27 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
| 5 | #include "chrome/browser/win/jumplist_update_util.h" |
| 6 | |
| 7 | #include <algorithm> |
| 8 | #include <iterator> |
| 9 | |
| 10 | bool MostVisitedItemsUnchanged(const ShellLinkItemList& items, |
| 11 | const history::MostVisitedURLList& urls, |
| 12 | size_t max_item_count) { |
| 13 | // If the number of urls going to be displayed doesn't equal to the current |
| 14 | // one, the most visited items are considered to have changes. |
| 15 | // Otherwise, check if the current urls stored in |items| equal to the first |
| 16 | // |max_item_count| urls in |urls| to determine if the most visited items |
| 17 | // are changed or not. |
| 18 | |
| 19 | if (std::min(urls.size(), max_item_count) != items.size()) |
| 20 | return false; |
| 21 | |
| 22 | return std::equal(std::begin(items), std::end(items), std::begin(urls), |
| 23 | [](const auto& item_ptr, const auto& most_visited_url) { |
| 24 | return item_ptr->url() == most_visited_url.url.spec(); |
| 25 | }); |
| 26 | } |