Commit 7bfd0bc8 authored by Ben Wells's avatar Ben Wells Committed by Commit Bot

Remove the internal extensions content settings provider.

This was only used for plugin settings, which are not needed any more.

Bug: 754178
Change-Id: I24a9d1d08fd5a00fca088ed7ac212148af6c30e0
Reviewed-on: https://chromium-review.googlesource.com/773898
Commit-Queue: Ben Wells <benwells@chromium.org>
Reviewed-by: default avatarRaymes Khoury <raymes@chromium.org>
Reviewed-by: default avatarLei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/master@{#517742}
parent 27d7d5f5
......@@ -3309,8 +3309,6 @@ split_static_library("browser") {
"autocomplete/shortcuts_extensions_manager.h",
"browsing_data/hosted_apps_counter.cc",
"browsing_data/hosted_apps_counter.h",
"content_settings/content_settings_internal_extension_provider.cc",
"content_settings/content_settings_internal_extension_provider.h",
"drive/drive_notification_manager_factory.cc",
"drive/drive_notification_manager_factory.h",
"guest_view/app_view/chrome_app_view_guest_delegate.cc",
......
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/content_settings/content_settings_internal_extension_provider.h"
#include <stddef.h>
#include "base/macros.h"
#include "chrome/browser/pdf/pdf_extension_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/chrome_content_client.h"
#include "components/content_settings/core/browser/content_settings_info.h"
#include "components/content_settings/core/browser/content_settings_registry.h"
#include "components/content_settings/core/browser/content_settings_rule.h"
#include "components/content_settings/core/common/content_settings.h"
#include "components/content_settings/core/common/content_settings_pattern.h"
#include "content/public/browser/notification_details.h"
#include "content/public/browser/notification_service.h"
#include "extensions/browser/extension_host.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/browser/notification_types.h"
#include "extensions/common/constants.h"
#include "extensions/common/extension.h"
#include "extensions/common/extension_set.h"
#include "extensions/common/features/simple_feature.h"
#include "extensions/common/manifest_handlers/plugins_handler.h"
namespace content_settings {
namespace {
// This is the set of extensions that are allowed to access the internal
// remoting viewer plugin.
const char* const 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),
extension_registry_(extensions::ExtensionRegistry::Get(profile)) {
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()) {
ApplyPluginContentSettingsForExtension(extension.get(),
CONTENT_SETTING_ALLOW);
}
registrar_->Add(this,
extensions::NOTIFICATION_EXTENSION_HOST_CREATED,
content::Source<Profile>(profile));
extension_registry_->AddObserver(this);
}
InternalExtensionProvider::~InternalExtensionProvider() {
DCHECK(!registrar_.get());
}
std::unique_ptr<RuleIterator> InternalExtensionProvider::GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
bool incognito) const {
return value_map_.GetRuleIterator(content_type, resource_identifier, &lock_);
}
bool InternalExtensionProvider::SetWebsiteSetting(
const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
base::Value* value) {
return false;
}
void InternalExtensionProvider::ClearAllContentSettingsRules(
ContentSettingsType content_type) {}
void InternalExtensionProvider::Observe(
int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) {
DCHECK_EQ(extensions::NOTIFICATION_EXTENSION_HOST_CREATED, type);
const extensions::ExtensionHost* host =
content::Details<extensions::ExtensionHost>(details).ptr();
if (host->extension()->is_platform_app()) {
SetContentSettingForExtension(host->extension(), CONTENT_SETTING_BLOCK);
// White-list CRD's v2 app, until crbug.com/134216 is complete.
const char* const kAppWhitelist[] = {
"2775E568AC98F9578791F1EAB65A1BF5F8CEF414",
"4AA3C5D69A4AECBD236CAD7884502209F0F5C169",
"97B23E01B2AA064E8332EE43A7A85C628AADC3F2",
"9E930B2B5EABA6243AE6C710F126E54688E8FAF6",
"C449A798C495E6CF7D6AF10162113D564E67AD12",
"E410CDAB2C6E6DD408D731016CECF2444000A912",
"EBA908206905323CECE6DC4B276A58A0F4AC573F",
// http://crbug.com/327507
"FAFE8EFDD2D6AE2EEB277AFEB91C870C79064D9E",
"3B52D273A271D4E2348233E322426DBAE854B567",
"5DF6ADC8708DF59FCFDDBF16AFBFB451380C2059",
"1037DEF5F6B06EA46153AD87B6C5C37440E3F2D1",
"F5815DAFEB8C53B078DD1853B2059E087C42F139",
"6A08EFFF9C16E090D6DCC7EC55A01CADAE840513",
// http://crbug.com/354258
"C32D6D93E12F5401DAA3A723E0C3CC5F25429BA4",
"9099782647D39C778E15C8C6E0D23C88F5CDE170",
"B7D5B52D1E5B106288BD7F278CAFA5E8D76108B0",
"89349DBAA2C4022FB244AA50182AB60934EB41EE",
"CB593E510640572A995CB1B6D41BD85ED51E63F8",
"1AD1AC86C87969CD3434FA08D99DBA6840AEA612",
"9C2EA21D7975BDF2B3C01C3A454EE44854067A6D",
"D2C488C80C3C90C3E01A991112A05E37831E17D0",
"6EEC061C0E74B46C7B5BE2EEFA49436368F4988F",
"8B344D9E8A4C505EF82A0DBBC25B8BD1F984E777",
"E06AFCB1EB0EFD237824CC4AC8FDD3D43E8BC868",
// http://crbug.com/386324
"F76F43EFFF56BF17A9868A5243F339BA28746632",
"C6EA52B92F80878515F94137020F01519357E5B5",
"E466389F058ABD73FF6FDD06F768A351FCBF8532",
"40063F1CF7B68BA847A26FA6620DDF156171D23C",
"A6FD8E15353CF1F5C3D0A7B20E1D10AEA4DD3E6A",
"57AC4D9E6BD8A2D0A70056B5FAC2378CAA588912",
"02037314DA4D913640DCF0E296A7D01F4FD793EC",
"B6EC0809BC63E10B431C5E4AA3645232CA86B2A5",
"48CA541313139786F056DBCB504A1025CFF5D2E3",
"05106136AE7F08A3C181D4648E5438350B1D2B4F"};
if (extensions::SimpleFeature::IsIdInArray(
host->extension()->id(), kAppWhitelist, arraysize(kAppWhitelist))) {
SetContentSettingForExtensionAndResource(
host->extension(), ChromeContentClient::kRemotingViewerPluginPath,
CONTENT_SETTING_ALLOW);
}
}
}
void InternalExtensionProvider::OnExtensionLoaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension) {
ApplyPluginContentSettingsForExtension(extension, CONTENT_SETTING_ALLOW);
}
void InternalExtensionProvider::OnExtensionUnloaded(
content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionReason reason) {
ApplyPluginContentSettingsForExtension(extension, CONTENT_SETTING_DEFAULT);
}
void InternalExtensionProvider::ShutdownOnUIThread() {
DCHECK(CalledOnValidThread());
RemoveAllObservers();
registrar_.reset();
extension_registry_->RemoveObserver(this);
}
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);
}
// The PDF viewer extension relies on the out of process PDF plugin.
if (extension->id() == extension_misc::kPdfExtensionId) {
SetContentSettingForExtensionAndResource(
extension, pdf_extension_util::kPdfResourceIdentifier, setting);
}
}
void InternalExtensionProvider::SetContentSettingForExtension(
const extensions::Extension* extension,
ContentSetting setting) {
SetContentSettingForExtensionAndResource(
extension, ResourceIdentifier(), setting);
}
void InternalExtensionProvider::SetContentSettingForExtensionAndResource(
const extensions::Extension* extension,
const ResourceIdentifier& resource,
ContentSetting setting) {
std::unique_ptr<ContentSettingsPattern::BuilderInterface> pattern_builder =
ContentSettingsPattern::CreateBuilder();
pattern_builder->WithScheme(extensions::kExtensionScheme);
pattern_builder->WithHost(extension->id());
pattern_builder->WithPathWildcard();
ContentSettingsPattern primary_pattern = pattern_builder->Build();
ContentSettingsPattern secondary_pattern = ContentSettingsPattern::Wildcard();
{
base::AutoLock lock(lock_);
if (setting == CONTENT_SETTING_DEFAULT) {
value_map_.DeleteValue(primary_pattern,
secondary_pattern,
CONTENT_SETTINGS_TYPE_PLUGINS,
resource);
} else {
DCHECK(content_settings::ContentSettingsRegistry::GetInstance()
->Get(CONTENT_SETTINGS_TYPE_PLUGINS)
->IsSettingValid(setting));
// Do not set a timestamp for extension settings.
value_map_.SetValue(primary_pattern, secondary_pattern,
CONTENT_SETTINGS_TYPE_PLUGINS, resource, base::Time(),
new base::Value(setting));
}
}
NotifyObservers(primary_pattern,
secondary_pattern,
CONTENT_SETTINGS_TYPE_PLUGINS,
resource);
}
} // namespace content_settings
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
#define CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
#include <memory>
#include <set>
#include <string>
#include "base/macros.h"
#include "base/synchronization/lock.h"
#include "components/content_settings/core/browser/content_settings_observable_provider.h"
#include "components/content_settings/core/browser/content_settings_origin_identifier_value_map.h"
#include "components/content_settings/core/common/content_settings.h"
#include "content/public/browser/notification_observer.h"
#include "content/public/browser/notification_registrar.h"
#include "extensions/browser/extension_registry_observer.h"
class Profile;
namespace extensions {
class Extension;
class ExtensionRegistry;
}
namespace content_settings {
// A content settings provider which disables certain plugins for platform apps.
class InternalExtensionProvider : public ObservableProvider,
public content::NotificationObserver,
public extensions::ExtensionRegistryObserver {
public:
explicit InternalExtensionProvider(Profile* profile);
~InternalExtensionProvider() override;
// ProviderInterface methods:
std::unique_ptr<RuleIterator> GetRuleIterator(
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
bool incognito) const override;
bool SetWebsiteSetting(const ContentSettingsPattern& primary_pattern,
const ContentSettingsPattern& secondary_pattern,
ContentSettingsType content_type,
const ResourceIdentifier& resource_identifier,
base::Value* value) override;
void ClearAllContentSettingsRules(ContentSettingsType content_type) override;
void ShutdownOnUIThread() override;
// content::NotificationObserver implementation.
void Observe(int type,
const content::NotificationSource& source,
const content::NotificationDetails& details) override;
// extensions::ExtensionRegistryObserver implementation.
void OnExtensionLoaded(content::BrowserContext* browser_context,
const extensions::Extension* extension) override;
void OnExtensionUnloaded(content::BrowserContext* browser_context,
const extensions::Extension* extension,
extensions::UnloadedExtensionReason reason) override;
private:
void ApplyPluginContentSettingsForExtension(
const extensions::Extension* extension,
ContentSetting setting);
void SetContentSettingForExtension(const extensions::Extension* extension,
ContentSetting setting);
void SetContentSettingForExtensionAndResource(
const extensions::Extension* extension,
const ResourceIdentifier& resource,
ContentSetting setting);
OriginIdentifierValueMap value_map_;
// Used around accesses to the |value_map_| list to guarantee thread safety.
mutable base::Lock lock_;
std::unique_ptr<content::NotificationRegistrar> registrar_;
// Extension IDs used by the Chrome Remote Desktop app.
std::set<std::string> chrome_remote_desktop_;
extensions::ExtensionRegistry* extension_registry_;
DISALLOW_COPY_AND_ASSIGN(InternalExtensionProvider);
};
} // namespace content_settings
#endif // CHROME_BROWSER_CONTENT_SETTINGS_CONTENT_SETTINGS_INTERNAL_EXTENSION_PROVIDER_H_
......@@ -30,7 +30,6 @@
#include "build/build_config.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/content_settings_internal_extension_provider.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_custom_extension_provider.h"
#include "chrome/browser/extensions/api/content_settings/content_settings_service.h"
#include "chrome/browser/extensions/app_data_migrator.h"
......@@ -1846,11 +1845,6 @@ void ExtensionService::RegisterContentSettings(
TRACE_EVENT0("browser,startup", "ExtensionService::RegisterContentSettings");
DCHECK_CURRENTLY_ON(BrowserThread::UI);
host_content_settings_map->RegisterProvider(
HostContentSettingsMap::INTERNAL_EXTENSION_PROVIDER,
std::unique_ptr<content_settings::ObservableProvider>(
new content_settings::InternalExtensionProvider(original_profile)));
host_content_settings_map->RegisterProvider(
HostContentSettingsMap::CUSTOM_EXTENSION_PROVIDER,
std::unique_ptr<content_settings::ObservableProvider>(
......
......@@ -18,14 +18,6 @@ const char kNameTag[] = "<NAME>";
} // namespace
// These should match the keys for the Chrome and Chromium PDF Viewer entries in
// chrome/browser/resources/plugin_metadata/plugins_*.json.
#if defined(GOOGLE_CHROME_BUILD)
const char kPdfResourceIdentifier[] = "google-chrome-pdf";
#else
const char kPdfResourceIdentifier[] = "chromium-pdf";
#endif
std::string GetManifest() {
std::string manifest_contents = ui::ResourceBundle::GetSharedInstance()
.GetRawDataResource(IDR_PDF_MANIFEST)
......
......@@ -9,9 +9,6 @@
namespace pdf_extension_util {
// The ResourceIdentifier for the PDF Viewer plugin.
extern const char kPdfResourceIdentifier[];
// Return the extensions manifest for PDF. The manifest is loaded from
// browser_resources.grd and certain fields are replaced based on what chrome
// flags are enabled.
......
......@@ -38,7 +38,6 @@ class ChromeContentClient : public content::ContentClient {
static const char kPDFExtensionPluginName[];
static const char kPDFInternalPluginName[];
static const char kPDFPluginPath[];
static const char kRemotingViewerPluginPath[];
ChromeContentClient();
~ChromeContentClient() override;
......
......@@ -15,5 +15,3 @@ const char ChromeContentClient::kPDFInternalPluginName[] =
"Chromium PDF Plugin";
#endif
const char ChromeContentClient::kPDFPluginPath[] = "internal-pdf-viewer";
const char ChromeContentClient::kRemotingViewerPluginPath[] =
"internal-remoting-viewer";
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