| 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 "components/omnibox/browser/base_search_provider.h" | 5 #include "components/omnibox/browser/base_search_provider.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/i18n/case_conversion.h" | 10 #include "base/i18n/case_conversion.h" |
| 11 #include "base/macros.h" | 11 #include "base/macros.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.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 "components/data_use_measurement/core/data_use_user_data.h" | 15 #include "components/data_use_measurement/core/data_use_user_data.h" |
| 16 #include "components/metrics/proto/omnibox_event.pb.h" | 16 #include "components/metrics/proto/omnibox_event.pb.h" |
| 17 #include "components/metrics/proto/omnibox_input_type.pb.h" | 17 #include "components/metrics/proto/omnibox_input_type.pb.h" |
| 18 #include "components/omnibox/browser/autocomplete_provider_client.h" | 18 #include "components/omnibox/browser/autocomplete_provider_client.h" |
| 19 #include "components/omnibox/browser/autocomplete_provider_listener.h" | 19 #include "components/omnibox/browser/autocomplete_provider_listener.h" |
| 20 #include "components/omnibox/browser/omnibox_field_trial.h" | 20 #include "components/omnibox/browser/omnibox_field_trial.h" |
| 21 #include "components/omnibox/browser/suggestion_answer.h" | 21 #include "components/omnibox/browser/suggestion_answer.h" |
| 22 #include "components/search_engines/template_url.h" | 22 #include "components/search_engines/template_url.h" |
| 23 #include "components/search_engines/template_url_prepopulate_data.h" | |
| 24 #include "components/search_engines/template_url_service.h" | 23 #include "components/search_engines/template_url_service.h" |
| 25 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 24 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
| 26 #include "net/url_request/url_fetcher.h" | 25 #include "net/url_request/url_fetcher.h" |
| 27 #include "net/url_request/url_fetcher_delegate.h" | 26 #include "net/url_request/url_fetcher_delegate.h" |
| 28 #include "url/gurl.h" | 27 #include "url/gurl.h" |
| 29 | 28 |
| 30 using metrics::OmniboxEventProto; | 29 using metrics::OmniboxEventProto; |
| 31 | 30 |
| 32 // SuggestionDeletionHandler ------------------------------------------------- | 31 // SuggestionDeletionHandler ------------------------------------------------- |
| 33 | 32 |
| (...skipping 276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 310 return false; | 309 return false; |
| 311 | 310 |
| 312 // Don't run if we can't get preferences or search suggest is not enabled. | 311 // Don't run if we can't get preferences or search suggest is not enabled. |
| 313 if (!client->SearchSuggestEnabled()) | 312 if (!client->SearchSuggestEnabled()) |
| 314 return false; | 313 return false; |
| 315 | 314 |
| 316 // Only make the request if we know that the provider supports zero suggest | 315 // Only make the request if we know that the provider supports zero suggest |
| 317 // (currently only the prepopulated Google provider). | 316 // (currently only the prepopulated Google provider). |
| 318 if (template_url == NULL || | 317 if (template_url == NULL || |
| 319 !template_url->SupportsReplacement(search_terms_data) || | 318 !template_url->SupportsReplacement(search_terms_data) || |
| 320 TemplateURLPrepopulateData::GetEngineType( | 319 template_url->GetEngineType(search_terms_data) != SEARCH_ENGINE_GOOGLE) |
| 321 *template_url, search_terms_data) != SEARCH_ENGINE_GOOGLE) | |
| 322 return false; | 320 return false; |
| 323 | 321 |
| 324 return true; | 322 return true; |
| 325 } | 323 } |
| 326 | 324 |
| 327 // static | 325 // static |
| 328 bool BaseSearchProvider::CanSendURL( | 326 bool BaseSearchProvider::CanSendURL( |
| 329 const GURL& current_page_url, | 327 const GURL& current_page_url, |
| 330 const GURL& suggest_url, | 328 const GURL& suggest_url, |
| 331 const TemplateURL* template_url, | 329 const TemplateURL* template_url, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 477 | 475 |
| 478 void BaseSearchProvider::OnDeletionComplete( | 476 void BaseSearchProvider::OnDeletionComplete( |
| 479 bool success, SuggestionDeletionHandler* handler) { | 477 bool success, SuggestionDeletionHandler* handler) { |
| 480 RecordDeletionResult(success); | 478 RecordDeletionResult(success); |
| 481 deletion_handlers_.erase(std::remove_if( | 479 deletion_handlers_.erase(std::remove_if( |
| 482 deletion_handlers_.begin(), deletion_handlers_.end(), | 480 deletion_handlers_.begin(), deletion_handlers_.end(), |
| 483 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { | 481 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { |
| 484 return elem.get() == handler; | 482 return elem.get() == handler; |
| 485 })); | 483 })); |
| 486 } | 484 } |
| OLD | NEW |