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

Side by Side Diff: components/search_engines/default_search_manager.h

Issue 2479113002: Make extensions DSE persistent in browser prefs (Closed)
Patch Set: Fixed default extension keywords conflicts problem Created 3 years, 11 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
« no previous file with comments | « components/search_engines/BUILD.gn ('k') | components/search_engines/default_search_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 static const char kDateCreated[]; 55 static const char kDateCreated[];
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 static const char kExtensionID[];
66
65 enum Source { 67 enum Source {
66 FROM_FALLBACK = 0, 68 FROM_FALLBACK = 0,
67 FROM_USER, 69 FROM_USER,
68 FROM_EXTENSION, 70 FROM_EXTENSION,
69 FROM_POLICY, 71 FROM_POLICY,
70 }; 72 };
71 73
72 typedef base::Callback<void(const TemplateURLData*, Source)> ObserverCallback; 74 typedef base::Callback<void(const TemplateURLData*, Source)> ObserverCallback;
73 75
74 DefaultSearchManager(PrefService* pref_service, 76 DefaultSearchManager(PrefService* pref_service,
(...skipping 17 matching lines...) Expand all
92 // that Default Search is explicitly disabled. |source|, if not NULL, will be 94 // that Default Search is explicitly disabled. |source|, if not NULL, will be
93 // filled in with the source of the result. 95 // filled in with the source of the result.
94 TemplateURLData* GetDefaultSearchEngine(Source* source) const; 96 TemplateURLData* GetDefaultSearchEngine(Source* source) const;
95 97
96 // Gets the source of the current Default Search Engine value. 98 // Gets the source of the current Default Search Engine value.
97 Source GetDefaultSearchEngineSource() const; 99 Source GetDefaultSearchEngineSource() const;
98 100
99 // Write default search provider data to |pref_service_|. 101 // Write default search provider data to |pref_service_|.
100 void SetUserSelectedDefaultSearchEngine(const TemplateURLData& data); 102 void SetUserSelectedDefaultSearchEngine(const TemplateURLData& data);
101 103
102 // Override the default search provider with an extension.
103 void SetExtensionControlledDefaultSearchEngine(const TemplateURLData& data);
104
105 // Clear the extension-provided default search engine. Does not explicitly
106 // disable Default Search. The new current default search engine will be
107 // defined by policy, extensions, or pre-populated data.
108 void ClearExtensionControlledDefaultSearchEngine();
109
110 // Clear the user's default search provider choice from |pref_service_|. Does 104 // Clear the user's default search provider choice from |pref_service_|. Does
111 // not explicitly disable Default Search. The new default search 105 // not explicitly disable Default Search. The new default search
112 // engine will be defined by policy, extensions, or pre-populated data. 106 // engine will be defined by policy, extensions, or pre-populated data.
113 void ClearUserSelectedDefaultSearchEngine(); 107 void ClearUserSelectedDefaultSearchEngine();
114 108
115 private: 109 private:
116 // Handles changes to kDefaultSearchProviderData pref. This includes sync and 110 // Handles changes to kDefaultSearchProviderData pref. This includes sync and
117 // policy changes. Calls LoadDefaultSearchEngineFromPrefs() and 111 // policy changes. Calls LoadDefaultSearchEngineFromPrefs() and
118 // NotifyObserver() if the effective DSE might have changed. 112 // NotifyObserver() if the effective DSE might have changed.
119 void OnDefaultSearchPrefChanged(); 113 void OnDefaultSearchPrefChanged();
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 // prefs). This will be null if no value was set in the pref store. 152 // prefs). This will be null if no value was set in the pref store.
159 std::unique_ptr<TemplateURLData> prefs_default_search_; 153 std::unique_ptr<TemplateURLData> prefs_default_search_;
160 154
161 // True if the default search is currently enforced by policy. 155 // True if the default search is currently enforced by policy.
162 bool default_search_controlled_by_policy_; 156 bool default_search_controlled_by_policy_;
163 157
164 DISALLOW_COPY_AND_ASSIGN(DefaultSearchManager); 158 DISALLOW_COPY_AND_ASSIGN(DefaultSearchManager);
165 }; 159 };
166 160
167 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_ 161 #endif // COMPONENTS_SEARCH_ENGINES_DEFAULT_SEARCH_MANAGER_H_
OLDNEW
« no previous file with comments | « components/search_engines/BUILD.gn ('k') | components/search_engines/default_search_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698