Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(3453)

Unified Diff: chrome/browser/win/jumplist_update_util.cc

Issue 2896233003: Cancel the JumpList update if top 5 most visited URLs are unchanged (Closed)
Patch Set: Fix nits Created 3 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/win/jumplist_update_util.h ('k') | chrome/browser/win/jumplist_update_util_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/win/jumplist_update_util.cc
diff --git a/chrome/browser/win/jumplist_update_util.cc b/chrome/browser/win/jumplist_update_util.cc
new file mode 100644
index 0000000000000000000000000000000000000000..c8a8a25f6d8319b4e7cfbf0e905559ae26466196
--- /dev/null
+++ b/chrome/browser/win/jumplist_update_util.cc
@@ -0,0 +1,26 @@
+// Copyright (c) 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/win/jumplist_update_util.h"
+
+#include <algorithm>
+#include <iterator>
+
+bool MostVisitedItemsUnchanged(const ShellLinkItemList& items,
+ const history::MostVisitedURLList& urls,
+ size_t max_item_count) {
+ // If the number of urls going to be displayed doesn't equal to the current
+ // one, the most visited items are considered to have changes.
+ // Otherwise, check if the current urls stored in |items| equal to the first
+ // |max_item_count| urls in |urls| to determine if the most visited items
+ // are changed or not.
+
+ if (std::min(urls.size(), max_item_count) != items.size())
+ return false;
+
+ return std::equal(std::begin(items), std::end(items), std::begin(urls),
+ [](const auto& item_ptr, const auto& most_visited_url) {
+ return item_ptr->url() == most_visited_url.url.spec();
+ });
+}
« no previous file with comments | « chrome/browser/win/jumplist_update_util.h ('k') | chrome/browser/win/jumplist_update_util_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698