| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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_policy_provider.h" | 5 #include "chrome/browser/content_settings/content_settings_policy_provider.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 270 prefs->RegisterListPref(prefs::kManagedPluginsAllowedForUrls, | 270 prefs->RegisterListPref(prefs::kManagedPluginsAllowedForUrls, |
| 271 PrefService::UNSYNCABLE_PREF); | 271 PrefService::UNSYNCABLE_PREF); |
| 272 prefs->RegisterListPref(prefs::kManagedPluginsBlockedForUrls, | 272 prefs->RegisterListPref(prefs::kManagedPluginsBlockedForUrls, |
| 273 PrefService::UNSYNCABLE_PREF); | 273 PrefService::UNSYNCABLE_PREF); |
| 274 prefs->RegisterListPref(prefs::kManagedPopupsAllowedForUrls, | 274 prefs->RegisterListPref(prefs::kManagedPopupsAllowedForUrls, |
| 275 PrefService::UNSYNCABLE_PREF); | 275 PrefService::UNSYNCABLE_PREF); |
| 276 prefs->RegisterListPref(prefs::kManagedPopupsBlockedForUrls, | 276 prefs->RegisterListPref(prefs::kManagedPopupsBlockedForUrls, |
| 277 PrefService::UNSYNCABLE_PREF); | 277 PrefService::UNSYNCABLE_PREF); |
| 278 } | 278 } |
| 279 | 279 |
| 280 PolicyProvider::PolicyProvider(HostContentSettingsMap* map, | 280 PolicyProvider::PolicyProvider(Observer* observer, |
| 281 PrefService* prefs, | 281 PrefService* prefs, |
| 282 DefaultProviderInterface* default_provider) | 282 DefaultProviderInterface* default_provider) |
| 283 : host_content_settings_map_(map), | 283 : prefs_(prefs), |
| 284 prefs_(prefs), | |
| 285 default_provider_(default_provider) { | 284 default_provider_(default_provider) { |
| 285 AddObserver(observer); |
| 286 ReadManagedContentSettings(false); | 286 ReadManagedContentSettings(false); |
| 287 | 287 |
| 288 pref_change_registrar_.Init(prefs_); | 288 pref_change_registrar_.Init(prefs_); |
| 289 pref_change_registrar_.Add(prefs::kManagedCookiesBlockedForUrls, this); | 289 pref_change_registrar_.Add(prefs::kManagedCookiesBlockedForUrls, this); |
| 290 pref_change_registrar_.Add(prefs::kManagedCookiesAllowedForUrls, this); | 290 pref_change_registrar_.Add(prefs::kManagedCookiesAllowedForUrls, this); |
| 291 pref_change_registrar_.Add(prefs::kManagedCookiesSessionOnlyForUrls, this); | 291 pref_change_registrar_.Add(prefs::kManagedCookiesSessionOnlyForUrls, this); |
| 292 pref_change_registrar_.Add(prefs::kManagedImagesBlockedForUrls, this); | 292 pref_change_registrar_.Add(prefs::kManagedImagesBlockedForUrls, this); |
| 293 pref_change_registrar_.Add(prefs::kManagedImagesAllowedForUrls, this); | 293 pref_change_registrar_.Add(prefs::kManagedImagesAllowedForUrls, this); |
| 294 pref_change_registrar_.Add(prefs::kManagedJavaScriptBlockedForUrls, this); | 294 pref_change_registrar_.Add(prefs::kManagedJavaScriptBlockedForUrls, this); |
| 295 pref_change_registrar_.Add(prefs::kManagedJavaScriptAllowedForUrls, this); | 295 pref_change_registrar_.Add(prefs::kManagedJavaScriptAllowedForUrls, this); |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 421 } |
| 422 } | 422 } |
| 423 } | 423 } |
| 424 | 424 |
| 425 void PolicyProvider::ClearAllContentSettingsRules( | 425 void PolicyProvider::ClearAllContentSettingsRules( |
| 426 ContentSettingsType content_type) { | 426 ContentSettingsType content_type) { |
| 427 } | 427 } |
| 428 | 428 |
| 429 void PolicyProvider::ShutdownOnUIThread() { | 429 void PolicyProvider::ShutdownOnUIThread() { |
| 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 430 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 431 RemoveAllObserver(); |
| 431 if (!prefs_) | 432 if (!prefs_) |
| 432 return; | 433 return; |
| 433 pref_change_registrar_.RemoveAll(); | 434 pref_change_registrar_.RemoveAll(); |
| 434 prefs_ = NULL; | 435 prefs_ = NULL; |
| 435 host_content_settings_map_ = NULL; | |
| 436 } | |
| 437 | |
| 438 void PolicyProvider::NotifyObservers( | |
| 439 const ContentSettingsDetails& details) { | |
| 440 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | |
| 441 if (host_content_settings_map_ == NULL) | |
| 442 return; | |
| 443 NotificationService::current()->Notify( | |
| 444 chrome::NOTIFICATION_CONTENT_SETTINGS_CHANGED, | |
| 445 Source<HostContentSettingsMap>(host_content_settings_map_), | |
| 446 Details<const ContentSettingsDetails>(&details)); | |
| 447 } | 436 } |
| 448 | 437 |
| 449 void PolicyProvider::Observe(int type, | 438 void PolicyProvider::Observe(int type, |
| 450 const NotificationSource& source, | 439 const NotificationSource& source, |
| 451 const NotificationDetails& details) { | 440 const NotificationDetails& details) { |
| 452 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 441 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 453 | 442 |
| 454 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 443 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
| 455 DCHECK_EQ(prefs_, Source<PrefService>(source).ptr()); | 444 DCHECK_EQ(prefs_, Source<PrefService>(source).ptr()); |
| 456 std::string* name = Details<std::string>(details).ptr(); | 445 std::string* name = Details<std::string>(details).ptr(); |
| (...skipping 14 matching lines...) Expand all Loading... |
| 471 CONTENT_SETTINGS_TYPE_DEFAULT, | 460 CONTENT_SETTINGS_TYPE_DEFAULT, |
| 472 std::string()); | 461 std::string()); |
| 473 NotifyObservers(details); | 462 NotifyObservers(details); |
| 474 } | 463 } |
| 475 } else { | 464 } else { |
| 476 NOTREACHED() << "Unexpected notification"; | 465 NOTREACHED() << "Unexpected notification"; |
| 477 } | 466 } |
| 478 } | 467 } |
| 479 | 468 |
| 480 } // namespace content_settings | 469 } // namespace content_settings |
| OLD | NEW |