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

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

Issue 15404003: Revert 200954 "Revert "InstantExtended: Prevent spurious themech..." (Closed) Base URL: svn://svn.chromium.org/chrome/
Patch Set: Created 7 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 | « trunk/src/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: trunk/src/chrome/renderer/searchbox/searchbox.cc
===================================================================
--- trunk/src/chrome/renderer/searchbox/searchbox.cc (revision 200965)
+++ trunk/src/chrome/renderer/searchbox/searchbox.cc (working copy)
@@ -24,6 +24,36 @@
// Size of the results cache.
const size_t kMaxInstantAutocompleteResultItemCacheSize = 100;
+bool IsThemeInfoEqual(const ThemeBackgroundInfo& new_theme_info,
+ const ThemeBackgroundInfo& old_theme_info) {
+ return old_theme_info.color_r == new_theme_info.color_r &&
+ old_theme_info.color_g == new_theme_info.color_g &&
+ old_theme_info.color_b == new_theme_info.color_b &&
+ old_theme_info.color_a == new_theme_info.color_a &&
+ old_theme_info.theme_id == new_theme_info.theme_id &&
+ old_theme_info.image_horizontal_alignment ==
+ new_theme_info.image_horizontal_alignment &&
+ old_theme_info.image_vertical_alignment ==
+ new_theme_info.image_vertical_alignment &&
+ old_theme_info.image_tiling == new_theme_info.image_tiling &&
+ old_theme_info.image_height == new_theme_info.image_height &&
+ old_theme_info.has_attribution == new_theme_info.has_attribution;
+}
+
+bool AreMostVisitedItemsEqual(
+ const std::vector<InstantMostVisitedItemIDPair>& new_items,
+ const std::vector<InstantMostVisitedItemIDPair>& old_items) {
+ if (old_items.size() != new_items.size())
+ return false;
+ for (size_t i = 0; i < new_items.size(); i++) {
+ const InstantMostVisitedItem& old_item = old_items[i].second;
+ const InstantMostVisitedItem& new_item = new_items[i].second;
+ if (new_item.url != old_item.url || new_item.title != old_item.title)
+ return false;
+ }
+ return true;
+}
+
} // namespace
SearchBox::SearchBox(content::RenderView* render_view)
@@ -339,6 +369,8 @@
}
void SearchBox::OnThemeChanged(const ThemeBackgroundInfo& theme_info) {
+ if (IsThemeInfoEqual(theme_info, theme_info_))
+ return;
theme_info_ = theme_info;
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
extensions_v8::SearchBoxExtension::DispatchThemeChange(
@@ -387,6 +419,11 @@
void SearchBox::OnMostVisitedChanged(
const std::vector<InstantMostVisitedItemIDPair>& items) {
+ std::vector<InstantMostVisitedItemIDPair> old_items;
+ most_visited_items_cache_.GetCurrentItems(&old_items);
+ if (AreMostVisitedItemsEqual(items, old_items))
+ return;
+
most_visited_items_cache_.AddItemsWithRestrictedID(items);
if (render_view()->GetWebView() && render_view()->GetWebView()->mainFrame()) {
« no previous file with comments | « trunk/src/chrome/common/instant_types.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698