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

Side by Side Diff: chrome/browser/ui/search/search_tab_helper.cc

Issue 17521002: Added a check in Searchbox::OnMostVisitedChanged() to prevent duplicate notifications regarding mos… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/search/search_tab_helper.h" 5 #include "chrome/browser/ui/search/search_tab_helper.h"
6 6
7 #include "chrome/browser/profiles/profile.h" 7 #include "chrome/browser/profiles/profile.h"
8 #include "chrome/browser/search/search.h" 8 #include "chrome/browser/search/search.h"
9 #include "chrome/common/render_messages.h" 9 #include "chrome/common/render_messages.h"
10 #include "chrome/common/url_constants.h" 10 #include "chrome/common/url_constants.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 UpdateMode(); 84 UpdateMode();
85 } 85 }
86 86
87 void SearchTabHelper::NavigationEntryUpdated() { 87 void SearchTabHelper::NavigationEntryUpdated() {
88 if (!is_search_enabled_) 88 if (!is_search_enabled_)
89 return; 89 return;
90 90
91 UpdateMode(); 91 UpdateMode();
92 } 92 }
93 93
94 bool SearchTabHelper::UpdateLastKnownMostVisitedItems(
95 const std::vector<InstantMostVisitedItem>& items) {
96 if (chrome::AreMostVisitedItemsEqual(items, last_known_most_visited_items_))
97 return false;
98
99 last_known_most_visited_items_ = items;
100 return true;
101 }
102
103 void SearchTabHelper::InstantSupportChanged(bool instant_support) { 94 void SearchTabHelper::InstantSupportChanged(bool instant_support) {
104 if (!is_search_enabled_) 95 if (!is_search_enabled_)
105 return; 96 return;
106 97
107 model_.SetInstantSupportState(instant_support ? INSTANT_SUPPORT_YES : 98 model_.SetInstantSupportState(instant_support ? INSTANT_SUPPORT_YES :
108 INSTANT_SUPPORT_NO); 99 INSTANT_SUPPORT_NO);
109 } 100 }
110 101
111 bool SearchTabHelper::SupportsInstant() const { 102 bool SearchTabHelper::SupportsInstant() const {
112 return model_.instant_support() == INSTANT_SUPPORT_YES; 103 return model_.instant_support() == INSTANT_SUPPORT_YES;
113 } 104 }
114 105
115 void SearchTabHelper::Observe( 106 void SearchTabHelper::Observe(
116 int type, 107 int type,
117 const content::NotificationSource& source, 108 const content::NotificationSource& source,
118 const content::NotificationDetails& details) { 109 const content::NotificationDetails& details) {
119 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type); 110 DCHECK_EQ(content::NOTIFICATION_NAV_ENTRY_COMMITTED, type);
120 content::LoadCommittedDetails* load_details = 111 content::LoadCommittedDetails* load_details =
121 content::Details<content::LoadCommittedDetails>(details).ptr(); 112 content::Details<content::LoadCommittedDetails>(details).ptr();
122 if (!load_details->is_main_frame) 113 if (!load_details->is_main_frame)
123 return; 114 return;
124 115
125 UpdateMode(); 116 UpdateMode();
126 last_known_most_visited_items_.clear();
127 117
128 // Already determined the instant support state for this page, do not reset 118 // Already determined the instant support state for this page, do not reset
129 // the instant support state. 119 // the instant support state.
130 // 120 //
131 // When we get a navigation entry committed event, there seem to be two ways 121 // When we get a navigation entry committed event, there seem to be two ways
132 // to tell whether the navigation was "in-page". Ideally, when 122 // to tell whether the navigation was "in-page". Ideally, when
133 // LoadCommittedDetails::is_in_page is true, we should have 123 // LoadCommittedDetails::is_in_page is true, we should have
134 // LoadCommittedDetails::type to be NAVIGATION_TYPE_IN_PAGE. Unfortunately, 124 // LoadCommittedDetails::type to be NAVIGATION_TYPE_IN_PAGE. Unfortunately,
135 // they are different in some cases. To workaround this bug, we are checking 125 // they are different in some cases. To workaround this bug, we are checking
136 // (is_in_page || type == NAVIGATION_TYPE_IN_PAGE). Please refer to 126 // (is_in_page || type == NAVIGATION_TYPE_IN_PAGE). Please refer to
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
225 if (web_contents()->IsActiveEntry(page_id)) 215 if (web_contents()->IsActiveEntry(page_id))
226 model_.SetTopBarsVisible(true); 216 model_.SetTopBarsVisible(true);
227 } 217 }
228 218
229 void SearchTabHelper::OnSearchBoxHideBars(int page_id) { 219 void SearchTabHelper::OnSearchBoxHideBars(int page_id) {
230 if (web_contents()->IsActiveEntry(page_id)) { 220 if (web_contents()->IsActiveEntry(page_id)) {
231 model_.SetTopBarsVisible(false); 221 model_.SetTopBarsVisible(false);
232 Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id())); 222 Send(new ChromeViewMsg_SearchBoxBarsHidden(routing_id()));
233 } 223 }
234 } 224 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698