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" |
11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" | 13 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" |
14 #include "chrome/browser/autocomplete/url_prefix.h" | 14 #include "chrome/browser/autocomplete/url_prefix.h" |
15 #include "chrome/browser/history/history_service.h" | 15 #include "chrome/browser/history/history_service.h" |
16 #include "chrome/browser/history/history_service_factory.h" | 16 #include "chrome/browser/history/history_service_factory.h" |
17 #include "chrome/browser/omnibox/omnibox_field_trial.h" | 17 #include "chrome/browser/omnibox/omnibox_field_trial.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/search/instant_service.h" | 19 #include "chrome/browser/search/instant_service.h" |
20 #include "chrome/browser/search/instant_service_factory.h" | 20 #include "chrome/browser/search/instant_service_factory.h" |
21 #include "chrome/browser/search/search.h" | 21 #include "chrome/browser/search/search.h" |
22 #include "chrome/browser/search_engines/template_url.h" | 22 #include "chrome/browser/search_engines/template_url.h" |
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 "content/public/common/url_constants.h" | 29 #include "content/public/common/url_constants.h" |
29 #include "net/base/escape.h" | 30 #include "net/base/escape.h" |
30 #include "net/base/net_util.h" | 31 #include "net/base/net_util.h" |
31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" | 32 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
32 #include "net/http/http_response_headers.h" | 33 #include "net/http/http_response_headers.h" |
33 #include "net/url_request/url_fetcher_delegate.h" | 34 #include "net/url_request/url_fetcher_delegate.h" |
34 #include "url/gurl.h" | 35 #include "url/gurl.h" |
35 | 36 |
36 namespace { | 37 namespace { |
37 | 38 |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
571 if ((current_page_url.scheme() != content::kHttpScheme) && | 572 if ((current_page_url.scheme() != content::kHttpScheme) && |
572 ((current_page_url.scheme() != content::kHttpsScheme) || | 573 ((current_page_url.scheme() != content::kHttpsScheme) || |
573 !net::registry_controlled_domains::SameDomainOrHost( | 574 !net::registry_controlled_domains::SameDomainOrHost( |
574 current_page_url, suggest_url, | 575 current_page_url, suggest_url, |
575 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))) | 576 net::registry_controlled_domains::EXCLUDE_PRIVATE_REGISTRIES))) |
576 return false; | 577 return false; |
577 | 578 |
578 // Check field trials and settings allow sending the URL on suggest requests. | 579 // Check field trials and settings allow sending the URL on suggest requests. |
579 ProfileSyncService* service = | 580 ProfileSyncService* service = |
580 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); | 581 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); |
581 browser_sync::SyncPrefs sync_prefs(profile->GetPrefs()); | 582 sync_driver::SyncPrefs sync_prefs(profile->GetPrefs()); |
582 if (service == NULL || | 583 if (service == NULL || |
583 !service->IsSyncEnabledAndLoggedIn() || | 584 !service->IsSyncEnabledAndLoggedIn() || |
584 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( | 585 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( |
585 syncer::PROXY_TABS) || | 586 syncer::PROXY_TABS) || |
586 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) | 587 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) |
587 return false; | 588 return false; |
588 | 589 |
589 return true; | 590 return true; |
590 } | 591 } |
591 | 592 |
(...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
872 } | 873 } |
873 | 874 |
874 void BaseSearchProvider::OnDeletionComplete( | 875 void BaseSearchProvider::OnDeletionComplete( |
875 bool success, SuggestionDeletionHandler* handler) { | 876 bool success, SuggestionDeletionHandler* handler) { |
876 RecordDeletionResult(success); | 877 RecordDeletionResult(success); |
877 SuggestionDeletionHandlers::iterator it = std::find( | 878 SuggestionDeletionHandlers::iterator it = std::find( |
878 deletion_handlers_.begin(), deletion_handlers_.end(), handler); | 879 deletion_handlers_.begin(), deletion_handlers_.end(), handler); |
879 DCHECK(it != deletion_handlers_.end()); | 880 DCHECK(it != deletion_handlers_.end()); |
880 deletion_handlers_.erase(it); | 881 deletion_handlers_.erase(it); |
881 } | 882 } |
OLD | NEW |