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

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

Issue 195873020: [Sync] Move SyncPrefs into sync_driver component (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 | Annotate | Revision Log
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/json/json_string_value_serializer.h" 8 #include "base/json/json_string_value_serializer.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h" 12 #include "chrome/browser/autocomplete/autocomplete_provider_listener.h"
13 #include "chrome/browser/autocomplete/url_prefix.h" 13 #include "chrome/browser/autocomplete/url_prefix.h"
14 #include "chrome/browser/history/history_service.h" 14 #include "chrome/browser/history/history_service.h"
15 #include "chrome/browser/history/history_service_factory.h" 15 #include "chrome/browser/history/history_service_factory.h"
16 #include "chrome/browser/omnibox/omnibox_field_trial.h" 16 #include "chrome/browser/omnibox/omnibox_field_trial.h"
17 #include "chrome/browser/profiles/profile.h" 17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/search/instant_service.h" 18 #include "chrome/browser/search/instant_service.h"
19 #include "chrome/browser/search/instant_service_factory.h" 19 #include "chrome/browser/search/instant_service_factory.h"
20 #include "chrome/browser/search/search.h" 20 #include "chrome/browser/search/search.h"
21 #include "chrome/browser/search_engines/template_url.h" 21 #include "chrome/browser/search_engines/template_url.h"
22 #include "chrome/browser/search_engines/template_url_prepopulate_data.h" 22 #include "chrome/browser/search_engines/template_url_prepopulate_data.h"
23 #include "chrome/browser/sync/profile_sync_service.h" 23 #include "chrome/browser/sync/profile_sync_service.h"
24 #include "chrome/browser/sync/profile_sync_service_factory.h" 24 #include "chrome/browser/sync/profile_sync_service_factory.h"
25 #include "chrome/common/net/url_fixer_upper.h" 25 #include "chrome/common/net/url_fixer_upper.h"
26 #include "chrome/common/pref_names.h" 26 #include "chrome/common/pref_names.h"
27 #include "components/sync_driver/sync_prefs.h"
27 #include "content/public/common/url_constants.h" 28 #include "content/public/common/url_constants.h"
28 #include "net/base/escape.h" 29 #include "net/base/escape.h"
29 #include "net/base/net_util.h" 30 #include "net/base/net_util.h"
30 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 31 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
31 #include "net/url_request/url_fetcher_delegate.h" 32 #include "net/url_request/url_fetcher_delegate.h"
32 #include "url/gurl.h" 33 #include "url/gurl.h"
33 34
34 namespace { 35 namespace {
35 36
36 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) { 37 AutocompleteMatchType::Type GetAutocompleteMatchType(const std::string& type) {
(...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 // Only make the request if we know that the provider supports zero suggest 551 // Only make the request if we know that the provider supports zero suggest
551 // (currently only the prepopulated Google provider). 552 // (currently only the prepopulated Google provider).
552 if (template_url == NULL || !template_url->SupportsReplacement() || 553 if (template_url == NULL || !template_url->SupportsReplacement() ||
553 TemplateURLPrepopulateData::GetEngineType(*template_url) != 554 TemplateURLPrepopulateData::GetEngineType(*template_url) !=
554 SEARCH_ENGINE_GOOGLE) 555 SEARCH_ENGINE_GOOGLE)
555 return false; 556 return false;
556 557
557 // Check field trials and settings allow sending the URL on suggest requests. 558 // Check field trials and settings allow sending the URL on suggest requests.
558 ProfileSyncService* service = 559 ProfileSyncService* service =
559 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile); 560 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile);
560 browser_sync::SyncPrefs sync_prefs(prefs); 561 sync_driver::SyncPrefs sync_prefs(prefs);
561 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() || 562 if (!OmniboxFieldTrial::InZeroSuggestFieldTrial() ||
562 service == NULL || 563 service == NULL ||
563 !service->IsSyncEnabledAndLoggedIn() || 564 !service->IsSyncEnabledAndLoggedIn() ||
564 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( 565 !sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has(
565 syncer::PROXY_TABS) || 566 syncer::PROXY_TABS) ||
566 service->GetEncryptedDataTypes().Has(syncer::SESSIONS)) 567 service->GetEncryptedDataTypes().Has(syncer::SESSIONS))
567 return false; 568 return false;
568 569
569 return true; 570 return true;
570 } 571 }
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
802 } 803 }
803 804
804 void BaseSearchProvider::OnDeletionComplete( 805 void BaseSearchProvider::OnDeletionComplete(
805 bool success, SuggestionDeletionHandler* handler) { 806 bool success, SuggestionDeletionHandler* handler) {
806 RecordDeletionResult(success); 807 RecordDeletionResult(success);
807 SuggestionDeletionHandlers::iterator it = std::find( 808 SuggestionDeletionHandlers::iterator it = std::find(
808 deletion_handlers_.begin(), deletion_handlers_.end(), handler); 809 deletion_handlers_.begin(), deletion_handlers_.end(), handler);
809 DCHECK(it != deletion_handlers_.end()); 810 DCHECK(it != deletion_handlers_.end());
810 deletion_handlers_.erase(it); 811 deletion_handlers_.erase(it);
811 } 812 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698