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

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

Issue 510783002: Rename AutocompleteProviderDelegate to AutocompleteProviderClient (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 3 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
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/chrome_autocomplete_provider_delegate.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"
11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h" 11 #include "chrome/browser/bitmap_fetcher/bitmap_fetcher_service_factory.h"
12 #include "chrome/browser/history/history_service.h" 12 #include "chrome/browser/history/history_service.h"
13 #include "chrome/browser/history/history_service_factory.h" 13 #include "chrome/browser/history/history_service_factory.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 15 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 16 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 18
19 ChromeAutocompleteProviderDelegate::ChromeAutocompleteProviderDelegate( 19 ChromeAutocompleteProviderClient::ChromeAutocompleteProviderClient(
20 Profile* profile) 20 Profile* profile)
21 : profile_(profile), 21 : profile_(profile),
22 scheme_classifier_(profile) { 22 scheme_classifier_(profile) {
23 } 23 }
24 24
25 ChromeAutocompleteProviderDelegate::~ChromeAutocompleteProviderDelegate() { 25 ChromeAutocompleteProviderClient::~ChromeAutocompleteProviderClient() {
26 } 26 }
27 27
28 net::URLRequestContextGetter* 28 net::URLRequestContextGetter*
29 ChromeAutocompleteProviderDelegate::RequestContext() { 29 ChromeAutocompleteProviderClient::RequestContext() {
30 return profile_->GetRequestContext(); 30 return profile_->GetRequestContext();
31 } 31 }
32 32
33 bool ChromeAutocompleteProviderDelegate::IsOffTheRecord() { 33 bool ChromeAutocompleteProviderClient::IsOffTheRecord() {
34 return profile_->IsOffTheRecord(); 34 return profile_->IsOffTheRecord();
35 } 35 }
36 36
37 std::string ChromeAutocompleteProviderDelegate::AcceptLanguages() { 37 std::string ChromeAutocompleteProviderClient::AcceptLanguages() {
38 return profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); 38 return profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
39 } 39 }
40 40
41 bool ChromeAutocompleteProviderDelegate::SearchSuggestEnabled() { 41 bool ChromeAutocompleteProviderClient::SearchSuggestEnabled() {
42 return profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled); 42 return profile_->GetPrefs()->GetBoolean(prefs::kSearchSuggestEnabled);
43 } 43 }
44 44
45 bool ChromeAutocompleteProviderDelegate::ShowBookmarkBar() { 45 bool ChromeAutocompleteProviderClient::ShowBookmarkBar() {
46 return profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar); 46 return profile_->GetPrefs()->GetBoolean(bookmarks::prefs::kShowBookmarkBar);
47 } 47 }
48 48
49 const AutocompleteSchemeClassifier& 49 const AutocompleteSchemeClassifier&
50 ChromeAutocompleteProviderDelegate::SchemeClassifier() { 50 ChromeAutocompleteProviderClient::SchemeClassifier() {
51 return scheme_classifier_; 51 return scheme_classifier_;
52 } 52 }
53 53
54 void ChromeAutocompleteProviderDelegate::Classify( 54 void ChromeAutocompleteProviderClient::Classify(
55 const base::string16& text, 55 const base::string16& text,
56 bool prefer_keyword, 56 bool prefer_keyword,
57 bool allow_exact_keyword_match, 57 bool allow_exact_keyword_match,
58 metrics::OmniboxEventProto::PageClassification page_classification, 58 metrics::OmniboxEventProto::PageClassification page_classification,
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* ChromeAutocompleteProviderDelegate::InMemoryDatabase() { 68 history::URLDatabase* ChromeAutocompleteProviderClient::InMemoryDatabase() {
69 HistoryService* history_service = 69 HistoryService* history_service =
70 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS); 70 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS);
71 return history_service ? history_service->InMemoryDatabase() : NULL; 71 return history_service ? history_service->InMemoryDatabase() : NULL;
72 } 72 }
73 73
74 void 74 void ChromeAutocompleteProviderClient::DeleteMatchingURLsForKeywordFromHistory(
75 ChromeAutocompleteProviderDelegate::DeleteMatchingURLsForKeywordFromHistory(
76 history::KeywordID keyword_id, 75 history::KeywordID keyword_id,
77 const base::string16& term) { 76 const base::string16& term) {
78 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS) 77 HistoryServiceFactory::GetForProfile(profile_, Profile::EXPLICIT_ACCESS)
79 ->DeleteMatchingURLsForKeyword(keyword_id, term); 78 ->DeleteMatchingURLsForKeyword(keyword_id, term);
80 } 79 }
81 80
82 bool ChromeAutocompleteProviderDelegate::TabSyncEnabledAndUnencrypted() { 81 bool ChromeAutocompleteProviderClient::TabSyncEnabledAndUnencrypted() {
83 // Check field trials and settings allow sending the URL on suggest requests. 82 // Check field trials and settings allow sending the URL on suggest requests.
84 ProfileSyncService* service = 83 ProfileSyncService* service =
85 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_); 84 ProfileSyncServiceFactory::GetInstance()->GetForProfile(profile_);
86 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs()); 85 sync_driver::SyncPrefs sync_prefs(profile_->GetPrefs());
87 return service && 86 return service &&
88 service->IsSyncEnabledAndLoggedIn() && 87 service->IsSyncEnabledAndLoggedIn() &&
89 sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has( 88 sync_prefs.GetPreferredDataTypes(syncer::UserTypes()).Has(
90 syncer::PROXY_TABS) && 89 syncer::PROXY_TABS) &&
91 !service->GetEncryptedDataTypes().Has(syncer::SESSIONS); 90 !service->GetEncryptedDataTypes().Has(syncer::SESSIONS);
92 } 91 }
93 92
94 void ChromeAutocompleteProviderDelegate::PrefetchImage(const GURL& url) { 93 void ChromeAutocompleteProviderClient::PrefetchImage(const GURL& url) {
95 BitmapFetcherService* image_service = 94 BitmapFetcherService* image_service =
96 BitmapFetcherServiceFactory::GetForBrowserContext(profile_); 95 BitmapFetcherServiceFactory::GetForBrowserContext(profile_);
97 DCHECK(image_service); 96 DCHECK(image_service);
98 image_service->Prefetch(url); 97 image_service->Prefetch(url);
99 } 98 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698