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/chrome_autocomplete_provider_client.h" | 5 #include "chrome/browser/autocomplete/chrome_autocomplete_provider_client.h" |
6 | 6 |
7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 8 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" | 9 #include "chrome/browser/autocomplete/autocomplete_classifier_factory.h" |
10 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" | 10 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 AutocompleteMatch* match, | 59 AutocompleteMatch* match, |
60 GURL* alternate_nav_url) { | 60 GURL* alternate_nav_url) { |
61 AutocompleteClassifier* classifier = | 61 AutocompleteClassifier* classifier = |
62 AutocompleteClassifierFactory::GetForProfile(profile_); | 62 AutocompleteClassifierFactory::GetForProfile(profile_); |
63 DCHECK(classifier); | 63 DCHECK(classifier); |
64 classifier->Classify(text, prefer_keyword, allow_exact_keyword_match, | 64 classifier->Classify(text, prefer_keyword, allow_exact_keyword_match, |
65 page_classification, match, alternate_nav_url); | 65 page_classification, match, alternate_nav_url); |
66 } | 66 } |
67 | 67 |
68 history::URLDatabase* ChromeAutocompleteProviderClient::InMemoryDatabase() { | 68 history::URLDatabase* ChromeAutocompleteProviderClient::InMemoryDatabase() { |
69 HistoryService* history_service = | 69 HistoryService* history_service = HistoryServiceFactory::GetForProfile( |
70 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); | 70 profile_, ServiceAccessType::EXPLICIT_ACCESS); |
71 return history_service ? history_service->InMemoryDatabase() : NULL; | 71 return history_service ? history_service->InMemoryDatabase() : NULL; |
72 } | 72 } |
73 | 73 |
74 void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory( | 74 void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory( |
75 history::KeywordID keyword_id, | 75 history::KeywordID keyword_id, |
76 const base::string16& term) { | 76 const base::string16& term) { |
77 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS) | 77 HistoryServiceFactory::GetForProfile(profile_, |
| 78 ServiceAccessType::EXPLICIT_ACCESS) |
78 ->DeleteMatchingURLsForKeyword(keyword_id, term); | 79 ->DeleteMatchingURLsForKeyword(keyword_id, term); |
79 } | 80 } |
80 | 81 |
81 bool ChromeAutocompleteProviderClient::TabSyncEnabledAndUnencrypted() { | 82 bool ChromeAutocompleteProviderClient::TabSyncEnabledAndUnencrypted() { |
82 // Check field trials and settings allow sending the URL on suggest requests. | 83 // Check field trials and settings allow sending the URL on suggest requests. |
83 ProfileSyncService* service = | 84 ProfileSyncService* service = |
84 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); | 85 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); |
85 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); | 86 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); |
86 return service && | 87 return service && |
87 service->IsSyncEnabledAndLoggedIn() && | 88 service->IsSyncEnabledAndLoggedIn() && |
88 sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( | 89 sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( |
89 syncer::PROXY_TABS) && | 90 syncer::PROXY_TABS) && |
90 !service->GetEncryptedDataTypes().Has(syncer::SESSIONS); | 91 !service->GetEncryptedDataTypes().Has(syncer::SESSIONS); |
91 } | 92 } |
92 | 93 |
93 void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) { | 94 void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) { |
94 BitmapFetcherService* image_service = | 95 BitmapFetcherService* image_service = |
95 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); | 96 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); |
96 DCHECK(image_service); | 97 DCHECK(image_service); |
97 image_service->Prefetch(url); | 98 image_service->Prefetch(url); |
98 } | 99 } |
OLD | NEW |