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

Side by Side Diff: chrome/browser/spellchecker/spellcheck_profile.cc

Issue 11345008: Remove content::NotificationObserver dependency from most Prefs code. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge to head for commit Created 8 years, 1 month 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/spellchecker/spellcheck_profile.h" 5 #include "chrome/browser/spellchecker/spellcheck_profile.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/lazy_instance.h" 8 #include "base/lazy_instance.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/string_split.h" 10 #include "base/string_split.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 custom_dictionary_->WriteWordToCustomDictionary(word); 105 custom_dictionary_->WriteWordToCustomDictionary(word);
106 } 106 }
107 107
108 void SpellCheckProfile::Shutdown() { 108 void SpellCheckProfile::Shutdown() {
109 if (host_.get()) 109 if (host_.get())
110 host_->UnsetProfile(); 110 host_->UnsetProfile();
111 111
112 profile_ = NULL; 112 profile_ = NULL;
113 } 113 }
114 114
115 void SpellCheckProfile::Observe(int type, 115 void SpellCheckProfile::OnPreferenceChanged(PrefServiceBase* prefs,
116 const content::NotificationSource& source, 116 const std::string& pref_name_in) {
117 const content::NotificationDetails& details) { 117 DCHECK(prefs);
118 switch (type) { 118 if (pref_name_in == prefs::kSpellCheckDictionary ||
119 case chrome::NOTIFICATION_PREF_CHANGED: { 119 pref_name_in == prefs::kEnableSpellCheck) {
120 std::string* pref_name_in = content::Details<std::string>(details).ptr(); 120 ReinitializeSpellCheckHost(true);
121 PrefService* prefs = content::Source<PrefService>(source).ptr(); 121 } else if (pref_name_in == prefs::kEnableAutoSpellCorrect) {
122 DCHECK(pref_name_in && prefs); 122 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect);
123 if (*pref_name_in == prefs::kSpellCheckDictionary || 123 for (content::RenderProcessHost::iterator i(
124 *pref_name_in == prefs::kEnableSpellCheck) { 124 content::RenderProcessHost::AllHostsIterator());
125 ReinitializeSpellCheckHost(true); 125 !i.IsAtEnd(); i.Advance()) {
126 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) { 126 content::RenderProcessHost* process = i.GetCurrentValue();
127 bool enabled = prefs->GetBoolean(prefs::kEnableAutoSpellCorrect); 127 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled));
128 for (content::RenderProcessHost::iterator i(
129 content::RenderProcessHost::AllHostsIterator());
130 !i.IsAtEnd(); i.Advance()) {
131 content::RenderProcessHost* process = i.GetCurrentValue();
132 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled));
133 }
134 }
135 } 128 }
136 } 129 }
137 } 130 }
138 131
139 SpellCheckProfile::ReinitializeResult SpellCheckProfile::ReinitializeHostImpl( 132 SpellCheckProfile::ReinitializeResult SpellCheckProfile::ReinitializeHostImpl(
140 bool force, 133 bool force,
141 bool enable, 134 bool enable,
142 const std::string& language, 135 const std::string& language,
143 net::URLRequestContextGetter* request_context) { 136 net::URLRequestContextGetter* request_context) {
144 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || IsTesting()); 137 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI) || IsTesting());
(...skipping 13 matching lines...) Expand all
158 151
159 if (enable) { 152 if (enable) {
160 // Retrieve the (perhaps updated recently) dictionary name from preferences. 153 // Retrieve the (perhaps updated recently) dictionary name from preferences.
161 host_.reset(CreateHost(this, language, request_context, metrics_.get())); 154 host_.reset(CreateHost(this, language, request_context, metrics_.get()));
162 return REINITIALIZE_CREATED_HOST; 155 return REINITIALIZE_CREATED_HOST;
163 } 156 }
164 157
165 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING; 158 return host_deleted ? REINITIALIZE_REMOVED_HOST : REINITIALIZE_DID_NOTHING;
166 } 159 }
167 160
OLDNEW
« no previous file with comments | « chrome/browser/spellchecker/spellcheck_profile.h ('k') | chrome/browser/sync/credential_cache_service_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698