OLD | NEW |
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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_internal_extension_pr
ovider.h" | 5 #include "chrome/browser/content_settings/content_settings_internal_extension_pr
ovider.h" |
6 | 6 |
7 #include "chrome/browser/extensions/extension_service.h" | 7 #include "chrome/browser/profiles/profile.h" |
8 #include "chrome/common/chrome_content_client.h" | 8 #include "chrome/common/chrome_content_client.h" |
9 #include "chrome/common/extensions/api/plugins/plugins_handler.h" | 9 #include "chrome/common/extensions/api/plugins/plugins_handler.h" |
10 #include "components/content_settings/core/browser/content_settings_rule.h" | 10 #include "components/content_settings/core/browser/content_settings_rule.h" |
11 #include "components/content_settings/core/common/content_settings.h" | 11 #include "components/content_settings/core/common/content_settings.h" |
12 #include "components/content_settings/core/common/content_settings_pattern.h" | 12 #include "components/content_settings/core/common/content_settings_pattern.h" |
13 #include "content/public/browser/notification_details.h" | 13 #include "content/public/browser/notification_details.h" |
14 #include "content/public/browser/notification_service.h" | 14 #include "content/public/browser/notification_service.h" |
15 #include "extensions/browser/extension_host.h" | 15 #include "extensions/browser/extension_host.h" |
| 16 #include "extensions/browser/extension_registry.h" |
16 #include "extensions/browser/notification_types.h" | 17 #include "extensions/browser/notification_types.h" |
17 #include "extensions/common/constants.h" | 18 #include "extensions/common/constants.h" |
18 #include "extensions/common/extension.h" | 19 #include "extensions/common/extension.h" |
19 #include "extensions/common/extension_set.h" | 20 #include "extensions/common/extension_set.h" |
20 #include "extensions/common/features/simple_feature.h" | 21 #include "extensions/common/features/simple_feature.h" |
21 | 22 |
22 using extensions::UnloadedExtensionInfo; | 23 using extensions::UnloadedExtensionInfo; |
23 | 24 |
24 namespace content_settings { | 25 namespace content_settings { |
25 | 26 |
26 InternalExtensionProvider::InternalExtensionProvider( | 27 InternalExtensionProvider::InternalExtensionProvider(Profile* profile) |
27 ExtensionService* extension_service) | |
28 : registrar_(new content::NotificationRegistrar) { | 28 : registrar_(new content::NotificationRegistrar) { |
29 // Whitelist all extensions loaded so far. | 29 // Whitelist all extensions loaded so far. |
30 const extensions::ExtensionSet* extensions = extension_service->extensions(); | 30 for (const scoped_refptr<const extensions::Extension>& extension : |
31 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); | 31 extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) { |
32 it != extensions->end(); ++it) { | 32 if (extensions::PluginInfo::HasPlugins(extension.get())) |
33 if (extensions::PluginInfo::HasPlugins(it->get())) | 33 SetContentSettingForExtension(extension.get(), CONTENT_SETTING_ALLOW); |
34 SetContentSettingForExtension(it->get(), CONTENT_SETTING_ALLOW); | |
35 } | 34 } |
36 Profile* profile = extension_service->profile(); | |
37 registrar_->Add(this, | 35 registrar_->Add(this, |
38 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, | 36 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, |
39 content::Source<Profile>(profile)); | 37 content::Source<Profile>(profile)); |
40 registrar_->Add(this, | 38 registrar_->Add(this, |
41 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, | 39 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, |
42 content::Source<Profile>(profile)); | 40 content::Source<Profile>(profile)); |
43 registrar_->Add(this, | 41 registrar_->Add(this, |
44 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, | 42 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, |
45 content::Source<Profile>(profile)); | 43 content::Source<Profile>(profile)); |
46 } | 44 } |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 new base::FundamentalValue(setting)); | 191 new base::FundamentalValue(setting)); |
194 } | 192 } |
195 } | 193 } |
196 NotifyObservers(primary_pattern, | 194 NotifyObservers(primary_pattern, |
197 secondary_pattern, | 195 secondary_pattern, |
198 CONTENT_SETTINGS_TYPE_PLUGINS, | 196 CONTENT_SETTINGS_TYPE_PLUGINS, |
199 resource); | 197 resource); |
200 } | 198 } |
201 | 199 |
202 } // namespace content_settings | 200 } // namespace content_settings |
OLD | NEW |