OLD | NEW |
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/content_settings/content_settings_default_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_default_provider.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 } | 269 } |
270 | 270 |
271 void DefaultProvider::ShutdownOnUIThread() { | 271 void DefaultProvider::ShutdownOnUIThread() { |
272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 272 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
273 DCHECK(prefs_); | 273 DCHECK(prefs_); |
274 RemoveAllObservers(); | 274 RemoveAllObservers(); |
275 pref_change_registrar_.RemoveAll(); | 275 pref_change_registrar_.RemoveAll(); |
276 prefs_ = NULL; | 276 prefs_ = NULL; |
277 } | 277 } |
278 | 278 |
279 void DefaultProvider::Observe(int type, | 279 void DefaultProvider::OnPreferenceChanged(PrefServiceBase* service, |
280 const content::NotificationSource& source, | 280 const std::string& name) { |
281 const content::NotificationDetails& details) { | |
282 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 281 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
283 DCHECK_EQ(chrome::NOTIFICATION_PREF_CHANGED, type); | 282 DCHECK_EQ(prefs_, service); |
284 DCHECK_EQ(content::Source<PrefService>(source).ptr(), prefs_); | |
285 | |
286 if (updating_preferences_) | 283 if (updating_preferences_) |
287 return; | 284 return; |
288 | 285 |
289 const std::string& name = *content::Details<std::string>(details).ptr(); | |
290 if (name == prefs::kDefaultContentSettings) { | 286 if (name == prefs::kDefaultContentSettings) { |
291 ReadDefaultSettings(true); | 287 ReadDefaultSettings(true); |
292 } else if (name == prefs::kGeolocationDefaultContentSetting) { | 288 } else if (name == prefs::kGeolocationDefaultContentSetting) { |
293 MigrateObsoleteGeolocationPref(); | 289 MigrateObsoleteGeolocationPref(); |
294 // Return and don't send a notifications. Migrating the obsolete | 290 // Return and don't send a notifications. Migrating the obsolete |
295 // geolocation pref will change the prefs::kDefaultContentSettings and | 291 // geolocation pref will change the prefs::kDefaultContentSettings and |
296 // cause the notification to be fired. | 292 // cause the notification to be fired. |
297 return; | 293 return; |
298 } else { | 294 } else { |
299 NOTREACHED() << "Unexpected preference observed"; | 295 NOTREACHED() << "Unexpected preference observed"; |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 SetWebsiteSetting( | 379 SetWebsiteSetting( |
384 ContentSettingsPattern::Wildcard(), | 380 ContentSettingsPattern::Wildcard(), |
385 ContentSettingsPattern::Wildcard(), | 381 ContentSettingsPattern::Wildcard(), |
386 CONTENT_SETTINGS_TYPE_GEOLOCATION, | 382 CONTENT_SETTINGS_TYPE_GEOLOCATION, |
387 std::string(), | 383 std::string(), |
388 value->DeepCopy()); | 384 value->DeepCopy()); |
389 } | 385 } |
390 } | 386 } |
391 | 387 |
392 } // namespace content_settings | 388 } // namespace content_settings |
OLD | NEW |