| 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 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 return false; | 313 return false; |
| 315 | 314 |
| 316 // Don't run if we can't get preferences or search suggest is not enabled. | 315 // Don't run if we can't get preferences or search suggest is not enabled. |
| 317 if (!client->SearchSuggestEnabled()) | 316 if (!client->SearchSuggestEnabled()) |
| 318 return false; | 317 return false; |
| 319 | 318 |
| 320 // Only make the request if we know that the provider supports zero suggest | 319 // Only make the request if we know that the provider supports zero suggest |
| 321 // (currently only the prepopulated Google provider). | 320 // (currently only the prepopulated Google provider). |
| 322 if (template_url == NULL || | 321 if (template_url == NULL || |
| 323 !template_url->SupportsReplacement(search_terms_data) || | 322 !template_url->SupportsReplacement(search_terms_data) || |
| 324 TemplateURLPrepopulateData::GetEngineType( | 323 template_url->GetEngineType(search_terms_data) != SEARCH_ENGINE_GOOGLE) |
| 325 *template_url, search_terms_data) != SEARCH_ENGINE_GOOGLE) | |
| 326 return false; | 324 return false; |
| 327 | 325 |
| 328 return true; | 326 return true; |
| 329 } | 327 } |
| 330 | 328 |
| 331 // static | 329 // static |
| 332 bool BaseSearchProvider::CanSendURL( | 330 bool BaseSearchProvider::CanSendURL( |
| 333 const GURL& current_page_url, | 331 const GURL& current_page_url, |
| 334 const GURL& suggest_url, | 332 const GURL& suggest_url, |
| 335 const TemplateURL* template_url, | 333 const TemplateURL* template_url, |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 481 | 479 |
| 482 void BaseSearchProvider::OnDeletionComplete( | 480 void BaseSearchProvider::OnDeletionComplete( |
| 483 bool success, SuggestionDeletionHandler* handler) { | 481 bool success, SuggestionDeletionHandler* handler) { |
| 484 RecordDeletionResult(success); | 482 RecordDeletionResult(success); |
| 485 deletion_handlers_.erase(std::remove_if( | 483 deletion_handlers_.erase(std::remove_if( |
| 486 deletion_handlers_.begin(), deletion_handlers_.end(), | 484 deletion_handlers_.begin(), deletion_handlers_.end(), |
| 487 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { | 485 [handler](const std::unique_ptr<SuggestionDeletionHandler>& elem) { |
| 488 return elem.get() == handler; | 486 return elem.get() == handler; |
| 489 })); | 487 })); |
| 490 } | 488 } |
| OLD | NEW |