diff options
author | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 20:28:11 +0000 |
---|---|---|
committer | kmadhusu@chromium.org <kmadhusu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-06-22 20:28:11 +0000 |
commit | 723eaf484c3eec4643cb4e1a470809b307764383 (patch) | |
tree | 5be57530f2484dd75aaa5e4601fdc5868198c675 /chrome/renderer/searchbox/searchbox.cc | |
parent | 4815b78cb46d8fac21213fc0583f8524dfacfb18 (diff) | |
download | chromium_src-723eaf484c3eec4643cb4e1a470809b307764383.zip chromium_src-723eaf484c3eec4643cb4e1a470809b307764383.tar.gz chromium_src-723eaf484c3eec4643cb4e1a470809b307764383.tar.bz2 |
Added a check in Searchbox::OnMostVisitedChanged() to prevent duplicate notifications regarding most visited items.
SearchTabHelper no longer tracks the last known most visited items list.
BUG=248683
TEST=none
Review URL: https://chromiumcodereview.appspot.com/17521002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@208086 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/renderer/searchbox/searchbox.cc')
-rw-r--r-- | chrome/renderer/searchbox/searchbox.cc | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc index bd563a8..922e985 100644 --- a/chrome/renderer/searchbox/searchbox.cc +++ b/chrome/renderer/searchbox/searchbox.cc @@ -28,6 +28,23 @@ namespace { // Size of the results cache. const size_t kMaxInstantAutocompleteResultItemCacheSize = 100; +// Returns true if items stored in |old_item_id_pairs| and |new_items| are +// equal. +bool AreMostVisitedItemsEqual( + const std::vector<InstantMostVisitedItemIDPair>& old_item_id_pairs, + const std::vector<InstantMostVisitedItem>& new_items) { + if (old_item_id_pairs.size() != new_items.size()) + return false; + + for (size_t i = 0; i < new_items.size(); ++i) { + if (new_items[i].url != old_item_id_pairs[i].second.url || + new_items[i].title != old_item_id_pairs[i].second.title) { + return false; + } + } + return true; +} + } // namespace namespace internal { // for testing @@ -506,6 +523,12 @@ void SearchBox::SetQuery(const string16& query, bool verbatim) { void SearchBox::OnMostVisitedChanged( const std::vector<InstantMostVisitedItem>& items) { + std::vector<InstantMostVisitedItemIDPair> last_known_items; + GetMostVisitedItems(&last_known_items); + + if (AreMostVisitedItemsEqual(last_known_items, items)) + return; // Do not send duplicate onmostvisitedchange events. + most_visited_items_cache_.AddItems(items); if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) { extensions_v8::SearchBoxExtension::DispatchMostVisitedChanged( |