OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/content_settings/content_settings_platform_app_provider
.h" |
| 6 |
| 7 #include "chrome/browser/content_settings/content_settings_rule.h" |
| 8 #include "chrome/browser/extensions/extension_host.h" |
| 9 #include "chrome/common/chrome_notification_types.h" |
| 10 #include "chrome/common/content_settings.h" |
| 11 #include "chrome/common/content_settings_pattern.h" |
| 12 #include "chrome/common/extensions/extension.h" |
| 13 #include "chrome/common/url_constants.h" |
| 14 #include "content/public/browser/browser_thread.h" |
| 15 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_service.h" |
| 17 |
| 18 namespace content_settings { |
| 19 |
| 20 PlatformAppProvider::PlatformAppProvider() |
| 21 : registrar_(new content::NotificationRegistrar) { |
| 22 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, |
| 23 content::NotificationService::AllSources()); |
| 24 } |
| 25 |
| 26 PlatformAppProvider::~PlatformAppProvider() { |
| 27 DCHECK(!registrar_); |
| 28 } |
| 29 |
| 30 RuleIterator* PlatformAppProvider::GetRuleIterator( |
| 31 ContentSettingsType content_type, |
| 32 const ResourceIdentifier& resource_identifier, |
| 33 bool incognito) const { |
| 34 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_); |
| 35 } |
| 36 |
| 37 bool PlatformAppProvider::SetWebsiteSetting( |
| 38 const ContentSettingsPattern& primary_pattern, |
| 39 const ContentSettingsPattern& secondary_pattern, |
| 40 ContentSettingsType content_type, |
| 41 const ResourceIdentifier& resource_identifier, |
| 42 Value* value) { |
| 43 return false; |
| 44 } |
| 45 |
| 46 void PlatformAppProvider::ClearAllContentSettingsRules( |
| 47 ContentSettingsType content_type) {} |
| 48 |
| 49 void PlatformAppProvider::Observe(int type, |
| 50 const content::NotificationSource& source, |
| 51 const content::NotificationDetails& details) { |
| 52 DCHECK(type == chrome::NOTIFICATION_EXTENSION_HOST_CREATED); |
| 53 const ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| 54 if (!host->extension()->is_platform_app()) |
| 55 return; |
| 56 |
| 57 base::AutoLock lock(lock_); |
| 58 scoped_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder( |
| 59 ContentSettingsPattern::CreateBuilder(false)); |
| 60 pattern_builder->WithScheme(chrome::kExtensionScheme); |
| 61 pattern_builder->WithHost(host->extension()->id()); |
| 62 pattern_builder->WithPathWildcard(); |
| 63 |
| 64 value_map_.SetValue(pattern_builder->Build(), |
| 65 ContentSettingsPattern::Wildcard(), |
| 66 CONTENT_SETTINGS_TYPE_PLUGINS, |
| 67 ResourceIdentifier(""), |
| 68 Value::CreateIntegerValue(CONTENT_SETTING_BLOCK)); |
| 69 } |
| 70 |
| 71 void PlatformAppProvider::ShutdownOnUIThread() { |
| 72 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 73 registrar_->RemoveAll(); |
| 74 delete registrar_; |
| 75 registrar_ = NULL; |
| 76 } |
| 77 |
| 78 } // namespace content_settings |
OLD | NEW |