Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(306)

Side by Side Diff: chrome/browser/content_settings/content_settings_internal_extension_provider.cc

Issue 425303002: Move extension notifications to extensions/browser/notification_types.h (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: (extension-notifications) rebase Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/chrome_notification_types.h"
8 #include "chrome/browser/content_settings/content_settings_rule.h" 7 #include "chrome/browser/content_settings/content_settings_rule.h"
9 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/common/chrome_content_client.h" 9 #include "chrome/common/chrome_content_client.h"
11 #include "chrome/common/content_settings.h" 10 #include "chrome/common/content_settings.h"
12 #include "chrome/common/content_settings_pattern.h" 11 #include "chrome/common/content_settings_pattern.h"
13 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 12 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
14 #include "content/public/browser/browser_thread.h" 13 #include "content/public/browser/browser_thread.h"
15 #include "content/public/browser/notification_details.h" 14 #include "content/public/browser/notification_details.h"
16 #include "content/public/browser/notification_service.h" 15 #include "content/public/browser/notification_service.h"
17 #include "extensions/browser/extension_host.h" 16 #include "extensions/browser/extension_host.h"
17 #include "extensions/browser/notification_types.h"
18 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
19 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
20 #include "extensions/common/extension_set.h" 20 #include "extensions/common/extension_set.h"
21 #include "extensions/common/features/simple_feature.h" 21 #include "extensions/common/features/simple_feature.h"
22 22
23 using extensions::UnloadedExtensionInfo; 23 using extensions::UnloadedExtensionInfo;
24 24
25 namespace content_settings { 25 namespace content_settings {
26 26
27 InternalExtensionProvider::InternalExtensionProvider( 27 InternalExtensionProvider::InternalExtensionProvider(
28 ExtensionService* extension_service) 28 ExtensionService* extension_service)
29 : registrar_(new content::NotificationRegistrar) { 29 : registrar_(new content::NotificationRegistrar) {
30 // Whitelist all extensions loaded so far. 30 // Whitelist all extensions loaded so far.
31 const extensions::ExtensionSet* extensions = extension_service->extensions(); 31 const extensions::ExtensionSet* extensions = extension_service->extensions();
32 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); 32 for (extensions::ExtensionSet::const_iterator it = extensions->begin();
33 it != extensions->end(); ++it) { 33 it != extensions->end(); ++it) {
34 if (extensions::PluginInfo::HasPlugins(it->get())) 34 if (extensions::PluginInfo::HasPlugins(it->get()))
35 SetContentSettingForExtension(it->get(), CONTENT_SETTING_ALLOW); 35 SetContentSettingForExtension(it->get(), CONTENT_SETTING_ALLOW);
36 } 36 }
37 Profile* profile = extension_service->profile(); 37 Profile* profile = extension_service->profile();
38 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 38 registrar_->Add(this,
39 extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
39 content::Source<Profile>(profile)); 40 content::Source<Profile>(profile));
40 registrar_->Add(this, 41 registrar_->Add(this,
41 chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 42 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
42 content::Source<Profile>(profile)); 43 content::Source<Profile>(profile));
43 registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 44 registrar_->Add(this,
45 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
44 content::Source<Profile>(profile)); 46 content::Source<Profile>(profile));
45 } 47 }
46 48
47 InternalExtensionProvider::~InternalExtensionProvider() { 49 InternalExtensionProvider::~InternalExtensionProvider() {
48 DCHECK(!registrar_.get()); 50 DCHECK(!registrar_.get());
49 } 51 }
50 52
51 RuleIterator* InternalExtensionProvider::GetRuleIterator( 53 RuleIterator* InternalExtensionProvider::GetRuleIterator(
52 ContentSettingsType content_type, 54 ContentSettingsType content_type,
53 const ResourceIdentifier& resource_identifier, 55 const ResourceIdentifier& resource_identifier,
(...skipping 10 matching lines...) Expand all
64 return false; 66 return false;
65 } 67 }
66 68
67 void InternalExtensionProvider::ClearAllContentSettingsRules( 69 void InternalExtensionProvider::ClearAllContentSettingsRules(
68 ContentSettingsType content_type) {} 70 ContentSettingsType content_type) {}
69 71
70 void InternalExtensionProvider::Observe(int type, 72 void InternalExtensionProvider::Observe(int type,
71 const content::NotificationSource& source, 73 const content::NotificationSource& source,
72 const content::NotificationDetails& details) { 74 const content::NotificationDetails& details) {
73 switch (type) { 75 switch (type) {
74 case chrome::NOTIFICATION_EXTENSION_HOST_CREATED: { 76 case extensions::NOTIFICATION_EXTENSION_HOST_CREATED: {
75 const extensions::ExtensionHost* host = 77 const extensions::ExtensionHost* host =
76 content::Details<extensions::ExtensionHost>(details).ptr(); 78 content::Details<extensions::ExtensionHost>(details).ptr();
77 if (host->extension()->is_platform_app()) { 79 if (host->extension()->is_platform_app()) {
78 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK); 80 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK);
79 81
80 // White-list CRD's v2 app, until crbug.com/134216 is complete. 82 // White-list CRD's v2 app, until crbug.com/134216 is complete.
81 const char* kAppWhitelist[] = { 83 const char* kAppWhitelist[] = {
82 "2775E568AC98F9578791F1EAB65A1BF5F8CEF414", 84 "2775E568AC98F9578791F1EAB65A1BF5F8CEF414",
83 "4AA3C5D69A4AECBD236CAD7884502209F0F5C169", 85 "4AA3C5D69A4AECBD236CAD7884502209F0F5C169",
84 "97B23E01B2AA064E8332EE43A7A85C628AADC3F2", 86 "97B23E01B2AA064E8332EE43A7A85C628AADC3F2",
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 kAppWhitelist, kAppWhitelist + arraysize(kAppWhitelist)))) { 128 kAppWhitelist, kAppWhitelist + arraysize(kAppWhitelist)))) {
127 SetContentSettingForExtensionAndResource( 129 SetContentSettingForExtensionAndResource(
128 host->extension(), 130 host->extension(),
129 ChromeContentClient::kRemotingViewerPluginPath, 131 ChromeContentClient::kRemotingViewerPluginPath,
130 CONTENT_SETTING_ALLOW); 132 CONTENT_SETTING_ALLOW);
131 } 133 }
132 } 134 }
133 135
134 break; 136 break;
135 } 137 }
136 case chrome::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { 138 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
137 const extensions::Extension* extension = 139 const extensions::Extension* extension =
138 content::Details<extensions::Extension>(details).ptr(); 140 content::Details<extensions::Extension>(details).ptr();
139 if (extensions::PluginInfo::HasPlugins(extension)) 141 if (extensions::PluginInfo::HasPlugins(extension))
140 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW); 142 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
141 break; 143 break;
142 } 144 }
143 case chrome::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { 145 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
144 const UnloadedExtensionInfo& info = 146 const UnloadedExtensionInfo& info =
145 *(content::Details<UnloadedExtensionInfo>(details).ptr()); 147 *(content::Details<UnloadedExtensionInfo>(details).ptr());
146 if (extensions::PluginInfo::HasPlugins(info.extension)) 148 if (extensions::PluginInfo::HasPlugins(info.extension))
147 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT); 149 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
148 break; 150 break;
149 } 151 }
150 default: 152 default:
151 NOTREACHED(); 153 NOTREACHED();
152 } 154 }
153 } 155 }
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 new base::FundamentalValue(setting)); 194 new base::FundamentalValue(setting));
193 } 195 }
194 } 196 }
195 NotifyObservers(primary_pattern, 197 NotifyObservers(primary_pattern,
196 secondary_pattern, 198 secondary_pattern,
197 CONTENT_SETTINGS_TYPE_PLUGINS, 199 CONTENT_SETTINGS_TYPE_PLUGINS,
198 resource); 200 resource);
199 } 201 }
200 202
201 } // namespace content_settings 203 } // namespace content_settings
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698