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

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

Issue 12084076: Ensure post-sync TemplateURL of prepopulated engines use built-in version. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change according to pkasting comments. Created 7 years, 10 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 (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"
11 #include "base/synchronization/waitable_event.h" 11 #include "base/synchronization/waitable_event.h"
12 #include "base/threading/thread.h" 12 #include "base/threading/thread.h"
13 #include "chrome/browser/google/google_url_tracker.h" 13 #include "chrome/browser/google/google_url_tracker.h"
14 #include "chrome/browser/search_engines/search_terms_data.h" 14 #include "chrome/browser/search_engines/search_terms_data.h"
15 #include "chrome/browser/search_engines/template_url_service.h" 15 #include "chrome/browser/search_engines/template_url_service.h"
16 #include "chrome/browser/search_engines/template_url_service_factory.h" 16 #include "chrome/browser/search_engines/template_url_service_factory.h"
17 #include "chrome/browser/webdata/web_data_service_factory.h" 17 #include "chrome/browser/webdata/web_data_service_factory.h"
18 #include "chrome/common/chrome_notification_types.h" 18 #include "chrome/common/chrome_notification_types.h"
19 #include "chrome/common/pref_names.h" 19 #include "chrome/common/pref_names.h"
20 #include "chrome/test/automation/value_conversion_util.h"
20 #include "chrome/test/base/testing_pref_service.h" 21 #include "chrome/test/base/testing_pref_service.h"
21 #include "chrome/test/base/testing_profile.h" 22 #include "chrome/test/base/testing_profile.h"
22 #include "content/public/browser/notification_service.h" 23 #include "content/public/browser/notification_service.h"
23 #include "content/public/test/test_browser_thread.h" 24 #include "content/public/test/test_browser_thread.h"
24 #include "testing/gtest/include/gtest/gtest.h" 25 #include "testing/gtest/include/gtest/gtest.h"
25 26
27
26 #if defined(OS_CHROMEOS) 28 #if defined(OS_CHROMEOS)
27 #include "chrome/browser/google/google_util_chromeos.h" 29 #include "chrome/browser/google/google_util_chromeos.h"
28 #endif 30 #endif
29 31
30 using content::BrowserThread; 32 using content::BrowserThread;
31 33
32 namespace { 34 namespace {
33 35
34 // A callback used to coordinate when the database has finished processing 36 // A callback used to coordinate when the database has finished processing
35 // requests. See note in BlockTillServiceProcessesRequests for details. 37 // requests. See note in BlockTillServiceProcessesRequests for details.
(...skipping 227 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 content::Details<GoogleURLTracker::UpdatedDetails>(&urls)); 265 content::Details<GoogleURLTracker::UpdatedDetails>(&urls));
264 } 266 }
265 267
266 void TemplateURLServiceTestUtil::SetManagedDefaultSearchPreferences( 268 void TemplateURLServiceTestUtil::SetManagedDefaultSearchPreferences(
267 bool enabled, 269 bool enabled,
268 const std::string& name, 270 const std::string& name,
269 const std::string& keyword, 271 const std::string& keyword,
270 const std::string& search_url, 272 const std::string& search_url,
271 const std::string& suggest_url, 273 const std::string& suggest_url,
272 const std::string& icon_url, 274 const std::string& icon_url,
273 const std::string& encodings) { 275 const std::string& encodings,
276 const std::string& alternate_url,
277 const std::string& search_terms_replacement_key) {
274 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService(); 278 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService();
275 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEnabled, 279 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEnabled,
276 Value::CreateBooleanValue(enabled)); 280 Value::CreateBooleanValue(enabled));
277 pref_service->SetManagedPref(prefs::kDefaultSearchProviderName, 281 pref_service->SetManagedPref(prefs::kDefaultSearchProviderName,
278 Value::CreateStringValue(name)); 282 Value::CreateStringValue(name));
279 pref_service->SetManagedPref(prefs::kDefaultSearchProviderKeyword, 283 pref_service->SetManagedPref(prefs::kDefaultSearchProviderKeyword,
280 Value::CreateStringValue(keyword)); 284 Value::CreateStringValue(keyword));
281 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL, 285 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSearchURL,
282 Value::CreateStringValue(search_url)); 286 Value::CreateStringValue(search_url));
283 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSuggestURL, 287 pref_service->SetManagedPref(prefs::kDefaultSearchProviderSuggestURL,
284 Value::CreateStringValue(suggest_url)); 288 Value::CreateStringValue(suggest_url));
285 pref_service->SetManagedPref(prefs::kDefaultSearchProviderIconURL, 289 pref_service->SetManagedPref(prefs::kDefaultSearchProviderIconURL,
286 Value::CreateStringValue(icon_url)); 290 Value::CreateStringValue(icon_url));
287 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEncodings, 291 pref_service->SetManagedPref(prefs::kDefaultSearchProviderEncodings,
288 Value::CreateStringValue(encodings)); 292 Value::CreateStringValue(encodings));
293 pref_service->SetManagedPref(prefs::kDefaultSearchProviderAlternateURLs,
294 alternate_url.empty() ? new base::ListValue() :
295 CreateListValueFrom(alternate_url));
296 pref_service->SetManagedPref(
297 prefs::kDefaultSearchProviderSearchTermsReplacementKey,
298 Value::CreateStringValue(search_terms_replacement_key));
289 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, 299 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED,
290 content::NotificationService::AllSources(), 300 content::NotificationService::AllSources(),
291 content::NotificationService::NoDetails()); 301 content::NotificationService::NoDetails());
292 } 302 }
293 303
294 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() { 304 void TemplateURLServiceTestUtil::RemoveManagedDefaultSearchPreferences() {
295 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService(); 305 TestingPrefServiceSyncable* pref_service = profile_->GetTestingPrefService();
296 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEnabled); 306 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEnabled);
297 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderName); 307 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderName);
298 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderKeyword); 308 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderKeyword);
299 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSearchURL); 309 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSearchURL);
300 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSuggestURL); 310 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderSuggestURL);
301 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderIconURL); 311 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderIconURL);
302 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEncodings); 312 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderEncodings);
313 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderAlternateURLs);
314 pref_service->RemoveManagedPref(
315 prefs::kDefaultSearchProviderSearchTermsReplacementKey);
303 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderID); 316 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderID);
304 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderPrepopulateID); 317 pref_service->RemoveManagedPref(prefs::kDefaultSearchProviderPrepopulateID);
305 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED, 318 model()->Observe(chrome::NOTIFICATION_DEFAULT_SEARCH_POLICY_CHANGED,
306 content::NotificationService::AllSources(), 319 content::NotificationService::AllSources(),
307 content::NotificationService::NoDetails()); 320 content::NotificationService::NoDetails());
308 } 321 }
309 322
310 TemplateURLService* TemplateURLServiceTestUtil::model() const { 323 TemplateURLService* TemplateURLServiceTestUtil::model() const {
311 return TemplateURLServiceFactory::GetForProfile(profile_.get()); 324 return TemplateURLServiceFactory::GetForProfile(profile_.get());
312 } 325 }
313 326
314 TestingProfile* TemplateURLServiceTestUtil::profile() const { 327 TestingProfile* TemplateURLServiceTestUtil::profile() const {
315 return profile_.get(); 328 return profile_.get();
316 } 329 }
317 330
318 void TemplateURLServiceTestUtil::StartIOThread() { 331 void TemplateURLServiceTestUtil::StartIOThread() {
319 profile_->StartIOThread(); 332 profile_->StartIOThread();
320 } 333 }
321 334
322 void TemplateURLServiceTestUtil::PumpLoop() { 335 void TemplateURLServiceTestUtil::PumpLoop() {
323 message_loop_.RunUntilIdle(); 336 message_loop_.RunUntilIdle();
324 } 337 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698