Commit 729f299a authored by Nicholas Verne's avatar Nicholas Verne Committed by Commit Bot

mojo IsInternalPluginAvailableForMimeType

We can now rename PluginInfoMessageFilter to PluginInfoHostImpl.

Bug: 577685
Change-Id: If95632401e048bbf7f756912dd59e6c399f433c3
Reviewed-on: https://chromium-review.googlesource.com/759621Reviewed-by: default avatarWill Harris <wfh@chromium.org>
Reviewed-by: default avatarSam McNally <sammc@chromium.org>
Reviewed-by: default avatarJohn Abd-El-Malek <jam@chromium.org>
Commit-Queue: Nicholas Verne <nverne@chromium.org>
Cr-Commit-Position: refs/heads/master@{#515838}
parent a627a65c
...@@ -3688,8 +3688,8 @@ split_static_library("browser") { ...@@ -3688,8 +3688,8 @@ split_static_library("browser") {
"plugins/plugin_data_remover_helper.h", "plugins/plugin_data_remover_helper.h",
"plugins/plugin_finder.cc", "plugins/plugin_finder.cc",
"plugins/plugin_finder.h", "plugins/plugin_finder.h",
"plugins/plugin_info_message_filter.cc", "plugins/plugin_info_host_impl.cc",
"plugins/plugin_info_message_filter.h", "plugins/plugin_info_host_impl.h",
"plugins/plugin_infobar_delegates.cc", "plugins/plugin_infobar_delegates.cc",
"plugins/plugin_infobar_delegates.h", "plugins/plugin_infobar_delegates.h",
"plugins/plugin_installer.cc", "plugins/plugin_installer.cc",
......
...@@ -169,11 +169,9 @@ void PluginManager::UpdatePluginListWithNaClModules() { ...@@ -169,11 +169,9 @@ void PluginManager::UpdatePluginListWithNaClModules() {
// manifest file. // manifest file.
content::WebPluginMimeType mime_type_info; content::WebPluginMimeType mime_type_info;
mime_type_info.mime_type = iter->mime_type; mime_type_info.mime_type = iter->mime_type;
mime_type_info.additional_param_names.push_back( mime_type_info.additional_params.emplace_back(
base::UTF8ToUTF16("nacl")); base::UTF8ToUTF16("nacl"), base::UTF8ToUTF16(iter->url.spec()));
mime_type_info.additional_param_values.push_back( info.mime_types.emplace_back(std::move(mime_type_info));
base::UTF8ToUTF16(iter->url.spec()));
info.mime_types.push_back(mime_type_info);
} }
PluginService::GetInstance()->RefreshPlugins(); PluginService::GetInstance()->RefreshPlugins();
......
...@@ -5,7 +5,7 @@ ...@@ -5,7 +5,7 @@
#include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h" #include "chrome/browser/plugins/chrome_content_browser_client_plugins_part.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "chrome/browser/plugins/plugin_info_message_filter.h" #include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h" #include "chrome/browser/renderer_host/pepper/chrome_browser_pepper_host_factory.h"
#include "chrome/common/channel_info.h" #include "chrome/common/channel_info.h"
...@@ -41,12 +41,9 @@ void ChromeContentBrowserClientPluginsPart::ExposeInterfacesToRenderer( ...@@ -41,12 +41,9 @@ void ChromeContentBrowserClientPluginsPart::ExposeInterfacesToRenderer(
content::AssociatedInterfaceRegistry* associated_registry, content::AssociatedInterfaceRegistry* associated_registry,
content::RenderProcessHost* host) { content::RenderProcessHost* host) {
Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext()); Profile* profile = Profile::FromBrowserContext(host->GetBrowserContext());
auto plugin_info_filter = host->GetChannel()->AddAssociatedInterfaceForIOThread(base::Bind(
base::MakeRefCounted<PluginInfoMessageFilter>(host->GetID(), profile); &PluginInfoHostImpl::OnPluginInfoHostRequest,
host->AddFilter(plugin_info_filter.get()); base::MakeRefCounted<PluginInfoHostImpl>(host->GetID(), profile)));
host->GetChannel()->AddAssociatedInterfaceForIOThread(
base::Bind(&PluginInfoMessageFilter::OnPluginInfoHostRequest,
std::move(plugin_info_filter)));
} }
bool ChromeContentBrowserClientPluginsPart:: bool ChromeContentBrowserClientPluginsPart::
......
...@@ -2,8 +2,8 @@ ...@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ #ifndef CHROME_BROWSER_PLUGINS_PLUGIN_INFO_HOST_IMPL_H_
#define CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ #define CHROME_BROWSER_PLUGINS_PLUGIN_INFO_HOST_IMPL_H_
#include <memory> #include <memory>
#include <string> #include <string>
...@@ -41,7 +41,7 @@ struct ComponentInfo; ...@@ -41,7 +41,7 @@ struct ComponentInfo;
namespace content { namespace content {
class ResourceContext; class ResourceContext;
struct WebPluginInfo; struct WebPluginInfo;
} } // namespace content
namespace extensions { namespace extensions {
class ExtensionRegistry; class ExtensionRegistry;
...@@ -55,13 +55,17 @@ namespace url { ...@@ -55,13 +55,17 @@ namespace url {
class Origin; class Origin;
} }
// This class filters out incoming IPC messages requesting plugin information. struct PluginInfoHostImplTraits;
class PluginInfoMessageFilter : public content::BrowserMessageFilter,
public chrome::mojom::PluginInfoHost { // Implements PluginInfoHost interface.
class PluginInfoHostImpl
: public base::RefCountedThreadSafe<PluginInfoHostImpl,
PluginInfoHostImplTraits>,
public chrome::mojom::PluginInfoHost {
public: public:
struct GetPluginInfo_Params; struct GetPluginInfo_Params;
// Contains all the information needed by the PluginInfoMessageFilter. // Contains all the information needed by the PluginInfoHostImpl.
class Context { class Context {
public: public:
Context(int render_process_id, Profile* profile); Context(int render_process_id, Profile* profile);
...@@ -105,14 +109,13 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter, ...@@ -105,14 +109,13 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter,
BooleanPrefMember run_all_flash_in_allow_mode_; BooleanPrefMember run_all_flash_in_allow_mode_;
}; };
PluginInfoMessageFilter(int render_process_id, Profile* profile); static void Create(int render_process_id,
Profile* profile,
chrome::mojom::PluginInfoHostAssociatedRequest request);
// content::BrowserMessageFilter methods: PluginInfoHostImpl(int render_process_id, Profile* profile);
bool OnMessageReceived(const IPC::Message& message) override;
void OnDestruct() const override;
void DestructOnBrowserThread() const; void DestructOnBrowserThread() const;
void OnPluginInfoHostRequest( void OnPluginInfoHostRequest(
chrome::mojom::PluginInfoHostAssociatedRequest request); chrome::mojom::PluginInfoHostAssociatedRequest request);
...@@ -121,10 +124,12 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter, ...@@ -121,10 +124,12 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter,
private: private:
friend struct content::BrowserThread::DeleteOnThread< friend struct content::BrowserThread::DeleteOnThread<
content::BrowserThread::UI>; content::BrowserThread::UI>;
friend class base::DeleteHelper<PluginInfoMessageFilter>; friend class base::DeleteHelper<PluginInfoHostImpl>;
friend struct PluginInfoHostImplTraits;
~PluginInfoHostImpl() override;
void ShutdownOnUIThread(); void ShutdownOnUIThread();
~PluginInfoMessageFilter() override;
// chrome::mojom::PluginInfoHost // chrome::mojom::PluginInfoHost
void GetPluginInfo(int32_t render_frame_id, void GetPluginInfo(int32_t render_frame_id,
...@@ -133,6 +138,10 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter, ...@@ -133,6 +138,10 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter,
const std::string& mime_type, const std::string& mime_type,
const GetPluginInfoCallback& callback) override; const GetPluginInfoCallback& callback) override;
void IsInternalPluginAvailableForMimeType(
const std::string& mime_type,
const IsInternalPluginAvailableForMimeTypeCallback& callback) override;
// |params| wraps the parameters passed to |OnGetPluginInfo|, because // |params| wraps the parameters passed to |OnGetPluginInfo|, because
// |base::Bind| doesn't support the required arity <http://crbug.com/98542>. // |base::Bind| doesn't support the required arity <http://crbug.com/98542>.
void PluginsLoaded(const GetPluginInfo_Params& params, void PluginsLoaded(const GetPluginInfo_Params& params,
...@@ -151,21 +160,6 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter, ...@@ -151,21 +160,6 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter,
GetPluginInfoCallback callback, GetPluginInfoCallback callback,
std::unique_ptr<PluginMetadata> plugin_metadata); std::unique_ptr<PluginMetadata> plugin_metadata);
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered
// and enabled. Does not determine whether the plugin can actually be
// instantiated (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for
// |mime_type|.
void OnIsInternalPluginAvailableForMimeType(
const std::string& mime_type,
bool* is_available,
std::vector<base::string16>* additional_param_names,
std::vector<base::string16>* additional_param_values);
#endif
// Reports usage metrics to RAPPOR and UKM. This must be a class function, // Reports usage metrics to RAPPOR and UKM. This must be a class function,
// because UkmService requires a friend declaration by design to call. // because UkmService requires a friend declaration by design to call.
void ReportMetrics(int render_frame_id, void ReportMetrics(int render_frame_id,
...@@ -186,7 +180,11 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter, ...@@ -186,7 +180,11 @@ class PluginInfoMessageFilter : public content::BrowserMessageFilter,
// (which unfortunately hops ~PluginInfoMesssageFilter to the UI thread). // (which unfortunately hops ~PluginInfoMesssageFilter to the UI thread).
mutable mojo::AssociatedBinding<chrome::mojom::PluginInfoHost> binding_; mutable mojo::AssociatedBinding<chrome::mojom::PluginInfoHost> binding_;
DISALLOW_COPY_AND_ASSIGN(PluginInfoMessageFilter); DISALLOW_COPY_AND_ASSIGN(PluginInfoHostImpl);
};
struct PluginInfoHostImplTraits {
static void Destruct(const PluginInfoHostImpl* impl);
}; };
#endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFO_MESSAGE_FILTER_H_ #endif // CHROME_BROWSER_PLUGINS_PLUGIN_INFO_HOST_IMPL_H_
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chrome/browser/plugins/plugin_info_message_filter.h" #include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "base/at_exit.h" #include "base/at_exit.h"
#include "base/bind.h" #include "base/bind.h"
...@@ -87,9 +87,9 @@ bool FakePluginServiceFilter::CanLoadPlugin(int render_process_id, ...@@ -87,9 +87,9 @@ bool FakePluginServiceFilter::CanLoadPlugin(int render_process_id,
} // namespace } // namespace
class PluginInfoMessageFilterTest : public ::testing::Test { class PluginInfoHostImplTest : public ::testing::Test {
public: public:
PluginInfoMessageFilterTest() PluginInfoHostImplTest()
: foo_plugin_path_(FILE_PATH_LITERAL("/path/to/foo")), : foo_plugin_path_(FILE_PATH_LITERAL("/path/to/foo")),
bar_plugin_path_(FILE_PATH_LITERAL("/path/to/bar")), bar_plugin_path_(FILE_PATH_LITERAL("/path/to/bar")),
fake_flash_path_(FILE_PATH_LITERAL("/path/to/fake/flash")), fake_flash_path_(FILE_PATH_LITERAL("/path/to/fake/flash")),
...@@ -99,8 +99,7 @@ class PluginInfoMessageFilterTest : public ::testing::Test { ...@@ -99,8 +99,7 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
void SetUp() override { void SetUp() override {
content::WebPluginInfo foo_plugin(base::ASCIIToUTF16("Foo Plugin"), content::WebPluginInfo foo_plugin(base::ASCIIToUTF16("Foo Plugin"),
foo_plugin_path_, foo_plugin_path_, base::ASCIIToUTF16("1"),
base::ASCIIToUTF16("1"),
base::ASCIIToUTF16("The Foo plugin.")); base::ASCIIToUTF16("The Foo plugin."));
content::WebPluginMimeType mime_type; content::WebPluginMimeType mime_type;
mime_type.mime_type = "foo/bar"; mime_type.mime_type = "foo/bar";
...@@ -110,8 +109,7 @@ class PluginInfoMessageFilterTest : public ::testing::Test { ...@@ -110,8 +109,7 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
PluginService::GetInstance()->RegisterInternalPlugin(foo_plugin, false); PluginService::GetInstance()->RegisterInternalPlugin(foo_plugin, false);
content::WebPluginInfo bar_plugin(base::ASCIIToUTF16("Bar Plugin"), content::WebPluginInfo bar_plugin(base::ASCIIToUTF16("Bar Plugin"),
bar_plugin_path_, bar_plugin_path_, base::ASCIIToUTF16("1"),
base::ASCIIToUTF16("1"),
base::ASCIIToUTF16("The Bar plugin.")); base::ASCIIToUTF16("The Bar plugin."));
mime_type.mime_type = "foo/bar"; mime_type.mime_type = "foo/bar";
bar_plugin.mime_types.push_back(mime_type); bar_plugin.mime_types.push_back(mime_type);
...@@ -143,21 +141,18 @@ class PluginInfoMessageFilterTest : public ::testing::Test { ...@@ -143,21 +141,18 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
} }
protected: protected:
TestingProfile* profile() { TestingProfile* profile() { return &profile_; }
return &profile_;
}
PluginInfoMessageFilter::Context* context() { PluginInfoHostImpl::Context* context() { return &context_; }
return &context_;
}
void VerifyPluginContentSetting(const GURL& url, void VerifyPluginContentSetting(const GURL& url,
const std::string& plugin, const std::string& plugin,
ContentSetting expected_setting, ContentSetting expected_setting,
bool expected_is_default, bool expected_is_default,
bool expected_is_managed) { bool expected_is_managed) {
ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT ? ContentSetting setting = expected_setting == CONTENT_SETTING_DEFAULT
CONTENT_SETTING_BLOCK : CONTENT_SETTING_DEFAULT; ? CONTENT_SETTING_BLOCK
: CONTENT_SETTING_DEFAULT;
bool is_default = !expected_is_default; bool is_default = !expected_is_default;
bool is_managed = !expected_is_managed; bool is_managed = !expected_is_managed;
...@@ -183,11 +178,11 @@ class PluginInfoMessageFilterTest : public ::testing::Test { ...@@ -183,11 +178,11 @@ class PluginInfoMessageFilterTest : public ::testing::Test {
base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService. base::ShadowingAtExitManager at_exit_manager_; // Destroys the PluginService.
content::TestBrowserThreadBundle test_thread_bundle; content::TestBrowserThreadBundle test_thread_bundle;
TestingProfile profile_; TestingProfile profile_;
PluginInfoMessageFilter::Context context_; PluginInfoHostImpl::Context context_;
HostContentSettingsMap* host_content_settings_map_; HostContentSettingsMap* host_content_settings_map_;
}; };
TEST_F(PluginInfoMessageFilterTest, FindEnabledPlugin) { TEST_F(PluginInfoHostImplTest, FindEnabledPlugin) {
filter_.set_plugin_enabled(foo_plugin_path_, true); filter_.set_plugin_enabled(foo_plugin_path_, true);
filter_.set_plugin_enabled(bar_plugin_path_, true); filter_.set_plugin_enabled(bar_plugin_path_, true);
{ {
...@@ -238,7 +233,7 @@ TEST_F(PluginInfoMessageFilterTest, FindEnabledPlugin) { ...@@ -238,7 +233,7 @@ TEST_F(PluginInfoMessageFilterTest, FindEnabledPlugin) {
} }
} }
TEST_F(PluginInfoMessageFilterTest, PreferHtmlOverPlugins) { TEST_F(PluginInfoHostImplTest, PreferHtmlOverPlugins) {
// The HTML5 By Default feature hides Flash using the plugin filter. // The HTML5 By Default feature hides Flash using the plugin filter.
filter_.set_plugin_enabled(fake_flash_path_, false); filter_.set_plugin_enabled(fake_flash_path_, false);
...@@ -273,7 +268,7 @@ TEST_F(PluginInfoMessageFilterTest, PreferHtmlOverPlugins) { ...@@ -273,7 +268,7 @@ TEST_F(PluginInfoMessageFilterTest, PreferHtmlOverPlugins) {
EXPECT_EQ(chrome::mojom::PluginStatus::kBlockedNoLoading, status); EXPECT_EQ(chrome::mojom::PluginStatus::kBlockedNoLoading, status);
} }
TEST_F(PluginInfoMessageFilterTest, RunAllFlashInAllowMode) { TEST_F(PluginInfoHostImplTest, RunAllFlashInAllowMode) {
filter_.set_plugin_enabled(fake_flash_path_, true); filter_.set_plugin_enabled(fake_flash_path_, true);
// Make a real HTTP origin, as all Flash content from non-HTTP and non-FILE // Make a real HTTP origin, as all Flash content from non-HTTP and non-FILE
...@@ -315,7 +310,7 @@ TEST_F(PluginInfoMessageFilterTest, RunAllFlashInAllowMode) { ...@@ -315,7 +310,7 @@ TEST_F(PluginInfoMessageFilterTest, RunAllFlashInAllowMode) {
EXPECT_THAT(status, Eq(chrome::mojom::PluginStatus::kAllowed)); EXPECT_THAT(status, Eq(chrome::mojom::PluginStatus::kAllowed));
} }
TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) { TEST_F(PluginInfoHostImplTest, GetPluginContentSetting) {
HostContentSettingsMap* map = HostContentSettingsMap* map =
HostContentSettingsMapFactory::GetForProfile(profile()); HostContentSettingsMapFactory::GetForProfile(profile());
...@@ -325,9 +320,9 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) { ...@@ -325,9 +320,9 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) {
// Set plugins to Plugin Power Saver on example.com and subdomains. // Set plugins to Plugin Power Saver on example.com and subdomains.
GURL host("http://example.com/"); GURL host("http://example.com/");
map->SetContentSettingDefaultScope(host, GURL(), map->SetContentSettingDefaultScope(
CONTENT_SETTINGS_TYPE_PLUGINS, std::string(), host, GURL(), CONTENT_SETTINGS_TYPE_PLUGINS, std::string(),
CONTENT_SETTING_DETECT_IMPORTANT_CONTENT); CONTENT_SETTING_DETECT_IMPORTANT_CONTENT);
// Allow plugin "foo" on all sites. // Allow plugin "foo" on all sites.
map->SetContentSettingCustomScope( map->SetContentSettingCustomScope(
...@@ -335,16 +330,19 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) { ...@@ -335,16 +330,19 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) {
CONTENT_SETTINGS_TYPE_PLUGINS, "foo", CONTENT_SETTING_ALLOW); CONTENT_SETTINGS_TYPE_PLUGINS, "foo", CONTENT_SETTING_ALLOW);
GURL unmatched_host("https://www.google.com"); GURL unmatched_host("https://www.google.com");
ASSERT_EQ(CONTENT_SETTING_BLOCK, map->GetContentSetting( ASSERT_EQ(
unmatched_host, unmatched_host, CONTENT_SETTINGS_TYPE_PLUGINS, CONTENT_SETTING_BLOCK,
std::string())); map->GetContentSetting(unmatched_host, unmatched_host,
CONTENT_SETTINGS_TYPE_PLUGINS, std::string()));
ASSERT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, ASSERT_EQ(CONTENT_SETTING_DETECT_IMPORTANT_CONTENT,
map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS,
std::string())); std::string()));
ASSERT_EQ(CONTENT_SETTING_ALLOW, map->GetContentSetting( ASSERT_EQ(
host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "foo")); CONTENT_SETTING_ALLOW,
ASSERT_EQ(CONTENT_SETTING_DEFAULT, map->GetContentSetting( map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "foo"));
host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "bar")); ASSERT_EQ(
CONTENT_SETTING_DEFAULT,
map->GetContentSetting(host, host, CONTENT_SETTINGS_TYPE_PLUGINS, "bar"));
// "foo" is allowed everywhere. // "foo" is allowed everywhere.
VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_ALLOW, false, false); VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_ALLOW, false, false);
...@@ -355,8 +353,8 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) { ...@@ -355,8 +353,8 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) {
host, "bar", CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, false, false); host, "bar", CONTENT_SETTING_DETECT_IMPORTANT_CONTENT, false, false);
// Otherwise, use the default. // Otherwise, use the default.
VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, true,
true, false); false);
// Block plugins via policy. // Block plugins via policy.
sync_preferences::TestingPrefServiceSyncable* prefs = sync_preferences::TestingPrefServiceSyncable* prefs =
...@@ -367,6 +365,6 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) { ...@@ -367,6 +365,6 @@ TEST_F(PluginInfoMessageFilterTest, GetPluginContentSetting) {
// All plugins should be blocked now. // All plugins should be blocked now.
VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true); VerifyPluginContentSetting(host, "foo", CONTENT_SETTING_BLOCK, true, true);
VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true); VerifyPluginContentSetting(host, "bar", CONTENT_SETTING_BLOCK, true, true);
VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, VerifyPluginContentSetting(unmatched_host, "bar", CONTENT_SETTING_BLOCK, true,
true, true); true);
} }
...@@ -148,7 +148,7 @@ ...@@ -148,7 +148,7 @@
#endif #endif
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
#include "chrome/browser/plugins/plugin_info_message_filter.h" #include "chrome/browser/plugins/plugin_info_host_impl.h"
#include "chrome/browser/plugins/plugins_resource_service.h" #include "chrome/browser/plugins/plugins_resource_service.h"
#endif #endif
...@@ -522,7 +522,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) { ...@@ -522,7 +522,7 @@ void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry) {
#endif #endif
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
PluginInfoMessageFilter::RegisterUserPrefs(registry); PluginInfoHostImpl::RegisterUserPrefs(registry);
#endif #endif
#if BUILDFLAG(ENABLE_PRINT_PREVIEW) #if BUILDFLAG(ENABLE_PRINT_PREVIEW)
......
...@@ -67,6 +67,11 @@ struct PluginInfo { ...@@ -67,6 +67,11 @@ struct PluginInfo {
mojo.common.mojom.String16 group_name; mojo.common.mojom.String16 group_name;
}; };
struct PluginParam {
mojo.common.mojom.String16 name;
mojo.common.mojom.String16 value;
};
interface PluginInfoHost { interface PluginInfoHost {
// Return information about a plugin for the given URL and MIME type. // Return information about a plugin for the given URL and MIME type.
// Includes specific reasons why a plugin can't be used, for example because // Includes specific reasons why a plugin can't be used, for example because
...@@ -76,6 +81,17 @@ interface PluginInfoHost { ...@@ -76,6 +81,17 @@ interface PluginInfoHost {
url.mojom.Url url, url.mojom.Url url,
url.mojom.Origin origin, url.mojom.Origin origin,
string mime_type) => (PluginInfo plugin_info); string mime_type) => (PluginInfo plugin_info);
// Returns whether any internal plugin supporting |mime_type| is registered
// and enabled. Does not determine whether the plugin can actually be
// instantiated (e.g. whether it has all its dependencies).
// When a plugin is available, the returned |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for
// |mime_type|.
[Sync]
IsInternalPluginAvailableForMimeType(string mime_type) => (
array<PluginParam>? additional_params);
}; };
// Plugin messages sent from a host to the renderer. // Plugin messages sent from a host to the renderer.
......
...@@ -164,22 +164,6 @@ IPC_SYNC_MESSAGE_CONTROL4_1(ChromeViewHostMsg_AllowIndexedDB, ...@@ -164,22 +164,6 @@ IPC_SYNC_MESSAGE_CONTROL4_1(ChromeViewHostMsg_AllowIndexedDB,
base::string16 /* database name */, base::string16 /* database name */,
bool /* allowed */) bool /* allowed */)
#if BUILDFLAG(ENABLE_LIBRARY_CDMS)
// Returns whether any internal plugin supporting |mime_type| is registered and
// enabled. Does not determine whether the plugin can actually be instantiated
// (e.g. whether it has all its dependencies).
// When the returned *|is_available| is true, |additional_param_names| and
// |additional_param_values| contain the name-value pairs, if any, specified
// for the *first* non-disabled plugin found that is registered for |mime_type|.
IPC_SYNC_MESSAGE_CONTROL1_3(
ChromeViewHostMsg_IsInternalPluginAvailableForMimeType,
std::string /* mime_type */,
bool /* is_available */,
std::vector<base::string16> /* additional_param_names */,
std::vector<base::string16> /* additional_param_values */)
#endif
IPC_MESSAGE_ROUTED1(ChromeFrameHostMsg_DidGetWebApplicationInfo, IPC_MESSAGE_ROUTED1(ChromeFrameHostMsg_DidGetWebApplicationInfo,
WebApplicationInfo) WebApplicationInfo)
......
...@@ -215,6 +215,7 @@ using content::PluginInstanceThrottler; ...@@ -215,6 +215,7 @@ using content::PluginInstanceThrottler;
using content::RenderFrame; using content::RenderFrame;
using content::RenderThread; using content::RenderThread;
using content::WebPluginInfo; using content::WebPluginInfo;
using content::WebPluginMimeType;
using extensions::Extension; using extensions::Extension;
namespace internal { namespace internal {
...@@ -242,15 +243,13 @@ const char* const kPredefinedAllowedCompositorOrigins[] = { ...@@ -242,15 +243,13 @@ const char* const kPredefinedAllowedCompositorOrigins[] = {
#endif #endif
#if BUILDFLAG(ENABLE_PLUGINS) #if BUILDFLAG(ENABLE_PLUGINS)
void AppendParams(const std::vector<base::string16>& additional_names, void AppendParams(
const std::vector<base::string16>& additional_values, const std::vector<WebPluginMimeType::Param>& additional_params,
WebVector<WebString>* existing_names, WebVector<WebString>* existing_names,
WebVector<WebString>* existing_values) { WebVector<WebString>* existing_values) {
DCHECK(additional_names.size() == additional_values.size());
DCHECK(existing_names->size() == existing_values->size()); DCHECK(existing_names->size() == existing_values->size());
size_t existing_size = existing_names->size(); size_t existing_size = existing_names->size();
size_t total_size = existing_size + additional_names.size(); size_t total_size = existing_size + additional_params.size();
WebVector<WebString> names(total_size); WebVector<WebString> names(total_size);
WebVector<WebString> values(total_size); WebVector<WebString> values(total_size);
...@@ -260,9 +259,10 @@ void AppendParams(const std::vector<base::string16>& additional_names, ...@@ -260,9 +259,10 @@ void AppendParams(const std::vector<base::string16>& additional_names,
values[i] = (*existing_values)[i]; values[i] = (*existing_values)[i];
} }
for (size_t i = 0; i < additional_names.size(); ++i) { for (size_t i = 0; i < additional_params.size(); ++i) {
names[existing_size + i] = WebString::FromUTF16(additional_names[i]); names[existing_size + i] = WebString::FromUTF16(additional_params[i].name);
values[existing_size + i] = WebString::FromUTF16(additional_values[i]); values[existing_size + i] =
WebString::FromUTF16(additional_params[i].value);
} }
existing_names->Swap(names); existing_names->Swap(names);
...@@ -778,8 +778,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin( ...@@ -778,8 +778,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
WebPluginParams params(original_params); WebPluginParams params(original_params);
for (const auto& mime_type : info.mime_types) { for (const auto& mime_type : info.mime_types) {
if (mime_type.mime_type == actual_mime_type) { if (mime_type.mime_type == actual_mime_type) {
AppendParams(mime_type.additional_param_names, AppendParams(mime_type.additional_params, &params.attribute_names,
mime_type.additional_param_values, &params.attribute_names,
&params.attribute_values); &params.attribute_values);
break; break;
} }
...@@ -1059,10 +1058,9 @@ GURL ChromeContentRendererClient::GetNaClContentHandlerURL( ...@@ -1059,10 +1058,9 @@ GURL ChromeContentRendererClient::GetNaClContentHandlerURL(
base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute);
for (size_t i = 0; i < plugin.mime_types.size(); ++i) { for (size_t i = 0; i < plugin.mime_types.size(); ++i) {
if (plugin.mime_types[i].mime_type == actual_mime_type) { if (plugin.mime_types[i].mime_type == actual_mime_type) {
const content::WebPluginMimeType& content_type = plugin.mime_types[i]; for (const auto& p : plugin.mime_types[i].additional_params) {
for (size_t i = 0; i < content_type.additional_param_names.size(); ++i) { if (p.name == nacl_attr)
if (content_type.additional_param_names[i] == nacl_attr) return GURL(p.value);
return GURL(content_type.additional_param_values[i]);
} }
break; break;
} }
...@@ -1136,11 +1134,10 @@ bool ChromeContentRendererClient::IsNaClAllowed( ...@@ -1136,11 +1134,10 @@ bool ChromeContentRendererClient::IsNaClAllowed(
if (is_extension_unrestricted || if (is_extension_unrestricted ||
(is_nacl_unrestricted && !is_nacl_allowed_by_location)) { (is_nacl_unrestricted && !is_nacl_allowed_by_location)) {
// Add the special '@dev' attribute. // Add the special '@dev' attribute.
std::vector<base::string16> param_names; std::vector<WebPluginMimeType::Param> mime_params;
std::vector<base::string16> param_values; mime_params.emplace_back(base::ASCIIToUTF16(dev_attribute),
param_names.push_back(base::ASCIIToUTF16(dev_attribute)); base::string16());
param_values.push_back(base::string16()); AppendParams(mime_params, &params->attribute_names,
AppendParams(param_names, param_values, &params->attribute_names,
&params->attribute_values); &params->attribute_values);
} else { } else {
// If the params somehow contain '@dev', remove it. // If the params somehow contain '@dev', remove it.
......
...@@ -93,9 +93,8 @@ void AddContentTypeHandler(content::WebPluginInfo* info, ...@@ -93,9 +93,8 @@ void AddContentTypeHandler(content::WebPluginInfo* info,
const char* manifest_url) { const char* manifest_url) {
content::WebPluginMimeType mime_type_info; content::WebPluginMimeType mime_type_info;
mime_type_info.mime_type = mime_type; mime_type_info.mime_type = mime_type;
mime_type_info.additional_param_names.push_back(base::UTF8ToUTF16("nacl")); mime_type_info.additional_params.emplace_back(
mime_type_info.additional_param_values.push_back( base::UTF8ToUTF16("nacl"), base::UTF8ToUTF16(manifest_url));
base::UTF8ToUTF16(manifest_url));
info->mime_types.push_back(mime_type_info); info->mime_types.push_back(mime_type_info);
} }
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "base/strings/string_split.h" #include "base/strings/string_split.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "build/build_config.h" #include "build/build_config.h"
#include "chrome/common/render_messages.h" #include "chrome/renderer/chrome_content_renderer_client.h"
#include "chrome/renderer/chrome_render_thread_observer.h" #include "chrome/renderer/chrome_render_thread_observer.h"
#include "components/cdm/renderer/external_clear_key_key_system_properties.h" #include "components/cdm/renderer/external_clear_key_key_system_properties.h"
#include "components/cdm/renderer/widevine_key_system_properties.h" #include "components/cdm/renderer/widevine_key_system_properties.h"
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#include "base/version.h" #include "base/version.h"
#endif #endif
using content::WebPluginMimeType;
using media::EmeFeatureSupport; using media::EmeFeatureSupport;
using media::EmeSessionTypeSupport; using media::EmeSessionTypeSupport;
using media::KeySystemProperties; using media::KeySystemProperties;
...@@ -49,17 +50,21 @@ using media::SupportedCodecs; ...@@ -49,17 +50,21 @@ using media::SupportedCodecs;
#if BUILDFLAG(ENABLE_LIBRARY_CDMS) #if BUILDFLAG(ENABLE_LIBRARY_CDMS)
static bool IsPepperCdmAvailable( static bool IsPepperCdmAvailable(
const std::string& pepper_type, const std::string& pepper_type,
std::vector<base::string16>* additional_param_names, std::vector<WebPluginMimeType::Param>* additional_params) {
std::vector<base::string16>* additional_param_values) { base::Optional<std::vector<chrome::mojom::PluginParamPtr>>
bool is_available = false; opt_additional_params;
content::RenderThread::Get()->Send( ChromeContentRendererClient::GetPluginInfoHost()
new ChromeViewHostMsg_IsInternalPluginAvailableForMimeType( ->IsInternalPluginAvailableForMimeType(pepper_type,
pepper_type, &opt_additional_params);
&is_available,
additional_param_names, if (opt_additional_params) {
additional_param_values)); for (auto& p : *opt_additional_params) {
additional_params->emplace_back(p->name, p->value);
return is_available; }
return true;
}
return false;
} }
// External Clear Key (used for testing). // External Clear Key (used for testing).
...@@ -90,11 +95,9 @@ static void AddExternalClearKey( ...@@ -90,11 +95,9 @@ static void AddExternalClearKey(
static const char kExternalClearKeyDifferentGuidTestKeySystem[] = static const char kExternalClearKeyDifferentGuidTestKeySystem[] =
"org.chromium.externalclearkey.differentguid"; "org.chromium.externalclearkey.differentguid";
std::vector<base::string16> additional_param_names; std::vector<WebPluginMimeType::Param> additional_params;
std::vector<base::string16> additional_param_values;
if (!IsPepperCdmAvailable(cdm::kExternalClearKeyPepperType, if (!IsPepperCdmAvailable(cdm::kExternalClearKeyPepperType,
&additional_param_names, &additional_params)) {
&additional_param_values)) {
return; return;
} }
...@@ -175,18 +178,14 @@ void GetSupportedCodecsForPepperCdm( ...@@ -175,18 +178,14 @@ void GetSupportedCodecsForPepperCdm(
// Whether persistent-license session is supported by the CDM. // Whether persistent-license session is supported by the CDM.
bool IsPersistentLicenseSupportedbyCdm( bool IsPersistentLicenseSupportedbyCdm(
const std::vector<base::string16>& additional_param_names, const std::vector<WebPluginMimeType::Param>& additional_params) {
const std::vector<base::string16>& additional_param_values) {
DCHECK_EQ(additional_param_names.size(), additional_param_values.size());
const base::string16 expected_param_name = const base::string16 expected_param_name =
base::ASCIIToUTF16(kCdmPersistentLicenseSupportedParamName); base::ASCIIToUTF16(kCdmPersistentLicenseSupportedParamName);
for (size_t i = 0; i < additional_param_names.size(); ++i) { for (const auto& p : additional_params) {
if (additional_param_names[i] == expected_param_name) { if (p.name == expected_param_name) {
return additional_param_values[i] == return p.value == base::ASCIIToUTF16(kCdmFeatureSupported);
base::ASCIIToUTF16(kCdmFeatureSupported);
} }
} }
return false; return false;
} }
...@@ -244,11 +243,8 @@ static void AddPepperBasedWidevine( ...@@ -244,11 +243,8 @@ static void AddPepperBasedWidevine(
return; return;
#endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION) #endif // defined(WIDEVINE_CDM_MIN_GLIBC_VERSION)
std::vector<base::string16> additional_param_names; std::vector<WebPluginMimeType::Param> additional_params;
std::vector<base::string16> additional_param_values; if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType, &additional_params)) {
if (!IsPepperCdmAvailable(kWidevineCdmPluginMimeType,
&additional_param_names,
&additional_param_values)) {
DVLOG(1) << "Widevine CDM is not currently available."; DVLOG(1) << "Widevine CDM is not currently available.";
return; return;
} }
...@@ -283,8 +279,8 @@ static void AddPepperBasedWidevine( ...@@ -283,8 +279,8 @@ static void AddPepperBasedWidevine(
} }
EmeSessionTypeSupport persistent_license_support = EmeSessionTypeSupport persistent_license_support =
GetPersistentLicenseSupport(IsPersistentLicenseSupportedbyCdm( GetPersistentLicenseSupport(
additional_param_names, additional_param_values)); IsPersistentLicenseSupportedbyCdm(additional_params));
using Robustness = cdm::WidevineKeySystemProperties::Robustness; using Robustness = cdm::WidevineKeySystemProperties::Robustness;
......
...@@ -4539,7 +4539,7 @@ test("unit_tests") { ...@@ -4539,7 +4539,7 @@ test("unit_tests") {
"../browser/plugins/flash_download_interception_unittest.cc", "../browser/plugins/flash_download_interception_unittest.cc",
"../browser/plugins/flash_temporary_permission_tracker_unittest.cc", "../browser/plugins/flash_temporary_permission_tracker_unittest.cc",
"../browser/plugins/plugin_finder_unittest.cc", "../browser/plugins/plugin_finder_unittest.cc",
"../browser/plugins/plugin_info_message_filter_unittest.cc", "../browser/plugins/plugin_info_host_impl_unittest.cc",
"../browser/plugins/plugin_installer_unittest.cc", "../browser/plugins/plugin_installer_unittest.cc",
"../browser/plugins/plugin_metadata_unittest.cc", "../browser/plugins/plugin_metadata_unittest.cc",
"../browser/plugins/plugin_prefs_unittest.cc", "../browser/plugins/plugin_prefs_unittest.cc",
......
...@@ -39,8 +39,14 @@ struct CONTENT_EXPORT WebPluginMimeType { ...@@ -39,8 +39,14 @@ struct CONTENT_EXPORT WebPluginMimeType {
base::string16 description; base::string16 description;
// Extra parameters to include when instantiating the plugin. // Extra parameters to include when instantiating the plugin.
std::vector<base::string16> additional_param_names; struct Param {
std::vector<base::string16> additional_param_values; Param() = default;
Param(base::string16 n, base::string16 v)
: name(std::move(n)), value(std::move(v)) {}
base::string16 name;
base::string16 value;
};
std::vector<Param> additional_params;
}; };
// Describes an available Pepper plugin. // Describes an available Pepper plugin.
......
...@@ -10,12 +10,16 @@ ...@@ -10,12 +10,16 @@
#undef IPC_MESSAGE_EXPORT #undef IPC_MESSAGE_EXPORT
#define IPC_MESSAGE_EXPORT CONTENT_EXPORT #define IPC_MESSAGE_EXPORT CONTENT_EXPORT
IPC_STRUCT_TRAITS_BEGIN(content::WebPluginMimeType::Param)
IPC_STRUCT_TRAITS_MEMBER(name)
IPC_STRUCT_TRAITS_MEMBER(value)
IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::WebPluginMimeType) IPC_STRUCT_TRAITS_BEGIN(content::WebPluginMimeType)
IPC_STRUCT_TRAITS_MEMBER(mime_type) IPC_STRUCT_TRAITS_MEMBER(mime_type)
IPC_STRUCT_TRAITS_MEMBER(file_extensions) IPC_STRUCT_TRAITS_MEMBER(file_extensions)
IPC_STRUCT_TRAITS_MEMBER(description) IPC_STRUCT_TRAITS_MEMBER(description)
IPC_STRUCT_TRAITS_MEMBER(additional_param_names) IPC_STRUCT_TRAITS_MEMBER(additional_params)
IPC_STRUCT_TRAITS_MEMBER(additional_param_values)
IPC_STRUCT_TRAITS_END() IPC_STRUCT_TRAITS_END()
IPC_STRUCT_TRAITS_BEGIN(content::WebPluginInfo) IPC_STRUCT_TRAITS_BEGIN(content::WebPluginInfo)
......
...@@ -20,7 +20,7 @@ ...@@ -20,7 +20,7 @@
class ContextualSearchRankerLoggerImpl; class ContextualSearchRankerLoggerImpl;
class DocumentWritePageLoadMetricsObserver; class DocumentWritePageLoadMetricsObserver;
class FromGWSPageLoadMetricsLogger; class FromGWSPageLoadMetricsLogger;
class PluginInfoMessageFilter; class PluginInfoHostImpl;
class ServiceWorkerPageLoadMetricsObserver; class ServiceWorkerPageLoadMetricsObserver;
class SubresourceFilterMetricsObserver; class SubresourceFilterMetricsObserver;
class UkmPageLoadMetricsObserver; class UkmPageLoadMetricsObserver;
...@@ -90,7 +90,7 @@ class METRICS_EXPORT UkmRecorder { ...@@ -90,7 +90,7 @@ class METRICS_EXPORT UkmRecorder {
friend DocumentWritePageLoadMetricsObserver; friend DocumentWritePageLoadMetricsObserver;
friend FromGWSPageLoadMetricsLogger; friend FromGWSPageLoadMetricsLogger;
friend LocalNetworkRequestsPageLoadMetricsObserver; friend LocalNetworkRequestsPageLoadMetricsObserver;
friend PluginInfoMessageFilter; friend PluginInfoHostImpl;
friend ServiceWorkerPageLoadMetricsObserver; friend ServiceWorkerPageLoadMetricsObserver;
friend SubresourceFilterMetricsObserver; friend SubresourceFilterMetricsObserver;
friend TestRecordingHelper; friend TestRecordingHelper;
......
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