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/extensions/extension_content_settings_store.h" | 5 #include "chrome/browser/extensions/extension_content_settings_store.h" |
6 | 6 |
7 #include <set> | 7 #include <set> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 ContentSettingSpecList incognito_persistent_settings; | 47 ContentSettingSpecList incognito_persistent_settings; |
48 // Session-only incognito content settings. | 48 // Session-only incognito content settings. |
49 ContentSettingSpecList incognito_session_only_settings; | 49 ContentSettingSpecList incognito_session_only_settings; |
50 }; | 50 }; |
51 | 51 |
52 ExtensionContentSettingsStore::ExtensionContentSettingsStore() { | 52 ExtensionContentSettingsStore::ExtensionContentSettingsStore() { |
53 DCHECK(OnCorrectThread()); | 53 DCHECK(OnCorrectThread()); |
54 } | 54 } |
55 | 55 |
56 ExtensionContentSettingsStore::~ExtensionContentSettingsStore() { | 56 ExtensionContentSettingsStore::~ExtensionContentSettingsStore() { |
57 DCHECK(OnCorrectThread()); | |
58 NotifyOfDestruction(); | |
59 STLDeleteValues(&entries_); | 57 STLDeleteValues(&entries_); |
60 } | 58 } |
61 | 59 |
62 void ExtensionContentSettingsStore::SetExtensionContentSetting( | 60 void ExtensionContentSettingsStore::SetExtensionContentSetting( |
63 const std::string& ext_id, | 61 const std::string& ext_id, |
64 const ContentSettingsPattern& primary_pattern, | 62 const ContentSettingsPattern& primary_pattern, |
65 const ContentSettingsPattern& secondary_pattern, | 63 const ContentSettingsPattern& secondary_pattern, |
66 ContentSettingsType type, | 64 ContentSettingsType type, |
67 const content_settings::ResourceIdentifier& identifier, | 65 const content_settings::ResourceIdentifier& identifier, |
68 ContentSetting setting, | 66 ContentSetting setting, |
(...skipping 358 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
427 ContentSettingsType type, | 425 ContentSettingsType type, |
428 const content_settings::ResourceIdentifier& identifier, | 426 const content_settings::ResourceIdentifier& identifier, |
429 ContentSetting setting) | 427 ContentSetting setting) |
430 : primary_pattern(primary_pattern), | 428 : primary_pattern(primary_pattern), |
431 secondary_pattern(secondary_pattern), | 429 secondary_pattern(secondary_pattern), |
432 content_type(type), | 430 content_type(type), |
433 resource_identifier(identifier), | 431 resource_identifier(identifier), |
434 setting(setting) { | 432 setting(setting) { |
435 } | 433 } |
436 | 434 |
437 void ExtensionContentSettingsStore::NotifyOfDestruction() { | |
438 FOR_EACH_OBSERVER(ExtensionContentSettingsStore::Observer, | |
439 observers_, | |
440 OnDestruction()); | |
441 } | |
442 | |
443 void ExtensionContentSettingsStore::NotifyOfContentSettingChanged( | 435 void ExtensionContentSettingsStore::NotifyOfContentSettingChanged( |
444 const std::string& extension_id, | 436 const std::string& extension_id, |
445 bool incognito) { | 437 bool incognito) { |
446 FOR_EACH_OBSERVER( | 438 FOR_EACH_OBSERVER( |
447 ExtensionContentSettingsStore::Observer, | 439 ExtensionContentSettingsStore::Observer, |
448 observers_, | 440 observers_, |
449 OnContentSettingChanged(extension_id, incognito)); | 441 OnContentSettingChanged(extension_id, incognito)); |
450 } | 442 } |
451 | 443 |
452 bool ExtensionContentSettingsStore::OnCorrectThread() { | 444 bool ExtensionContentSettingsStore::OnCorrectThread() { |
453 // If there is no UI thread, we're most likely in a unit test. | 445 // If there is no UI thread, we're most likely in a unit test. |
454 return !BrowserThread::IsWellKnownThread(BrowserThread::UI) || | 446 return !BrowserThread::IsWellKnownThread(BrowserThread::UI) || |
455 BrowserThread::CurrentlyOn(BrowserThread::UI); | 447 BrowserThread::CurrentlyOn(BrowserThread::UI); |
456 } | 448 } |
OLD | NEW |