OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/template_url_service_test_util.h" | 5 #include "chrome/browser/search_engines/template_url_service_test_util.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
264 } | 264 } |
265 | 265 |
266 void TemplateURLServiceTestUtil::SetManagedDefaultSearchPreferences( | 266 void TemplateURLServiceTestUtil::SetManagedDefaultSearchPreferences( |
267 bool enabled, | 267 bool enabled, |
268 const std::string& name, | 268 const std::string& name, |
269 const std::string& keyword, | 269 const std::string& keyword, |
270 const std::string& search_url, | 270 const std::string& search_url, |
271 const std::string& suggest_url, | 271 const std::string& suggest_url, |
272 const std::string& icon_url, | 272 const std::string& icon_url, |
273 const std::string& encodings) { | 273 const std::string& encodings) { |
274 TestingPrefService* pref_service = profile_->GetTestingPrefService(); | 274 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService(); |
275 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, | 275 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, |
276 Value::CreateBooleanValue(enabled)); | 276 Value::CreateBooleanValue(enabled)); |
277 pref_service->SetManagedPref(prefs::kDefaultSearchProviderName, | 277 pref_service->SetManagedPref(prefs::kDefaultSearchProviderName, |
278 Value::CreateStringValue(name)); | 278 Value::CreateStringValue(name)); |
279 pref_service->SetManagedPref(prefs::kDefaultSearchProviderKeyword, | 279 pref_service->SetManagedPref(prefs::kDefaultSearchProviderKeyword, |
280 Value::CreateStringValue(keyword)); | 280 Value::CreateStringValue(keyword)); |
281 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, | 281 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, |
282 Value::CreateStringValue(search_url)); | 282 Value::CreateStringValue(search_url)); |
283 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSuggestURL, | 283 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSuggestURL, |
284 Value::CreateStringValue(suggest_url)); | 284 Value::CreateStringValue(suggest_url)); |
285 pref_service->SetManagedPref(prefs::kDefaultSearchProviderIconURL, | 285 pref_service->SetManagedPref(prefs::kDefaultSearchProviderIconURL, |
286 Value::CreateStringValue(icon_url)); | 286 Value::CreateStringValue(icon_url)); |
287 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEncodings, | 287 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEncodings, |
288 Value::CreateStringValue(encodings)); | 288 Value::CreateStringValue(encodings)); |
289 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, | 289 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, |
290 content::NotificationService::AllSources(), | 290 content::NotificationService::AllSources(), |
291 content::NotificationService::NoDetails()); | 291 content::NotificationService::NoDetails()); |
292 } | 292 } |
293 | 293 |
294 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { | 294 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { |
295 TestingPrefService* pref_service = profile_->GetTestingPrefService(); | 295 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService(); |
296 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEnabled); | 296 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEnabled); |
297 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderName); | 297 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderName); |
298 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderKeyword); | 298 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderKeyword); |
299 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSearchURL); | 299 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSearchURL); |
300 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSuggestURL); | 300 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSuggestURL); |
301 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderIconURL); | 301 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderIconURL); |
302 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEncodings); | 302 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEncodings); |
303 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderID); | 303 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderID); |
304 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderPrepopulateID); | 304 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderPrepopulateID); |
305 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, | 305 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, |
306 content::NotificationService::AllSources(), | 306 content::NotificationService::AllSources(), |
307 content::NotificationService::NoDetails()); | 307 content::NotificationService::NoDetails()); |
308 } | 308 } |
309 | 309 |
310 TemplateURLService* TemplateURLServiceTestUtil::model() const { | 310 TemplateURLService* TemplateURLServiceTestUtil::model() const { |
311 return TemplateURLServiceFactory::GetForProfile(profile_.get()); | 311 return TemplateURLServiceFactory::GetForProfile(profile_.get()); |
312 } | 312 } |
313 | 313 |
314 TestingProfile* TemplateURLServiceTestUtil::profile() const { | 314 TestingProfile* TemplateURLServiceTestUtil::profile() const { |
315 return profile_.get(); | 315 return profile_.get(); |
316 } | 316 } |
317 | 317 |
318 void TemplateURLServiceTestUtil::StartIOThread() { | 318 void TemplateURLServiceTestUtil::StartIOThread() { |
319 profile_->StartIOThread(); | 319 profile_->StartIOThread(); |
320 } | 320 } |
321 | 321 |
322 void TemplateURLServiceTestUtil::PumpLoop() { | 322 void TemplateURLServiceTestUtil::PumpLoop() { |
323 message_loop_.RunUntilIdle(); | 323 message_loop_.RunUntilIdle(); |
324 } | 324 } |
OLD | NEW |