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

Side by Side Diff: chrome/browser/search/instant_service.cc

Issue 930853005: [Instant] Default Search Provider change redirects to local NTP in some cases (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: includes Created 5 years, 10 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
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/browser/search/instant_service_observer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/top_sites_factory.h" 8 #include "chrome/browser/history/top_sites_factory.h"
9 #include "chrome/browser/profiles/profile.h" 9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/browser/search/instant_io_context.h" 10 #include "chrome/browser/search/instant_io_context.h"
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
400 UIThreadSearchTermsData(profile_)); 400 UIThreadSearchTermsData(profile_));
401 if (default_search_provider_changed) { 401 if (default_search_provider_changed) {
402 previous_default_search_provider_.reset( 402 previous_default_search_provider_.reset(
403 template_url ? new TemplateURLData(template_url->data()) : NULL); 403 template_url ? new TemplateURLData(template_url->data()) : NULL);
404 } 404 }
405 405
406 // Note that, even if the TemplateURL for the Default Search Provider has not 406 // Note that, even if the TemplateURL for the Default Search Provider has not
407 // changed, the effective URLs might change if they reference the Google base 407 // changed, the effective URLs might change if they reference the Google base
408 // URL. The TemplateURLService will notify us when the effective URL changes 408 // URL. The TemplateURLService will notify us when the effective URL changes
409 // in this way but it's up to us to do the work to check both. 409 // in this way but it's up to us to do the work to check both.
410 bool google_base_url_domain_changed = false;
410 GURL google_base_url(UIThreadSearchTermsData(profile_).GoogleBaseURLValue()); 411 GURL google_base_url(UIThreadSearchTermsData(profile_).GoogleBaseURLValue());
411 if (google_base_url != previous_google_base_url_) { 412 if (google_base_url != previous_google_base_url_) {
412 previous_google_base_url_ = google_base_url; 413 previous_google_base_url_ = google_base_url;
413 if (template_url && template_url->HasGoogleBaseURLs( 414 if (template_url && template_url->HasGoogleBaseURLs(
414 UIThreadSearchTermsData(profile_))) 415 UIThreadSearchTermsData(profile_)))
415 default_search_provider_changed = true; 416 google_base_url_domain_changed = true;
416 } 417 }
417 418
418 if (default_search_provider_changed) { 419 if (default_search_provider_changed || google_base_url_domain_changed) {
419 ResetInstantSearchPrerenderer(); 420 ResetInstantSearchPrerenderer();
420 FOR_EACH_OBSERVER(InstantServiceObserver, observers_, 421 FOR_EACH_OBSERVER(
421 DefaultSearchProviderChanged()); 422 InstantServiceObserver, observers_,
423 DefaultSearchProviderChanged(google_base_url_domain_changed));
422 } 424 }
423 } 425 }
424 426
425 void InstantService::TopSitesLoaded(history::TopSites* top_sites) { 427 void InstantService::TopSitesLoaded(history::TopSites* top_sites) {
426 } 428 }
427 429
428 void InstantService::TopSitesChanged(history::TopSites* top_sites) { 430 void InstantService::TopSitesChanged(history::TopSites* top_sites) {
429 top_sites->GetMostVisitedURLs( 431 top_sites->GetMostVisitedURLs(
430 base::Bind(&InstantService::OnMostVisitedItemsReceived, 432 base::Bind(&InstantService::OnMostVisitedItemsReceived,
431 weak_ptr_factory_.GetWeakPtr()), 433 weak_ptr_factory_.GetWeakPtr()),
432 false); 434 false);
433 } 435 }
434 436
435 void InstantService::ResetInstantSearchPrerenderer() { 437 void InstantService::ResetInstantSearchPrerenderer() {
436 if (!chrome::ShouldPrefetchSearchResults()) 438 if (!chrome::ShouldPrefetchSearchResults())
437 return; 439 return;
438 440
439 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_)); 441 GURL url(chrome::GetSearchResultPrefetchBaseURL(profile_));
440 instant_prerenderer_.reset( 442 instant_prerenderer_.reset(
441 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL); 443 url.is_valid() ? new InstantSearchPrerenderer(profile_, url) : NULL);
442 } 444 }
OLDNEW
« no previous file with comments | « chrome/browser/android/tab_android.cc ('k') | chrome/browser/search/instant_service_observer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698