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

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

Issue 553263004: Revert of Remove deprecated extension notification from content_settings (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 3 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
« no previous file with comments | « chrome/browser/content_settings/content_settings_internal_extension_provider.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/content_settings/content_settings_rule.h" 7 #include "chrome/browser/content_settings/content_settings_rule.h"
8 #include "chrome/browser/extensions/extension_service.h" 8 #include "chrome/browser/extensions/extension_service.h"
9 #include "chrome/browser/profiles/profile.h"
10 #include "chrome/common/chrome_content_client.h" 9 #include "chrome/common/chrome_content_client.h"
11 #include "chrome/common/extensions/api/plugins/plugins_handler.h" 10 #include "chrome/common/extensions/api/plugins/plugins_handler.h"
12 #include "components/content_settings/core/common/content_settings.h" 11 #include "components/content_settings/core/common/content_settings.h"
13 #include "components/content_settings/core/common/content_settings_pattern.h" 12 #include "components/content_settings/core/common/content_settings_pattern.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"
18 #include "extensions/browser/extension_registry.h"
19 #include "extensions/browser/notification_types.h" 17 #include "extensions/browser/notification_types.h"
20 #include "extensions/common/constants.h" 18 #include "extensions/common/constants.h"
21 #include "extensions/common/extension.h" 19 #include "extensions/common/extension.h"
22 #include "extensions/common/extension_set.h" 20 #include "extensions/common/extension_set.h"
23 #include "extensions/common/features/simple_feature.h" 21 #include "extensions/common/features/simple_feature.h"
24 22
25 using extensions::UnloadedExtensionInfo; 23 using extensions::UnloadedExtensionInfo;
26 24
27 namespace content_settings { 25 namespace content_settings {
28 26
29 InternalExtensionProvider::InternalExtensionProvider( 27 InternalExtensionProvider::InternalExtensionProvider(
30 ExtensionService* extension_service) 28 ExtensionService* extension_service)
31 : registrar_(new content::NotificationRegistrar), 29 : registrar_(new content::NotificationRegistrar) {
32 extension_registry_(
33 extensions::ExtensionRegistry::Get(extension_service->profile())) {
34 // Whitelist all extensions loaded so far. 30 // Whitelist all extensions loaded so far.
35 const extensions::ExtensionSet* extensions = extension_service->extensions(); 31 const extensions::ExtensionSet* extensions = extension_service->extensions();
36 for (extensions::ExtensionSet::const_iterator it = extensions->begin(); 32 for (extensions::ExtensionSet::const_iterator it = extensions->begin();
37 it != extensions->end(); ++it) { 33 it != extensions->end(); ++it) {
38 if (extensions::PluginInfo::HasPlugins(it->get())) 34 if (extensions::PluginInfo::HasPlugins(it->get()))
39 SetContentSettingForExtension(it->get(), CONTENT_SETTING_ALLOW); 35 SetContentSettingForExtension(it->get(), CONTENT_SETTING_ALLOW);
40 } 36 }
41 Profile* profile = extension_service->profile(); 37 Profile* profile = extension_service->profile();
42 registrar_->Add(this, 38 registrar_->Add(this,
43 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, 39 extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
44 content::Source<Profile>(profile)); 40 content::Source<Profile>(profile));
45 41 registrar_->Add(this,
46 extension_registry_->AddObserver(this); 42 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
43 content::Source<Profile>(profile));
44 registrar_->Add(this,
45 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
46 content::Source<Profile>(profile));
47 } 47 }
48 48
49 InternalExtensionProvider::~InternalExtensionProvider() { 49 InternalExtensionProvider::~InternalExtensionProvider() {
50 DCHECK(!registrar_.get()); 50 DCHECK(!registrar_.get());
51 } 51 }
52 52
53 RuleIterator* InternalExtensionProvider::GetRuleIterator( 53 RuleIterator* InternalExtensionProvider::GetRuleIterator(
54 ContentSettingsType content_type, 54 ContentSettingsType content_type,
55 const ResourceIdentifier& resource_identifier, 55 const ResourceIdentifier& resource_identifier,
56 bool incognito) const { 56 bool incognito) const {
57 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_); 57 return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
58 } 58 }
59 59
60 bool InternalExtensionProvider::SetWebsiteSetting( 60 bool InternalExtensionProvider::SetWebsiteSetting(
61 const ContentSettingsPattern& primary_pattern, 61 const ContentSettingsPattern& primary_pattern,
62 const ContentSettingsPattern& secondary_pattern, 62 const ContentSettingsPattern& secondary_pattern,
63 ContentSettingsType content_type, 63 ContentSettingsType content_type,
64 const ResourceIdentifier& resource_identifier, 64 const ResourceIdentifier& resource_identifier,
65 base::Value* value) { 65 base::Value* value) {
66 return false; 66 return false;
67 } 67 }
68 68
69 void InternalExtensionProvider::ClearAllContentSettingsRules( 69 void InternalExtensionProvider::ClearAllContentSettingsRules(
70 ContentSettingsType content_type) {} 70 ContentSettingsType content_type) {}
71 71
72 void InternalExtensionProvider::Observe(int type, 72 void InternalExtensionProvider::Observe(int type,
73 const content::NotificationSource& source, 73 const content::NotificationSource& source,
74 const content::NotificationDetails& details) { 74 const content::NotificationDetails& details) {
75 DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_CREATED, type); 75 switch (type) {
76 const extensions::ExtensionHost* host = 76 case extensions::NOTIFICATION_EXTENSION_HOST_CREATED: {
77 content::Details<extensions::ExtensionHost>(details).ptr(); 77 const extensions::ExtensionHost* host =
78 if (host->extension()->is_platform_app()) { 78 content::Details<extensions::ExtensionHost>(details).ptr();
79 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK); 79 if (host->extension()->is_platform_app()) {
80 SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK);
80 81
81 // 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.
82 const char* kAppWhitelist[] = {"2775E568AC98F9578791F1EAB65A1BF5F8CEF414", 83 const char* kAppWhitelist[] = {
83 "4AA3C5D69A4AECBD236CAD7884502209F0F5C169", 84 "2775E568AC98F9578791F1EAB65A1BF5F8CEF414",
84 "97B23E01B2AA064E8332EE43A7A85C628AADC3F2", 85 "4AA3C5D69A4AECBD236CAD7884502209F0F5C169",
85 "9E930B2B5EABA6243AE6C710F126E54688E8FAF6", 86 "97B23E01B2AA064E8332EE43A7A85C628AADC3F2",
86 "C449A798C495E6CF7D6AF10162113D564E67AD12", 87 "9E930B2B5EABA6243AE6C710F126E54688E8FAF6",
87 "E410CDAB2C6E6DD408D731016CECF2444000A912", 88 "C449A798C495E6CF7D6AF10162113D564E67AD12",
88 "EBA908206905323CECE6DC4B276A58A0F4AC573F", 89 "E410CDAB2C6E6DD408D731016CECF2444000A912",
90 "EBA908206905323CECE6DC4B276A58A0F4AC573F",
89 91
90 // http://crbug.com/327507 92 // http://crbug.com/327507
91 "FAFE8EFDD2D6AE2EEB277AFEB91C870C79064D9E", 93 "FAFE8EFDD2D6AE2EEB277AFEB91C870C79064D9E",
92 "3B52D273A271D4E2348233E322426DBAE854B567", 94 "3B52D273A271D4E2348233E322426DBAE854B567",
93 "5DF6ADC8708DF59FCFDDBF16AFBFB451380C2059", 95 "5DF6ADC8708DF59FCFDDBF16AFBFB451380C2059",
94 "1037DEF5F6B06EA46153AD87B6C5C37440E3F2D1", 96 "1037DEF5F6B06EA46153AD87B6C5C37440E3F2D1",
95 "F5815DAFEB8C53B078DD1853B2059E087C42F139", 97 "F5815DAFEB8C53B078DD1853B2059E087C42F139",
96 "6A08EFFF9C16E090D6DCC7EC55A01CADAE840513", 98 "6A08EFFF9C16E090D6DCC7EC55A01CADAE840513",
97 99
98 // http://crbug.com/354258 100 // http://crbug.com/354258
99 "C32D6D93E12F5401DAA3A723E0C3CC5F25429BA4", 101 "C32D6D93E12F5401DAA3A723E0C3CC5F25429BA4",
100 "9099782647D39C778E15C8C6E0D23C88F5CDE170", 102 "9099782647D39C778E15C8C6E0D23C88F5CDE170",
101 "B7D5B52D1E5B106288BD7F278CAFA5E8D76108B0", 103 "B7D5B52D1E5B106288BD7F278CAFA5E8D76108B0",
102 "89349DBAA2C4022FB244AA50182AB60934EB41EE", 104 "89349DBAA2C4022FB244AA50182AB60934EB41EE",
103 "CB593E510640572A995CB1B6D41BD85ED51E63F8", 105 "CB593E510640572A995CB1B6D41BD85ED51E63F8",
104 "1AD1AC86C87969CD3434FA08D99DBA6840AEA612", 106 "1AD1AC86C87969CD3434FA08D99DBA6840AEA612",
105 "9C2EA21D7975BDF2B3C01C3A454EE44854067A6D", 107 "9C2EA21D7975BDF2B3C01C3A454EE44854067A6D",
106 "D2C488C80C3C90C3E01A991112A05E37831E17D0", 108 "D2C488C80C3C90C3E01A991112A05E37831E17D0",
107 "6EEC061C0E74B46C7B5BE2EEFA49436368F4988F", 109 "6EEC061C0E74B46C7B5BE2EEFA49436368F4988F",
108 "8B344D9E8A4C505EF82A0DBBC25B8BD1F984E777", 110 "8B344D9E8A4C505EF82A0DBBC25B8BD1F984E777",
109 "E06AFCB1EB0EFD237824CC4AC8FDD3D43E8BC868", 111 "E06AFCB1EB0EFD237824CC4AC8FDD3D43E8BC868",
110 112
111 // http://crbug.com/386324 113 // http://crbug.com/386324
112 "F76F43EFFF56BF17A9868A5243F339BA28746632", 114 "F76F43EFFF56BF17A9868A5243F339BA28746632",
113 "C6EA52B92F80878515F94137020F01519357E5B5", 115 "C6EA52B92F80878515F94137020F01519357E5B5",
114 "E466389F058ABD73FF6FDD06F768A351FCBF8532", 116 "E466389F058ABD73FF6FDD06F768A351FCBF8532",
115 "40063F1CF7B68BA847A26FA6620DDF156171D23C", 117 "40063F1CF7B68BA847A26FA6620DDF156171D23C",
116 "A6FD8E15353CF1F5C3D0A7B20E1D10AEA4DD3E6A", 118 "A6FD8E15353CF1F5C3D0A7B20E1D10AEA4DD3E6A",
117 "57AC4D9E6BD8A2D0A70056B5FAC2378CAA588912", 119 "57AC4D9E6BD8A2D0A70056B5FAC2378CAA588912",
118 "02037314DA4D913640DCF0E296A7D01F4FD793EC", 120 "02037314DA4D913640DCF0E296A7D01F4FD793EC",
119 "B6EC0809BC63E10B431C5E4AA3645232CA86B2A5", 121 "B6EC0809BC63E10B431C5E4AA3645232CA86B2A5",
120 "48CA541313139786F056DBCB504A1025CFF5D2E3", 122 "48CA541313139786F056DBCB504A1025CFF5D2E3",
121 "05106136AE7F08A3C181D4648E5438350B1D2B4F"}; 123 "05106136AE7F08A3C181D4648E5438350B1D2B4F"
122 if (extensions::SimpleFeature::IsIdInList( 124 };
123 host->extension()->id(), 125 if (extensions::SimpleFeature::IsIdInList(
124 std::set<std::string>(kAppWhitelist, 126 host->extension()->id(),
125 kAppWhitelist + arraysize(kAppWhitelist)))) { 127 std::set<std::string>(
126 SetContentSettingForExtensionAndResource( 128 kAppWhitelist, kAppWhitelist + arraysize(kAppWhitelist)))) {
127 host->extension(), 129 SetContentSettingForExtensionAndResource(
128 ChromeContentClient::kRemotingViewerPluginPath, 130 host->extension(),
129 CONTENT_SETTING_ALLOW); 131 ChromeContentClient::kRemotingViewerPluginPath,
132 CONTENT_SETTING_ALLOW);
133 }
134 }
135
136 break;
130 } 137 }
138 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
139 const extensions::Extension* extension =
140 content::Details<extensions::Extension>(details).ptr();
141 if (extensions::PluginInfo::HasPlugins(extension))
142 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
143 break;
144 }
145 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
146 const UnloadedExtensionInfo& info =
147 *(content::Details<UnloadedExtensionInfo>(details).ptr());
148 if (extensions::PluginInfo::HasPlugins(info.extension))
149 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
150 break;
151 }
152 default:
153 NOTREACHED();
131 } 154 }
132 } 155 }
133 156
134 void InternalExtensionProvider::OnExtensionLoaded(
135 content::BrowserContext* browser_context,
136 const extensions::Extension* extension) {
137 if (extensions::PluginInfo::HasPlugins(extension))
138 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
139 }
140
141 void InternalExtensionProvider::OnExtensionUnloaded(
142 content::BrowserContext* browser_context,
143 const extensions::Extension* extension,
144 extensions::UnloadedExtensionInfo::Reason reason) {
145 if (extensions::PluginInfo::HasPlugins(extension))
146 SetContentSettingForExtension(extension, CONTENT_SETTING_DEFAULT);
147 }
148
149 void InternalExtensionProvider::ShutdownOnUIThread() { 157 void InternalExtensionProvider::ShutdownOnUIThread() {
150 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 158 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
151 RemoveAllObservers(); 159 RemoveAllObservers();
152 registrar_.reset(); 160 registrar_.reset();
153 extension_registry_->RemoveObserver(this);
154 } 161 }
155 162
156 void InternalExtensionProvider::SetContentSettingForExtension( 163 void InternalExtensionProvider::SetContentSettingForExtension(
157 const extensions::Extension* extension, 164 const extensions::Extension* extension,
158 ContentSetting setting) { 165 ContentSetting setting) {
159 SetContentSettingForExtensionAndResource( 166 SetContentSettingForExtensionAndResource(
160 extension, ResourceIdentifier(), setting); 167 extension, ResourceIdentifier(), setting);
161 } 168 }
162 169
163 void InternalExtensionProvider::SetContentSettingForExtensionAndResource( 170 void InternalExtensionProvider::SetContentSettingForExtensionAndResource(
(...skipping 23 matching lines...) Expand all
187 new base::FundamentalValue(setting)); 194 new base::FundamentalValue(setting));
188 } 195 }
189 } 196 }
190 NotifyObservers(primary_pattern, 197 NotifyObservers(primary_pattern,
191 secondary_pattern, 198 secondary_pattern,
192 CONTENT_SETTINGS_TYPE_PLUGINS, 199 CONTENT_SETTINGS_TYPE_PLUGINS,
193 resource); 200 resource);
194 } 201 }
195 202
196 } // namespace content_settings 203 } // namespace content_settings
OLDNEW
« no previous file with comments | « chrome/browser/content_settings/content_settings_internal_extension_provider.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698