OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/search/instant_service.h" | 5 #include "chrome/browser/search/instant_service.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
(...skipping 166 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 history::TopSites::MaybeShuffle(&reordered_data); | 177 history::TopSites::MaybeShuffle(&reordered_data); |
178 | 178 |
179 std::vector<InstantMostVisitedItem> new_most_visited_items; | 179 std::vector<InstantMostVisitedItem> new_most_visited_items; |
180 for (size_t i = 0; i < reordered_data.size(); i++) { | 180 for (size_t i = 0; i < reordered_data.size(); i++) { |
181 const history::MostVisitedURL& url = reordered_data[i]; | 181 const history::MostVisitedURL& url = reordered_data[i]; |
182 InstantMostVisitedItem item; | 182 InstantMostVisitedItem item; |
183 item.url = url.url; | 183 item.url = url.url; |
184 item.title = url.title; | 184 item.title = url.title; |
185 new_most_visited_items.push_back(item); | 185 new_most_visited_items.push_back(item); |
186 } | 186 } |
187 if (chrome::AreMostVisitedItemsEqual(new_most_visited_items, | |
188 most_visited_items_)) { | |
189 return; | |
190 } | |
191 | 187 |
192 most_visited_items_ = new_most_visited_items; | 188 most_visited_items_ = new_most_visited_items; |
193 | 189 |
194 const BrowserList* browser_list = | 190 const BrowserList* browser_list = |
195 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 191 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
196 for (BrowserList::const_iterator it = browser_list->begin(); | 192 for (BrowserList::const_iterator it = browser_list->begin(); |
197 it != browser_list->end(); ++it) { | 193 it != browser_list->end(); ++it) { |
198 if ((*it)->profile() != profile_ || !((*it)->instant_controller())) | 194 if ((*it)->profile() != profile_ || !((*it)->instant_controller())) |
199 continue; | 195 continue; |
200 | 196 |
201 InstantController* controller = (*it)->instant_controller()->instant(); | 197 InstantController* controller = (*it)->instant_controller()->instant(); |
202 if (!controller) | 198 if (!controller) |
203 continue; | 199 continue; |
204 // TODO(kmadhusu): It would be cleaner to have each InstantController | 200 // TODO(kmadhusu): It would be cleaner to have each InstantController |
205 // register itself as an InstantServiceObserver and push out updates that | 201 // register itself as an InstantServiceObserver and push out updates that |
206 // way. Refer to crbug.com/246355 for more details. | 202 // way. Refer to crbug.com/246355 for more details. |
207 controller->UpdateMostVisitedItems(); | 203 controller->UpdateMostVisitedItems(); |
208 } | 204 } |
209 #endif | 205 #endif |
210 } | 206 } |
OLD | NEW |