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

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: 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 const char* kRemotingViewerWhitelist[] = {
30 "gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
Bernhard Bauer 2014/12/12 14:44:37 I never know how whether these initializer lists a
31 "kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote
32 // Desktop
33 "odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
34 "ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
35 };
36
37 } // namespace
38
39
27 InternalExtensionProvider::InternalExtensionProvider(Profile* profile) 40 InternalExtensionProvider::InternalExtensionProvider(Profile* profile)
28 : registrar_(new content::NotificationRegistrar) { 41 : registrar_(new content::NotificationRegistrar) {
42 for (size_t i = 0; i < arraysize(kRemotingViewerWhitelist); ++i)
43 chrome_remote_desktop_.insert(kRemotingViewerWhitelist[i]);
44
29 // Whitelist all extensions loaded so far. 45 // Whitelist all extensions loaded so far.
30 for (const scoped_refptr<const extensions::Extension>& extension : 46 for (const scoped_refptr<const extensions::Extension>& extension :
31 extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) { 47 extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) {
32 if (extensions::PluginInfo::HasPlugins(extension.get())) 48 if (extensions::PluginInfo::HasPlugins(extension.get()))
33 SetContentSettingForExtension(extension.get(), CONTENT_SETTING_ALLOW); 49 SetContentSettingForExtension(extension.get(), CONTENT_SETTING_ALLOW);
50
51 // Allow the Chrome Remote Desktop extension to load its internal plugin.
Bernhard Bauer 2014/12/12 14:44:37 This seems like it could be extracted into a helpe
52 if (chrome_remote_desktop_.find(extension.get()->id()) !=
53 chrome_remote_desktop_.end()) {
54 SetContentSettingForExtensionAndResource(
55 extension.get(), ChromeContentClient::kRemotingViewerPluginPath,
56 CONTENT_SETTING_ALLOW);
57 }
34 } 58 }
35 registrar_->Add(this, 59 registrar_->Add(this,
36 extensions::NOTIFICATION_EXTENSION_HOST_CREATED, 60 extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
37 content::Source<Profile>(profile)); 61 content::Source<Profile>(profile));
38 registrar_->Add(this, 62 registrar_->Add(this,
39 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED, 63 extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED,
40 content::Source<Profile>(profile)); 64 content::Source<Profile>(profile));
41 registrar_->Add(this, 65 registrar_->Add(this,
42 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED, 66 extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED,
43 content::Source<Profile>(profile)); 67 content::Source<Profile>(profile));
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 154 }
131 } 155 }
132 156
133 break; 157 break;
134 } 158 }
135 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: { 159 case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
136 const extensions::Extension* extension = 160 const extensions::Extension* extension =
137 content::Details<extensions::Extension>(details).ptr(); 161 content::Details<extensions::Extension>(details).ptr();
138 if (extensions::PluginInfo::HasPlugins(extension)) 162 if (extensions::PluginInfo::HasPlugins(extension))
139 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW); 163 SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
164
165 // Allow the Chrome Remote Desktop extension to load its internal plugin.
166 if (chrome_remote_desktop_.find(extension->id()) !=
167 chrome_remote_desktop_.end()) {
168 SetContentSettingForExtensionAndResource(
169 extension, ChromeContentClient::kRemotingViewerPluginPath,
170 CONTENT_SETTING_ALLOW);
171 }
140 break; 172 break;
141 } 173 }
142 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: { 174 case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
143 const UnloadedExtensionInfo& info = 175 const UnloadedExtensionInfo& info =
144 *(content::Details<UnloadedExtensionInfo>(details).ptr()); 176 *(content::Details<UnloadedExtensionInfo>(details).ptr());
145 if (extensions::PluginInfo::HasPlugins(info.extension)) 177 if (extensions::PluginInfo::HasPlugins(info.extension))
146 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT); 178 SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
179
180 if (chrome_remote_desktop_.find(info.extension->id()) !=
181 chrome_remote_desktop_.end()) {
182 SetContentSettingForExtensionAndResource(
183 info.extension, ChromeContentClient::kRemotingViewerPluginPath,
184 CONTENT_SETTING_DEFAULT);
185 }
147 break; 186 break;
148 } 187 }
149 default: 188 default:
150 NOTREACHED(); 189 NOTREACHED();
151 } 190 }
152 } 191 }
153 192
154 void InternalExtensionProvider::ShutdownOnUIThread() { 193 void InternalExtensionProvider::ShutdownOnUIThread() {
155 DCHECK(CalledOnValidThread()); 194 DCHECK(CalledOnValidThread());
156 RemoveAllObservers(); 195 RemoveAllObservers();
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 new base::FundamentalValue(setting)); 230 new base::FundamentalValue(setting));
192 } 231 }
193 } 232 }
194 NotifyObservers(primary_pattern, 233 NotifyObservers(primary_pattern,
195 secondary_pattern, 234 secondary_pattern,
196 CONTENT_SETTINGS_TYPE_PLUGINS, 235 CONTENT_SETTINGS_TYPE_PLUGINS,
197 resource); 236 resource);
198 } 237 }
199 238
200 } // namespace content_settings 239 } // 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