| 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 "base/metrics/field_trial.h" | 7 #include "base/metrics/field_trial.h" |
| 8 #include "base/strings/string_util.h" | 8 #include "base/strings/string_util.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 313 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 } | 324 } |
| 325 if (suggestion.has_favicon_url()) { | 325 if (suggestion.has_favicon_url()) { |
| 326 item.favicon = GURL(suggestion.favicon_url()); | 326 item.favicon = GURL(suggestion.favicon_url()); |
| 327 } | 327 } |
| 328 if (suggestion.has_impression_url()) { | 328 if (suggestion.has_impression_url()) { |
| 329 item.impression_url = GURL(suggestion.impression_url()); | 329 item.impression_url = GURL(suggestion.impression_url()); |
| 330 } | 330 } |
| 331 if (suggestion.has_click_url()) { | 331 if (suggestion.has_click_url()) { |
| 332 item.click_url = GURL(suggestion.click_url()); | 332 item.click_url = GURL(suggestion.click_url()); |
| 333 } | 333 } |
| 334 item.is_server_side_suggestion = true; |
| 334 new_suggestions_items.push_back(item); | 335 new_suggestions_items.push_back(item); |
| 335 } | 336 } |
| 336 suggestions_items_ = new_suggestions_items; | 337 suggestions_items_ = new_suggestions_items; |
| 337 NotifyAboutMostVisitedItems(); | 338 NotifyAboutMostVisitedItems(); |
| 338 } | 339 } |
| 339 | 340 |
| 340 void InstantService::OnMostVisitedItemsReceived( | 341 void InstantService::OnMostVisitedItemsReceived( |
| 341 const history::MostVisitedURLList& data) { | 342 const history::MostVisitedURLList& data) { |
| 342 history::MostVisitedURLList reordered_data(data); | 343 history::MostVisitedURLList reordered_data(data); |
| 343 std::vector<InstantMostVisitedItem> new_most_visited_items; | 344 std::vector<InstantMostVisitedItem> new_most_visited_items; |
| 344 for (size_t i = 0; i < reordered_data.size(); i++) { | 345 for (size_t i = 0; i < reordered_data.size(); i++) { |
| 345 const history::MostVisitedURL& url = reordered_data[i]; | 346 const history::MostVisitedURL& url = reordered_data[i]; |
| 346 InstantMostVisitedItem item; | 347 InstantMostVisitedItem item; |
| 347 item.url = url.url; | 348 item.url = url.url; |
| 348 item.title = url.title; | 349 item.title = url.title; |
| 350 item.is_server_side_suggestion = false; |
| 349 new_most_visited_items.push_back(item); | 351 new_most_visited_items.push_back(item); |
| 350 } | 352 } |
| 351 | 353 |
| 352 most_visited_items_ = new_most_visited_items; | 354 most_visited_items_ = new_most_visited_items; |
| 353 NotifyAboutMostVisitedItems(); | 355 NotifyAboutMostVisitedItems(); |
| 354 } | 356 } |
| 355 | 357 |
| 356 void InstantService::NotifyAboutMostVisitedItems() { | 358 void InstantService::NotifyAboutMostVisitedItems() { |
| 357 if (suggestions_service_ && !suggestions_items_.empty()) { | 359 if (suggestions_service_ && !suggestions_items_.empty()) { |
| 358 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, | 360 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 } | 540 } |
| 539 | 541 |
| 540 void InstantService::ResetInstantSearchPrerenderer() { | 542 void InstantService::ResetInstantSearchPrerenderer() { |
| 541 if (!search::ShouldPrefetchSearchResults()) | 543 if (!search::ShouldPrefetchSearchResults()) |
| 542 return; | 544 return; |
| 543 | 545 |
| 544 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); | 546 GURL url(search::GetSearchResultPrefetchBaseURL(profile_)); |
| 545 instant_prerenderer_.reset( | 547 instant_prerenderer_.reset( |
| 546 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); | 548 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); |
| 547 } | 549 } |
| OLD | NEW |