Don't preload rarely seen large images
[chromium-blink-merge.git] / components / search_engines / default_search_pref_test_util.h
blob53484e6a4a844aa0802c124920b4cef915c5bc6b
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
3 // found in the LICENSE file.
5 #ifndef COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_PREF_TEST_UTIL_H_
6 #define COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_PREF_TEST_UTIL_H_
8 #include <string>
10 #include "base/basictypes.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "base/values.h"
13 #include "components/search_engines/default_search_manager.h"
15 class DefaultSearchPrefTestUtil {
16 public:
17 // Creates a DictionaryValue which can be used as a
18 // kDefaultSearchProviderDataPrefName preference value.
19 static scoped_ptr<base::DictionaryValue> CreateDefaultSearchPreferenceValue(
20 bool enabled,
21 const std::string& name,
22 const std::string& keyword,
23 const std::string& search_url,
24 const std::string& suggest_url,
25 const std::string& icon_url,
26 const std::string& encodings,
27 const std::string& alternate_url,
28 const std::string& search_terms_replacement_key);
30 // Set the managed preferences for the default search provider and trigger
31 // notification. If |alternate_url| is empty, uses an empty list of alternate
32 // URLs, otherwise use a list containing a single entry.
33 template<typename TestingPrefService>
34 static void SetManagedPref(TestingPrefService* pref_service,
35 bool enabled,
36 const std::string& name,
37 const std::string& keyword,
38 const std::string& search_url,
39 const std::string& suggest_url,
40 const std::string& icon_url,
41 const std::string& encodings,
42 const std::string& alternate_url,
43 const std::string& search_terms_replacement_key) {
44 pref_service->SetManagedPref(
45 DefaultSearchManager::kDefaultSearchProviderDataPrefName,
46 CreateDefaultSearchPreferenceValue(
47 enabled, name, keyword, search_url, suggest_url, icon_url,
48 encodings, alternate_url, search_terms_replacement_key).release());
51 // Remove all the managed preferences for the default search provider and
52 // trigger notification.
53 template<typename TestingPrefService>
54 static void RemoveManagedPref(TestingPrefService* pref_service) {
55 pref_service->RemoveManagedPref(
56 DefaultSearchManager::kDefaultSearchProviderDataPrefName);
60 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_PREF_TEST_UTIL_H_