Commit 8731dbe9 authored by jochen's avatar jochen Committed by Commit bot

Whiltelist the remoting viewer for the Chromoting extension

Extensions that ship with plugins may use them. Since the viewer is a
builtin plugin, it doesn't get whitelisted by the usual mechanism.
Explicitly whiltelist it.

BUG=409813
R=bauerb@chromium.org

Review URL: https://codereview.chromium.org/794903005

Cr-Commit-Position: refs/heads/master@{#308102}
parent 8e2eaabf
......@@ -24,13 +24,30 @@ using extensions::UnloadedExtensionInfo;
namespace content_settings {
namespace {
// This is the set of extensions that are allowed to access the internal
// remoting viewer plugin.
const char* kRemotingViewerWhitelist[] = {
"gbchcmhmhahfdphkhkmpfmihenigjmpp", // Chrome Remote Desktop
"kgngmbheleoaphbjbaiobfdepmghbfah", // Pre-release Chrome Remote Desktop
"odkaodonbgfohohmklejpjiejmcipmib", // Dogfood Chrome Remote Desktop
"ojoimpklfciegopdfgeenehpalipignm", // Chromoting canary
};
} // namespace
InternalExtensionProvider::InternalExtensionProvider(Profile* profile)
: registrar_(new content::NotificationRegistrar) {
for (size_t i = 0; i < arraysize(kRemotingViewerWhitelist); ++i)
chrome_remote_desktop_.insert(kRemotingViewerWhitelist[i]);
// Whitelist all extensions loaded so far.
for (const scoped_refptr<const extensions::Extension>& extension :
extensions::ExtensionRegistry::Get(profile)->enabled_extensions()) {
if (extensions::PluginInfo::HasPlugins(extension.get()))
SetContentSettingForExtension(extension.get(), CONTENT_SETTING_ALLOW);
ApplyPluginContentSettingsForExtension(extension.get(),
CONTENT_SETTING_ALLOW);
}
registrar_->Add(this,
extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
......@@ -135,15 +152,14 @@ void InternalExtensionProvider::Observe(int type,
case extensions::NOTIFICATION_EXTENSION_LOADED_DEPRECATED: {
const extensions::Extension* extension =
content::Details<extensions::Extension>(details).ptr();
if (extensions::PluginInfo::HasPlugins(extension))
SetContentSettingForExtension(extension, CONTENT_SETTING_ALLOW);
ApplyPluginContentSettingsForExtension(extension, CONTENT_SETTING_ALLOW);
break;
}
case extensions::NOTIFICATION_EXTENSION_UNLOADED_DEPRECATED: {
const UnloadedExtensionInfo& info =
*(content::Details<UnloadedExtensionInfo>(details).ptr());
if (extensions::PluginInfo::HasPlugins(info.extension))
SetContentSettingForExtension(info.extension, CONTENT_SETTING_DEFAULT);
ApplyPluginContentSettingsForExtension(info.extension,
CONTENT_SETTING_DEFAULT);
break;
}
default:
......@@ -157,6 +173,21 @@ void InternalExtensionProvider::ShutdownOnUIThread() {
registrar_.reset();
}
void InternalExtensionProvider::ApplyPluginContentSettingsForExtension(
const extensions::Extension* extension,
ContentSetting setting) {
if (extensions::PluginInfo::HasPlugins(extension))
SetContentSettingForExtension(extension, setting);
// Chrome Remove Desktop relies on the remoting viewer plugin. The
// above check does not catch this, as the plugin is a builtin plugin.
if (chrome_remote_desktop_.find(extension->id()) !=
chrome_remote_desktop_.end()) {
SetContentSettingForExtensionAndResource(
extension, ChromeContentClient::kRemotingViewerPluginPath, setting);
}
}
void InternalExtensionProvider::SetContentSettingForExtension(
const extensions::Extension* extension,
ContentSetting setting) {
......
......@@ -5,6 +5,9 @@
#ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
#include <set>
#include <string>
#include "base/memory/scoped_ptr.h"
#include "base/synchronization/lock.h"
#include "components/content_settings/core/browser/content_settings_observable_provider.h"
......@@ -50,6 +53,9 @@ class InternalExtensionProvider : public ObservableProvider,
const content::NotificationDetails& details) override;
private:
void ApplyPluginContentSettingsForExtension(
const extensions::Extension* extension,
ContentSetting setting);
void SetContentSettingForExtension(const extensions::Extension* extension,
ContentSetting setting);
void SetContentSettingForExtensionAndResource(
......@@ -63,6 +69,9 @@ class InternalExtensionProvider : public ObservableProvider,
mutable base::Lock lock_;
scoped_ptr<content::NotificationRegistrar> registrar_;
// Extension IDs used by the Chrome Remote Desktop app.
std::set<std::string> chrome_remote_desktop_;
DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider);
};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment