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

Side by Side Diff: chrome/browser/search_engines/default_search_manager.cc

Issue 268643002: Use the DefaultSearchManager as the exclusive authority on DSE, ignoring Web Data. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review comments. Created 6 years, 7 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/search_engines/default_search_manager.h" 5 #include "chrome/browser/search_engines/default_search_manager.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
92 } 92 }
93 93
94 DefaultSearchManager::~DefaultSearchManager() { 94 DefaultSearchManager::~DefaultSearchManager() {
95 } 95 }
96 96
97 // static 97 // static
98 void DefaultSearchManager::RegisterProfilePrefs( 98 void DefaultSearchManager::RegisterProfilePrefs(
99 user_prefs::PrefRegistrySyncable* registry) { 99 user_prefs::PrefRegistrySyncable* registry) {
100 registry->RegisterDictionaryPref( 100 registry->RegisterDictionaryPref(
101 kDefaultSearchProviderDataPrefName, 101 kDefaultSearchProviderDataPrefName,
102 user_prefs::PrefRegistrySyncable::SYNCABLE_PREF); 102 user_prefs::PrefRegistrySyncable::UNSYNCABLE_PREF);
103 } 103 }
104 104
105 // static 105 // static
106 void DefaultSearchManager::AddPrefValueToMap(base::DictionaryValue* value, 106 void DefaultSearchManager::AddPrefValueToMap(base::DictionaryValue* value,
107 PrefValueMap* pref_value_map) { 107 PrefValueMap* pref_value_map) {
108 pref_value_map->SetValue(kDefaultSearchProviderDataPrefName, value); 108 pref_value_map->SetValue(kDefaultSearchProviderDataPrefName, value);
109 } 109 }
110 110
111 TemplateURLData* DefaultSearchManager::GetDefaultSearchEngine( 111 TemplateURLData* DefaultSearchManager::GetDefaultSearchEngine(
112 Source* source) const { 112 Source* source) const {
113 if (default_search_controlled_by_policy_) { 113 if (default_search_controlled_by_policy_) {
114 if (source) 114 if (source)
115 *source = FROM_POLICY; 115 *source = FROM_POLICY;
116 return prefs_default_search_.get(); 116 return prefs_default_search_.get();
117 } 117 }
118 if (extension_default_search_) { 118 if (extension_default_search_) {
119 if (source) 119 if (source)
120 *source = FROM_EXTENSION; 120 *source = FROM_EXTENSION;
121 return extension_default_search_.get(); 121 return extension_default_search_.get();
122 } 122 }
123 if (prefs_default_search_) { 123 if (prefs_default_search_) {
124 if (source) 124 if (source)
125 *source = FROM_USER; 125 *source = FROM_USER;
126 return prefs_default_search_.get(); 126 return prefs_default_search_.get();
127 } 127 }
128 128
129 if (source) 129 if (source)
130 *source = FROM_FALLBACK; 130 *source = FROM_FALLBACK;
131 return fallback_default_search_.get(); 131 return TemplateURLService::FallbackSearchEnginesDisabled()
132 ? NULL
133 : fallback_default_search_.get();
Peter Kasting 2014/05/07 23:38:29 Nit: Please format as return TemplateURLService
erikwright (departed) 2014/05/08 12:46:24 Done.
132 } 134 }
133 135
134 DefaultSearchManager::Source 136 DefaultSearchManager::Source
135 DefaultSearchManager::GetDefaultSearchEngineSource() const { 137 DefaultSearchManager::GetDefaultSearchEngineSource() const {
136 Source source; 138 Source source;
137 GetDefaultSearchEngine(&source); 139 GetDefaultSearchEngine(&source);
138 return source; 140 return source;
139 } 141 }
140 142
141 void DefaultSearchManager::SetUserSelectedDefaultSearchEngine( 143 void DefaultSearchManager::SetUserSelectedDefaultSearchEngine(
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 MergePrefsDataWithPrepopulated(); 398 MergePrefsDataWithPrepopulated();
397 } 399 }
398 400
399 void DefaultSearchManager::NotifyObserver() { 401 void DefaultSearchManager::NotifyObserver() {
400 if (!change_observer_.is_null()) { 402 if (!change_observer_.is_null()) {
401 Source source = FROM_FALLBACK; 403 Source source = FROM_FALLBACK;
402 TemplateURLData* data = GetDefaultSearchEngine(&source); 404 TemplateURLData* data = GetDefaultSearchEngine(&source);
403 change_observer_.Run(data, source); 405 change_observer_.Run(data, source);
404 } 406 }
405 } 407 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698