| 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/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
| 11 #include "base/prefs/pref_registry_simple.h" | 11 #include "base/prefs/pref_registry_simple.h" |
| 12 #include "base/prefs/pref_service.h" | 12 #include "base/prefs/pref_service.h" |
| 13 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 14 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 15 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
| 16 #include "chrome/browser/autocomplete/url_prefix.h" | 16 #include "chrome/browser/autocomplete/url_prefix.h" |
| 17 #include "chrome/browser/history/history_service.h" | 17 #include "chrome/browser/history/history_service.h" |
| 18 #include "chrome/browser/history/history_service_factory.h" | 18 #include "chrome/browser/history/history_service_factory.h" |
| 19 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 19 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
| 20 #include "chrome/browser/profiles/profile.h" | 20 #include "chrome/browser/profiles/profile.h" |
| 21 #include "chrome/browser/search/instant_service.h" | 21 #include "chrome/browser/search/instant_service.h" |
| 22 #include "chrome/browser/search/instant_service_factory.h" | 22 #include "chrome/browser/search/instant_service_factory.h" |
| 23 #include "chrome/browser/search/search.h" | 23 #include "chrome/browser/search/search.h" |
| 24 #include "chrome/browser/search_engines/template_url.h" | 24 #include "chrome/browser/search_engines/template_url.h" |
| 25 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" | 25 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" |
| 26 #include "chrome/browser/search_engines/template_url_service.h" | 26 #include "chrome/browser/search_engines/template_url_service.h" |
| 27 #include "chrome/browser/search_engines/template_url_service_factory.h" | 27 #include "chrome/browser/search_engines/template_url_service_factory.h" |
| 28 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
| 29 #include "chrome/browser/sync/profile_sync_service_factory.h" | 29 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 30 #include "chrome/common/net/url_fixer_upper.h" | |
| 31 #include "chrome/common/pref_names.h" | 30 #include "chrome/common/pref_names.h" |
| 32 #include "components/metrics/proto/omnibox_input_type.pb.h" | 31 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 33 #include "components/sync_driver/sync_prefs.h" | 32 #include "components/sync_driver/sync_prefs.h" |
| 33 #include "components/url_fixer/url_fixer.h" |
| 34 #include "content/public/common/url_constants.h" | 34 #include "content/public/common/url_constants.h" |
| 35 #include "net/base/escape.h" | 35 #include "net/base/escape.h" |
| 36 #include "net/base/net_util.h" | 36 #include "net/base/net_util.h" |
| 37 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 37 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 38 #include "net/http/http_response_headers.h" | 38 #include "net/http/http_response_headers.h" |
| 39 #include "net/url_request/url_fetcher.h" | 39 #include "net/url_request/url_fetcher.h" |
| 40 #include "net/url_request/url_fetcher_delegate.h" | 40 #include "net/url_request/url_fetcher_delegate.h" |
| 41 #include "url/gurl.h" | 41 #include "url/gurl.h" |
| 42 | 42 |
| 43 namespace { | 43 namespace { |
| (...skipping 832 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 876 const base::DictionaryValue* suggestion_detail = NULL; | 876 const base::DictionaryValue* suggestion_detail = NULL; |
| 877 std::string deletion_url; | 877 std::string deletion_url; |
| 878 | 878 |
| 879 if (suggestion_details && | 879 if (suggestion_details && |
| 880 suggestion_details->GetDictionary(index, &suggestion_detail)) | 880 suggestion_details->GetDictionary(index, &suggestion_detail)) |
| 881 suggestion_detail->GetString("du", &deletion_url); | 881 suggestion_detail->GetString("du", &deletion_url); |
| 882 | 882 |
| 883 if ((match_type == AutocompleteMatchType::NAVSUGGEST) || | 883 if ((match_type == AutocompleteMatchType::NAVSUGGEST) || |
| 884 (match_type == AutocompleteMatchType::NAVSUGGEST_PERSONALIZED)) { | 884 (match_type == AutocompleteMatchType::NAVSUGGEST_PERSONALIZED)) { |
| 885 // Do not blindly trust the URL coming from the server to be valid. | 885 // Do not blindly trust the URL coming from the server to be valid. |
| 886 GURL url(URLFixerUpper::FixupURL( | 886 GURL url( |
| 887 base::UTF16ToUTF8(suggestion), std::string())); | 887 url_fixer::FixupURL(base::UTF16ToUTF8(suggestion), std::string())); |
| 888 if (url.is_valid() && allow_navsuggest) { | 888 if (url.is_valid() && allow_navsuggest) { |
| 889 base::string16 title; | 889 base::string16 title; |
| 890 if (descriptions != NULL) | 890 if (descriptions != NULL) |
| 891 descriptions->GetString(index, &title); | 891 descriptions->GetString(index, &title); |
| 892 results->navigation_results.push_back(NavigationResult( | 892 results->navigation_results.push_back(NavigationResult( |
| 893 *this, url, match_type, title, deletion_url, is_keyword_result, | 893 *this, url, match_type, title, deletion_url, is_keyword_result, |
| 894 relevance, relevances != NULL, input.text(), languages)); | 894 relevance, relevances != NULL, input.text(), languages)); |
| 895 } | 895 } |
| 896 } else { | 896 } else { |
| 897 base::string16 match_contents = suggestion; | 897 base::string16 match_contents = suggestion; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 968 } | 968 } |
| 969 | 969 |
| 970 void BaseSearchProvider::OnDeletionComplete( | 970 void BaseSearchProvider::OnDeletionComplete( |
| 971 bool success, SuggestionDeletionHandler* handler) { | 971 bool success, SuggestionDeletionHandler* handler) { |
| 972 RecordDeletionResult(success); | 972 RecordDeletionResult(success); |
| 973 SuggestionDeletionHandlers::iterator it = std::find( | 973 SuggestionDeletionHandlers::iterator it = std::find( |
| 974 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 974 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
| 975 DCHECK(it != deletion_handlers_.end()); | 975 DCHECK(it != deletion_handlers_.end()); |
| 976 deletion_handlers_.erase(it); | 976 deletion_handlers_.erase(it); |
| 977 } | 977 } |
| OLD | NEW |