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 "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
8 #include "chrome/browser/history/most_visited_tiles_experiment.h" | |
9 #include "chrome/browser/history/top_sites.h" | 8 #include "chrome/browser/history/top_sites.h" |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/search/instant_io_context.h" | 10 #include "chrome/browser/search/instant_io_context.h" |
12 #include "chrome/browser/search/instant_service_observer.h" | 11 #include "chrome/browser/search/instant_service_observer.h" |
13 #include "chrome/browser/search/local_ntp_source.h" | 12 #include "chrome/browser/search/local_ntp_source.h" |
14 #include "chrome/browser/search/most_visited_iframe_source.h" | 13 #include "chrome/browser/search/most_visited_iframe_source.h" |
15 #include "chrome/browser/search/search.h" | 14 #include "chrome/browser/search/search.h" |
16 #include "chrome/browser/search/suggestions/suggestions_source.h" | 15 #include "chrome/browser/search/suggestions/suggestions_source.h" |
17 #include "chrome/browser/search_engines/template_url_service_factory.h" | 16 #include "chrome/browser/search_engines/template_url_service_factory.h" |
18 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" | 17 #include "chrome/browser/search_engines/ui_thread_search_terms_data.h" |
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 content::BrowserThread::PostTask( | 257 content::BrowserThread::PostTask( |
259 content::BrowserThread::IO, FROM_HERE, | 258 content::BrowserThread::IO, FROM_HERE, |
260 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, | 259 base::Bind(&InstantIOContext::RemoveInstantProcessOnIO, |
261 instant_io_context_, process_id)); | 260 instant_io_context_, process_id)); |
262 } | 261 } |
263 } | 262 } |
264 | 263 |
265 void InstantService::OnMostVisitedItemsReceived( | 264 void InstantService::OnMostVisitedItemsReceived( |
266 const history::MostVisitedURLList& data) { | 265 const history::MostVisitedURLList& data) { |
267 history::MostVisitedURLList reordered_data(data); | 266 history::MostVisitedURLList reordered_data(data); |
268 history::MostVisitedTilesExperiment::MaybeShuffle(&reordered_data); | |
269 | |
270 std::vector<InstantMostVisitedItem> new_most_visited_items; | 267 std::vector<InstantMostVisitedItem> new_most_visited_items; |
271 for (size_t i = 0; i < reordered_data.size(); i++) { | 268 for (size_t i = 0; i < reordered_data.size(); i++) { |
272 const history::MostVisitedURL& url = reordered_data[i]; | 269 const history::MostVisitedURL& url = reordered_data[i]; |
273 InstantMostVisitedItem item; | 270 InstantMostVisitedItem item; |
274 item.url = url.url; | 271 item.url = url.url; |
275 item.title = url.title; | 272 item.title = url.title; |
276 new_most_visited_items.push_back(item); | 273 new_most_visited_items.push_back(item); |
277 } | 274 } |
278 | 275 |
279 most_visited_items_ = new_most_visited_items; | 276 most_visited_items_ = new_most_visited_items; |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
425 } | 422 } |
426 | 423 |
427 void InstantService::ResetInstantSearchPrerenderer() { | 424 void InstantService::ResetInstantSearchPrerenderer() { |
428 if (!chrome::ShouldPrefetchSearchResults()) | 425 if (!chrome::ShouldPrefetchSearchResults()) |
429 return; | 426 return; |
430 | 427 |
431 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); | 428 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); |
432 instant_prerenderer_.reset( | 429 instant_prerenderer_.reset( |
433 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 430 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
434 } | 431 } |
OLD | NEW |