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

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

Issue 794903005: Whiltelist the remoting viewer for the Chromoting extension (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: updates Created 6 years 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/profiles/profile.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/extension_registry.h"
17 #include "extensions/browser/notification_types.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 namespace {
28
29 // This is the set of extensions that are allowed to access the internal
30 // remoting viewer plugin.
31 const char* kRemotingViewerWhitelist[] = {
32 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
33 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop
34 "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
35 "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
36 };
37
38 } // namespace
39
40
27 InternalExtensionProvider::InternalExtensionProvider(Profile* profile) 41 InternalExtensionProvider::InternalExtensionProvider(Profile* profile)
28 : registrar_(new content::NotificationRegistrar) { 42 : registrar_(new content::NotificationRegistrar) {
43 for (size_t i = 0; i < arraysize(kRemotingViewerWhitelist); ++i)
44 chrome_remote_desktop_.insert(kRemotingViewerWhitelist[i]);
45
29 // Whitelist all extensions loaded so far. 46 // Whitelist all extensions loaded so far.
30 for (const scoped_refptr<const extensions::Extension>& extension : 47 for (const scoped_refptr<const extensions::Extension>& extension :
31 extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) { 48 extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) {
32 if (extensions::PluginInfo::HasPlugins(extension.get())) 49 ApplyPluginContentSettingsForExtension(extension.get(),
33 SetContentSettingForExtension(extension.get(), CONTENT_SETTING_ALLOW); 50 CONTENT_SETTING_ALLOW);
34 } 51 }
35 registrar_->Add(this, 52 registrar_->Add(this,
36 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, 53 extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
37 content::Source<Profile>(profile)); 54 content::Source<Profile>(profile));
38 registrar_->Add(this, 55 registrar_->Add(this,
39 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 56 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
40 content::Source<Profile>(profile)); 57 content::Source<Profile>(profile));
41 registrar_->Add(this, 58 registrar_->Add(this,
42 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 59 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
43 content::Source<Profile>(profile)); 60 content::Source<Profile>(profile));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 ChromeContentClient::kRemotingViewerPluginPath, 145 ChromeContentClient::kRemotingViewerPluginPath,
129 CONTENT_SETTING_ALLOW); 146 CONTENT_SETTING_ALLOW);
130 } 147 }
131 } 148 }
132 149
133 break; 150 break;
134 } 151 }
135 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { 152 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
136 const extensions::Extension* extension = 153 const extensions::Extension* extension =
137 content::Details<extensions::Extension>(details).ptr(); 154 content::Details<extensions::Extension>(details).ptr();
138 if (extensions::PluginInfo::HasPlugins(extension)) 155 ApplyPluginContentSettingsForExtension(extension, CONTENT_SETTING_ALLOW);
139 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
140 break; 156 break;
141 } 157 }
142 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { 158 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
143 const UnloadedExtensionInfo& info = 159 const UnloadedExtensionInfo& info =
144 *(content::Details<UnloadedExtensionInfo>(details).ptr()); 160 *(content::Details<UnloadedExtensionInfo>(details).ptr());
145 if (extensions::PluginInfo::HasPlugins(info.extension)) 161 ApplyPluginContentSettingsForExtension(info.extension,
146 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT); 162 CONTENT_SETTING_DEFAULT);
147 break; 163 break;
148 } 164 }
149 default: 165 default:
150 NOTREACHED(); 166 NOTREACHED();
151 } 167 }
152 } 168 }
153 169
154 void InternalExtensionProvider::ShutdownOnUIThread() { 170 void InternalExtensionProvider::ShutdownOnUIThread() {
155 DCHECK(CalledOnValidThread()); 171 DCHECK(CalledOnValidThread());
156 RemoveAllObservers(); 172 RemoveAllObservers();
157 registrar_.reset(); 173 registrar_.reset();
158 } 174 }
159 175
176 void InternalExtensionProvider::ApplyPluginContentSettingsForExtension(
177 const extensions::Extension* extension,
178 ContentSetting setting) {
179 if (extensions::PluginInfo::HasPlugins(extension))
180 SetContentSettingForExtension(extension, setting);
181
182 if (chrome_remote_desktop_.find(extension->id()) !=
Bernhard Bauer 2014/12/12 15:00:46 Add a comment that explains the stuff from the CL
183 chrome_remote_desktop_.end()) {
184 SetContentSettingForExtensionAndResource(
185 extension, ChromeContentClient::kRemotingViewerPluginPath, setting);
186 }
187 }
188
160 void InternalExtensionProvider::SetContentSettingForExtension( 189 void InternalExtensionProvider::SetContentSettingForExtension(
161 const extensions::Extension* extension, 190 const extensions::Extension* extension,
162 ContentSetting setting) { 191 ContentSetting setting) {
163 SetContentSettingForExtensionAndResource( 192 SetContentSettingForExtensionAndResource(
164 extension, ResourceIdentifier(), setting); 193 extension, ResourceIdentifier(), setting);
165 } 194 }
166 195
167 void InternalExtensionProvider::SetContentSettingForExtensionAndResource( 196 void InternalExtensionProvider::SetContentSettingForExtensionAndResource(
168 const extensions::Extension* extension, 197 const extensions::Extension* extension,
169 const ResourceIdentifier& resource, 198 const ResourceIdentifier& resource,
(...skipping 21 matching lines...) Expand all
191 new base::FundamentalValue(setting)); 220 new base::FundamentalValue(setting));
192 } 221 }
193 } 222 }
194 NotifyObservers(primary_pattern, 223 NotifyObservers(primary_pattern,
195 secondary_pattern, 224 secondary_pattern,
196 CONTENT_SETTINGS_TYPE_PLUGINS, 225 CONTENT_SETTINGS_TYPE_PLUGINS,
197 resource); 226 resource);
198 } 227 }
199 228
200 } // namespace content_settings 229 } // 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