Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 #ifndef COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ | 5 #ifndef COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ |
| 6 #define COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ | 6 #define COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ |
| 7 | 7 |
| 8 #include <memory> | 8 #include <memory> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 56 static const char kLastModified[]; | 56 static const char kLastModified[]; |
| 57 static const char kLastVisited[]; | 57 static const char kLastVisited[]; |
| 58 | 58 |
| 59 static const char kUsageCount[]; | 59 static const char kUsageCount[]; |
| 60 static const char kAlternateURLs[]; | 60 static const char kAlternateURLs[]; |
| 61 static const char kSearchTermsReplacementKey[]; | 61 static const char kSearchTermsReplacementKey[]; |
| 62 static const char kCreatedByPolicy[]; | 62 static const char kCreatedByPolicy[]; |
| 63 static const char kDisabledByPolicy[]; | 63 static const char kDisabledByPolicy[]; |
| 64 | 64 |
| 65 enum Source { | 65 enum Source { |
| 66 // Default search engine chosen either from prepopulated engines set for | |
| 67 // current country or overriden from kSearchProviderOverrides preference. | |
| 66 FROM_FALLBACK = 0, | 68 FROM_FALLBACK = 0, |
| 69 // User selected engine. | |
| 67 FROM_USER, | 70 FROM_USER, |
| 71 // Search engine set by extension overriding default search. | |
| 68 FROM_EXTENSION, | 72 FROM_EXTENSION, |
| 73 // Search engine controlled externally through enterprise configuration | |
| 74 // management (e.g. windows group policy). | |
| 69 FROM_POLICY, | 75 FROM_POLICY, |
| 70 }; | 76 }; |
| 71 | 77 |
| 72 typedef base::Callback<void(const TemplateURLData*, Source)> ObserverCallback; | 78 typedef base::Callback<void(const TemplateURLData*, Source)> ObserverCallback; |
| 73 | 79 |
| 74 DefaultSearchManager(PrefService* pref_service, | 80 DefaultSearchManager(PrefService* pref_service, |
| 75 const ObserverCallback& change_observer); | 81 const ObserverCallback& change_observer); |
| 76 | 82 |
| 77 ~DefaultSearchManager(); | 83 ~DefaultSearchManager(); |
| 78 | 84 |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 89 static void SetFallbackSearchEnginesDisabledForTesting(bool disabled); | 95 static void SetFallbackSearchEnginesDisabledForTesting(bool disabled); |
| 90 | 96 |
| 91 // Gets a pointer to the current Default Search Engine. If NULL, indicates | 97 // Gets a pointer to the current Default Search Engine. If NULL, indicates |
| 92 // that Default Search is explicitly disabled. |source|, if not NULL, will be | 98 // that Default Search is explicitly disabled. |source|, if not NULL, will be |
| 93 // filled in with the source of the result. | 99 // filled in with the source of the result. |
| 94 TemplateURLData* GetDefaultSearchEngine(Source* source) const; | 100 TemplateURLData* GetDefaultSearchEngine(Source* source) const; |
| 95 | 101 |
| 96 // Gets the source of the current Default Search Engine value. | 102 // Gets the source of the current Default Search Engine value. |
| 97 Source GetDefaultSearchEngineSource() const; | 103 Source GetDefaultSearchEngineSource() const; |
| 98 | 104 |
| 105 // Returns a pointer to fallback engine. | |
|
vasilii
2017/02/13 14:37:54
the fallback engine
Alexander Yashkin
2017/02/14 12:04:43
Done
| |
| 106 TemplateURLData* GetFallbackSearchEngine() const; | |
|
Peter Kasting
2017/02/13 22:24:57
Nit: const methods should not return non-const poi
Alexander Yashkin
2017/02/14 12:04:43
Done
| |
| 107 | |
| 99 // Write default search provider data to |pref_service_|. | 108 // Write default search provider data to |pref_service_|. |
| 100 void SetUserSelectedDefaultSearchEngine(const TemplateURLData& data); | 109 void SetUserSelectedDefaultSearchEngine(const TemplateURLData& data); |
| 101 | 110 |
| 102 // Override the default search provider with an extension. | 111 // Override the default search provider with an extension. |
| 103 void SetExtensionControlledDefaultSearchEngine(const TemplateURLData& data); | 112 void SetExtensionControlledDefaultSearchEngine(const TemplateURLData& data); |
| 104 | 113 |
| 105 // Clear the extension-provided default search engine. Does not explicitly | 114 // Clear the extension-provided default search engine. Does not explicitly |
| 106 // disable Default Search. The new current default search engine will be | 115 // disable Default Search. The new current default search engine will be |
| 107 // defined by policy, extensions, or pre-populated data. | 116 // defined by policy, extensions, or pre-populated data. |
| 108 void ClearExtensionControlledDefaultSearchEngine(); | 117 void ClearExtensionControlledDefaultSearchEngine(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 // prefs). This will be null if no value was set in the pref store. | 167 // prefs). This will be null if no value was set in the pref store. |
| 159 std::unique_ptr<TemplateURLData> prefs_default_search_; | 168 std::unique_ptr<TemplateURLData> prefs_default_search_; |
| 160 | 169 |
| 161 // True if the default search is currently enforced by policy. | 170 // True if the default search is currently enforced by policy. |
| 162 bool default_search_controlled_by_policy_; | 171 bool default_search_controlled_by_policy_; |
| 163 | 172 |
| 164 DISALLOW_COPY_AND_ASSIGN(DefaultSearchManager); | 173 DISALLOW_COPY_AND_ASSIGN(DefaultSearchManager); |
| 165 }; | 174 }; |
| 166 | 175 |
| 167 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ | 176 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ |
| OLD | NEW |