| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/autocomplete/base_search_provider.h" | 5 #include "chrome/browser/autocomplete/base_search_provider.h" |
| 6 | 6 |
| 7 #include "base/i18n/case_conversion.h" | 7 #include "base/i18n/case_conversion.h" |
| 8 #include "base/i18n/icu_string_conversions.h" | 8 #include "base/i18n/icu_string_conversions.h" |
| 9 #include "base/json/json_string_value_serializer.h" | 9 #include "base/json/json_string_value_serializer.h" |
| 10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 535 bool BaseSearchProvider::ZeroSuggestEnabled( | 535 bool BaseSearchProvider::ZeroSuggestEnabled( |
| 536 const GURL& suggest_url, | 536 const GURL& suggest_url, |
| 537 const TemplateURL* template_url, | 537 const TemplateURL* template_url, |
| 538 AutocompleteInput::PageClassification page_classification, | 538 AutocompleteInput::PageClassification page_classification, |
| 539 Profile* profile) { | 539 Profile* profile) { |
| 540 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial()) | 540 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial()) |
| 541 return false; | 541 return false; |
| 542 | 542 |
| 543 // Make sure we are sending the suggest request through HTTPS to prevent | 543 // Make sure we are sending the suggest request through HTTPS to prevent |
| 544 // exposing the current page URL or personalized results without encryption. | 544 // exposing the current page URL or personalized results without encryption. |
| 545 if (!suggest_url.SchemeIs(content::kHttpsScheme)) | 545 if (!suggest_url.SchemeIs(url::kHttpsScheme)) |
| 546 return false; | 546 return false; |
| 547 | 547 |
| 548 // Don't show zero suggest on the NTP. | 548 // Don't show zero suggest on the NTP. |
| 549 // TODO(hfung): Experiment with showing MostVisited zero suggest on NTP | 549 // TODO(hfung): Experiment with showing MostVisited zero suggest on NTP |
| 550 // under the conditions described in crbug.com/305366. | 550 // under the conditions described in crbug.com/305366. |
| 551 if ((page_classification == | 551 if ((page_classification == |
| 552 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) || | 552 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) || |
| 553 (page_classification == | 553 (page_classification == |
| 554 AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS)) | 554 AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS)) |
| 555 return false; | 555 return false; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 582 Profile* profile) { | 582 Profile* profile) { |
| 583 if (!ZeroSuggestEnabled(suggest_url, template_url, page_classification, | 583 if (!ZeroSuggestEnabled(suggest_url, template_url, page_classification, |
| 584 profile)) | 584 profile)) |
| 585 return false; | 585 return false; |
| 586 | 586 |
| 587 if (!current_page_url.is_valid()) | 587 if (!current_page_url.is_valid()) |
| 588 return false; | 588 return false; |
| 589 | 589 |
| 590 // Only allow HTTP URLs or HTTPS URLs for the same domain as the search | 590 // Only allow HTTP URLs or HTTPS URLs for the same domain as the search |
| 591 // provider. | 591 // provider. |
| 592 if ((current_page_url.scheme() != content::kHttpScheme) && | 592 if ((current_page_url.scheme() != url::kHttpScheme) && |
| 593 ((current_page_url.scheme() != content::kHttpsScheme) || | 593 ((current_page_url.scheme() != url::kHttpsScheme) || |
| 594 !net::registry_controlled_domains::SameDomainOrHost( | 594 !net::registry_controlled_domains::SameDomainOrHost( |
| 595 current_page_url, suggest_url, | 595 current_page_url, suggest_url, |
| 596 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))) | 596 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))) |
| 597 return false; | 597 return false; |
| 598 | 598 |
| 599 // Check field trials and settings allow sending the URL on suggest requests. | 599 // Check field trials and settings allow sending the URL on suggest requests. |
| 600 ProfileSyncService* service = | 600 ProfileSyncService* service = |
| 601 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 601 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
| 602 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); | 602 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); |
| 603 if (service == NULL || | 603 if (service == NULL || |
| (...skipping 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 898 } | 898 } |
| 899 | 899 |
| 900 void BaseSearchProvider::OnDeletionComplete( | 900 void BaseSearchProvider::OnDeletionComplete( |
| 901 bool success, SuggestionDeletionHandler* handler) { | 901 bool success, SuggestionDeletionHandler* handler) { |
| 902 RecordDeletionResult(success); | 902 RecordDeletionResult(success); |
| 903 SuggestionDeletionHandlers::iterator it = std::find( | 903 SuggestionDeletionHandlers::iterator it = std::find( |
| 904 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 904 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
| 905 DCHECK(it != deletion_handlers_.end()); | 905 DCHECK(it != deletion_handlers_.end()); |
| 906 deletion_handlers_.erase(it); | 906 deletion_handlers_.erase(it); |
| 907 } | 907 } |
| OLD | NEW |