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

Unified Diff: chrome/renderer/searchbox/searchbox.cc

Issue 14805004: InstantExtended: Prevent spurious themechanged/mostvisitedchanged events (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Prevent event triggers from searchbox Created 7 years, 8 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
« chrome/common/instant_types.h ('K') | « chrome/common/instant_types.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/searchbox/searchbox.cc
diff --git a/chrome/renderer/searchbox/searchbox.cc b/chrome/renderer/searchbox/searchbox.cc
index 2483b30b6bf7e6d8d4f2cb8fa48d8e583f45cc18..8e8374de3f686c23fbaac726c99c8525c134d441 100644
--- a/chrome/renderer/searchbox/searchbox.cc
+++ b/chrome/renderer/searchbox/searchbox.cc
@@ -332,6 +332,9 @@ void SearchBox::OnSetDisplayInstantResults(bool display_instant_results) {
}
void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) {
+ if (theme_info == theme_info_) {
samarth 2013/05/03 21:24:42 nit: no braces for 1-line conditionals in Chrome.
+ return;
+ }
theme_info_ = theme_info;
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
extensions_v8::SearchBoxExtension::DispatchThemeChange(
@@ -373,6 +376,25 @@ void SearchBox::Reset() {
void SearchBox::OnMostVisitedChanged(
const std::vector<InstantMostVisitedItemIDPair>& items) {
+ std::vector<InstantMostVisitedItemIDPair> oldItems;
+ most_visited_items_cache_.GetCurrentItems(&oldItems);
+
+ bool most_visited_changed = oldItems.size() != items.size();
samarth 2013/05/03 21:24:42 if (oldsize != newsize) return;
+ if (!most_visited_changed) {
+ for (size_t i = 0; i < items.size(); i++) {
+ InstantMostVisitedItem oldItem = oldItems[i].second;
+ InstantMostVisitedItem newItem = items[i].second;
+ if (newItem.url != oldItem.url || newItem.title != oldItem.title) {
+ most_visited_changed = true;
samarth 2013/05/03 21:24:42 Just return here.
+ break;
+ }
+ }
+ }
+
+ if (!most_visited_changed) {
+ return;
+ }
+
most_visited_items_cache_.AddItemsWithRestrictedID(items);
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
« chrome/common/instant_types.h ('K') | « chrome/common/instant_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698