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

Side by Side Diff: chrome/browser/extensions/api/font_settings/font_settings_api.cc

Issue 11307020: Cleanup: Simplify some extensions / content_settings Observer code by simply DCHECKING instead of u… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: 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 // Font Settings Extension API implementation. 5 // Font Settings Extension API implementation.
6 6
7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h" 7 #include "chrome/browser/extensions/api/font_settings/font_settings_api.h"
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 const char* event_name, 151 const char* event_name,
152 const char* key) { 152 const char* key) {
153 registrar_.Add(pref_name, this); 153 registrar_.Add(pref_name, this);
154 pref_event_map_[pref_name] = std::make_pair(event_name, key); 154 pref_event_map_[pref_name] = std::make_pair(event_name, key);
155 } 155 }
156 156
157 void FontSettingsEventRouter::Observe( 157 void FontSettingsEventRouter::Observe(
158 int type, 158 int type,
159 const content::NotificationSource& source, 159 const content::NotificationSource& source,
160 const content::NotificationDetails& details) { 160 const content::NotificationDetails& details) {
161 if (type != chrome::NOTIFICATION_PREF_CHANGED) { 161 DCHECK_EQ(type, chrome::NOTIFICATION_PREF_CHANGED);
162 NOTREACHED();
163 return;
164 }
165 162
166 PrefService* pref_service = content::Source<PrefService>(source).ptr(); 163 PrefService* pref_service = content::Source<PrefService>(source).ptr();
167 bool incognito = (pref_service != profile_->GetPrefs()); 164 bool incognito = (pref_service != profile_->GetPrefs());
168 // We're only observing pref changes on the regular profile. 165 // We're only observing pref changes on the regular profile.
169 DCHECK(!incognito); 166 DCHECK(!incognito);
170 const std::string* pref_name = 167 const std::string& pref_name =
171 content::Details<const std::string>(details).ptr(); 168 *content::Details<const std::string>(details).ptr();
172 169
173 PrefEventMap::iterator iter = pref_event_map_.find(*pref_name); 170 PrefEventMap::iterator iter = pref_event_map_.find(pref_name);
174 if (iter != pref_event_map_.end()) { 171 if (iter != pref_event_map_.end()) {
175 const std::string& event_name = iter->second.first; 172 const std::string& event_name = iter->second.first;
176 const std::string& key = iter->second.second; 173 const std::string& key = iter->second.second;
177 OnFontPrefChanged(pref_service, *pref_name, event_name, key, incognito); 174 OnFontPrefChanged(pref_service, pref_name, event_name, key, incognito);
178 return; 175 return;
179 } 176 }
180 177
181 std::string generic_family; 178 std::string generic_family;
182 std::string script; 179 std::string script;
183 if (ParseFontNamePrefPath(*pref_name, &generic_family, &script)) { 180 if (ParseFontNamePrefPath(pref_name, &generic_family, &script)) {
184 OnFontNamePrefChanged(pref_service, *pref_name, generic_family, script, 181 OnFontNamePrefChanged(pref_service, pref_name, generic_family, script,
185 incognito); 182 incognito);
186 return; 183 return;
187 } 184 }
188 185
189 NOTREACHED(); 186 NOTREACHED();
190 } 187 }
191 188
192 void FontSettingsEventRouter::OnFontNamePrefChanged( 189 void FontSettingsEventRouter::OnFontNamePrefChanged(
193 PrefService* pref_service, 190 PrefService* pref_service,
194 const std::string& pref_name, 191 const std::string& pref_name,
(...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 477
481 const char* SetMinimumFontSizeFunction::GetPrefName() { 478 const char* SetMinimumFontSizeFunction::GetPrefName() {
482 return prefs::kWebKitMinimumFontSize; 479 return prefs::kWebKitMinimumFontSize;
483 } 480 }
484 481
485 const char* SetMinimumFontSizeFunction::GetKey() { 482 const char* SetMinimumFontSizeFunction::GetKey() {
486 return kPixelSizeKey; 483 return kPixelSizeKey;
487 } 484 }
488 485
489 } // namespace extensions 486 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698