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

Side by Side Diff: chrome/browser/autocomplete/base_search_provider.cc

Issue 254763005: Move some content url constants to /url. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Initial patches. Created 6 years, 8 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
OLDNEW
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 12 matching lines...) Expand all
23 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 23 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
24 #include "chrome/browser/sync/profile_sync_service.h" 24 #include "chrome/browser/sync/profile_sync_service.h"
25 #include "chrome/browser/sync/profile_sync_service_factory.h" 25 #include "chrome/browser/sync/profile_sync_service_factory.h"
26 #include "chrome/common/net/url_fixer_upper.h" 26 #include "chrome/common/net/url_fixer_upper.h"
27 #include "chrome/common/pref_names.h" 27 #include "chrome/common/pref_names.h"
28 #include "components/sync_driver/sync_prefs.h" 28 #include "components/sync_driver/sync_prefs.h"
29 #include "content/public/common/url_constants.h" 29 #include "content/public/common/url_constants.h"
30 #include "net/base/escape.h" 30 #include "net/base/escape.h"
31 #include "net/base/net_util.h" 31 #include "net/base/net_util.h"
32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
33 #include "net/base/url_constants.h"
33 #include "net/http/http_response_headers.h" 34 #include "net/http/http_response_headers.h"
34 #include "net/url_request/url_fetcher_delegate.h" 35 #include "net/url_request/url_fetcher_delegate.h"
35 #include "url/gurl.h" 36 #include "url/gurl.h"
36 37
37 namespace { 38 namespace {
38 39
39 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { 40 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) {
40 if (type == "ENTITY") 41 if (type == "ENTITY")
41 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY; 42 return AutocompleteMatchType::SEARCH_SUGGEST_ENTITY;
42 if (type == "INFINITE") 43 if (type == "INFINITE")
(...skipping 492 matching lines...) Expand 10 before | Expand all | Expand 10 after
535 bool BaseSearchProvider::ZeroSuggestEnabled( 536 bool BaseSearchProvider::ZeroSuggestEnabled(
536 const GURL& suggest_url, 537 const GURL& suggest_url,
537 const TemplateURL* template_url, 538 const TemplateURL* template_url,
538 AutocompleteInput::PageClassification page_classification, 539 AutocompleteInput::PageClassification page_classification,
539 Profile* profile) { 540 Profile* profile) {
540 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial()) 541 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial())
541 return false; 542 return false;
542 543
543 // Make sure we are sending the suggest request through HTTPS to prevent 544 // Make sure we are sending the suggest request through HTTPS to prevent
544 // exposing the current page URL or personalized results without encryption. 545 // exposing the current page URL or personalized results without encryption.
545 if (!suggest_url.SchemeIs(content::kHttpsScheme)) 546 if (!suggest_url.SchemeIs(net::kHttpsScheme))
546 return false; 547 return false;
547 548
548 // Don't show zero suggest on the NTP. 549 // Don't show zero suggest on the NTP.
549 // TODO(hfung): Experiment with showing MostVisited zero suggest on NTP 550 // TODO(hfung): Experiment with showing MostVisited zero suggest on NTP
550 // under the conditions described in crbug.com/305366. 551 // under the conditions described in crbug.com/305366.
551 if ((page_classification == 552 if ((page_classification ==
552 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) || 553 AutocompleteInput::INSTANT_NTP_WITH_FAKEBOX_AS_STARTING_FOCUS) ||
553 (page_classification == 554 (page_classification ==
554 AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS)) 555 AutocompleteInput::INSTANT_NTP_WITH_OMNIBOX_AS_STARTING_FOCUS))
555 return false; 556 return false;
(...skipping 26 matching lines...) Expand all
582 Profile* profile) { 583 Profile* profile) {
583 if (!ZeroSuggestEnabled(suggest_url, template_url, page_classification, 584 if (!ZeroSuggestEnabled(suggest_url, template_url, page_classification,
584 profile)) 585 profile))
585 return false; 586 return false;
586 587
587 if (!current_page_url.is_valid()) 588 if (!current_page_url.is_valid())
588 return false; 589 return false;
589 590
590 // Only allow HTTP URLs or HTTPS URLs for the same domain as the search 591 // Only allow HTTP URLs or HTTPS URLs for the same domain as the search
591 // provider. 592 // provider.
592 if ((current_page_url.scheme() != content::kHttpScheme) && 593 if ((current_page_url.scheme() != net::kHttpScheme) &&
593 ((current_page_url.scheme() != content::kHttpsScheme) || 594 ((current_page_url.scheme() != net::kHttpsScheme) ||
594 !net::registry_controlled_domains::SameDomainOrHost( 595 !net::registry_controlled_domains::SameDomainOrHost(
595 current_page_url, suggest_url, 596 current_page_url,
597 suggest_url,
596 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))) 598 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES)))
597 return false; 599 return false;
598 600
599 // Check field trials and settings allow sending the URL on suggest requests. 601 // Check field trials and settings allow sending the URL on suggest requests.
600 ProfileSyncService* service = 602 ProfileSyncService* service =
601 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 603 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
602 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); 604 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs());
603 if (service == NULL || 605 if (service == NULL ||
604 !service->IsSyncEnabledAndLoggedIn() || 606 !service->IsSyncEnabledAndLoggedIn() ||
605 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( 607 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has(
(...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
898 } 900 }
899 901
900 void BaseSearchProvider::OnDeletionComplete( 902 void BaseSearchProvider::OnDeletionComplete(
901 bool success, SuggestionDeletionHandler* handler) { 903 bool success, SuggestionDeletionHandler* handler) {
902 RecordDeletionResult(success); 904 RecordDeletionResult(success);
903 SuggestionDeletionHandlers::iterator it = std::find( 905 SuggestionDeletionHandlers::iterator it = std::find(
904 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 906 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
905 DCHECK(it != deletion_handlers_.end()); 907 DCHECK(it != deletion_handlers_.end());
906 deletion_handlers_.erase(it); 908 deletion_handlers_.erase(it);
907 } 909 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698