2017-12-07 22:44:24 +01:00
|
|
|
diff --git chrome/browser/plugins/plugin_info_host_impl.cc chrome/browser/plugins/plugin_info_host_impl.cc
|
2018-03-20 21:15:08 +01:00
|
|
|
index ab3fd0de9e07..298db88e685f 100644
|
2017-12-07 22:44:24 +01:00
|
|
|
--- chrome/browser/plugins/plugin_info_host_impl.cc
|
|
|
|
+++ chrome/browser/plugins/plugin_info_host_impl.cc
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -17,6 +17,7 @@
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "base/task_runner_util.h"
|
|
|
|
#include "base/threading/thread_task_runner_handle.h"
|
|
|
|
#include "build/build_config.h"
|
|
|
|
+#include "cef/libcef/features/features.h"
|
|
|
|
#include "chrome/browser/browser_process.h"
|
|
|
|
#include "chrome/browser/content_settings/host_content_settings_map_factory.h"
|
|
|
|
#include "chrome/browser/plugins/chrome_plugin_service_filter.h"
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -55,6 +56,11 @@
|
|
|
|
#include "url/gurl.h"
|
2017-12-07 22:44:24 +01:00
|
|
|
#include "url/origin.h"
|
|
|
|
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+#include "cef/libcef/browser/plugins/plugin_service_filter.h"
|
|
|
|
+#include "cef/libcef/common/extensions/extensions_util.h"
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
|
#include "components/guest_view/browser/guest_view_base.h"
|
|
|
|
#include "extensions/browser/extension_registry.h"
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -76,12 +82,10 @@ namespace {
|
|
|
|
class PluginInfoHostImplShutdownNotifierFactory
|
2017-12-07 22:44:24 +01:00
|
|
|
: public BrowserContextKeyedServiceShutdownNotifierFactory {
|
|
|
|
public:
|
2018-02-15 01:12:09 +01:00
|
|
|
- static PluginInfoHostImplShutdownNotifierFactory* GetInstance() {
|
|
|
|
- return base::Singleton<PluginInfoHostImplShutdownNotifierFactory>::get();
|
2017-12-07 22:44:24 +01:00
|
|
|
- }
|
2018-02-15 01:12:09 +01:00
|
|
|
+ static PluginInfoHostImplShutdownNotifierFactory* GetInstance();
|
2017-12-07 22:44:24 +01:00
|
|
|
|
|
|
|
private:
|
2018-02-15 01:12:09 +01:00
|
|
|
- friend struct base::DefaultSingletonTraits<
|
|
|
|
+ friend struct base::LazyInstanceTraitsBase<
|
|
|
|
PluginInfoHostImplShutdownNotifierFactory>;
|
2017-12-07 22:44:24 +01:00
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
PluginInfoHostImplShutdownNotifierFactory()
|
|
|
|
@@ -93,6 +97,16 @@ class PluginInfoHostImplShutdownNotifierFactory
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(PluginInfoHostImplShutdownNotifierFactory);
|
2017-12-07 22:44:24 +01:00
|
|
|
};
|
|
|
|
|
2018-02-15 01:12:09 +01:00
|
|
|
+base::LazyInstance<PluginInfoHostImplShutdownNotifierFactory>::Leaky
|
|
|
|
+ g_plugin_info_host_impl_shutdown_notifier_factory =
|
|
|
|
+ LAZY_INSTANCE_INITIALIZER;
|
2017-12-07 22:44:24 +01:00
|
|
|
+
|
|
|
|
+// static
|
2018-02-15 01:12:09 +01:00
|
|
|
+PluginInfoHostImplShutdownNotifierFactory*
|
|
|
|
+PluginInfoHostImplShutdownNotifierFactory::GetInstance() {
|
|
|
|
+ return g_plugin_info_host_impl_shutdown_notifier_factory.Pointer();
|
2017-12-07 22:44:24 +01:00
|
|
|
+}
|
|
|
|
+
|
2018-02-15 01:12:09 +01:00
|
|
|
#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
|
// Returns whether a request from a plugin to load |resource| from a renderer
|
|
|
|
// with process id |process_id| is a request for an internal resource by an app
|
|
|
|
@@ -101,6 +115,9 @@ bool IsPluginLoadingAccessibleResourceInWebView(
|
2017-12-07 22:44:24 +01:00
|
|
|
extensions::ExtensionRegistry* extension_registry,
|
|
|
|
int process_id,
|
|
|
|
const GURL& resource) {
|
|
|
|
+ if (!extension_registry)
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
extensions::WebViewRendererState* renderer_state =
|
|
|
|
extensions::WebViewRendererState::GetInstance();
|
|
|
|
std::string partition_id;
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -130,12 +147,16 @@ bool IsPluginLoadingAccessibleResourceInWebView(
|
2017-12-07 22:44:24 +01:00
|
|
|
PluginInfoHostImpl::Context::Context(int render_process_id, Profile* profile)
|
|
|
|
: render_process_id_(render_process_id),
|
|
|
|
resource_context_(profile->GetResourceContext()),
|
|
|
|
-#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
|
- extension_registry_(extensions::ExtensionRegistry::Get(profile)),
|
|
|
|
-#endif
|
|
|
|
host_content_settings_map_(
|
|
|
|
HostContentSettingsMapFactory::GetForProfile(profile)),
|
|
|
|
plugin_prefs_(PluginPrefs::GetForProfile(profile)) {
|
|
|
|
+#if BUILDFLAG(ENABLE_EXTENSIONS)
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ if (extensions::ExtensionsEnabled())
|
|
|
|
+#endif
|
|
|
|
+ extension_registry_ = extensions::ExtensionRegistry::Get(profile);
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated,
|
|
|
|
profile->GetPrefs());
|
|
|
|
allow_outdated_plugins_.MoveToThread(
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -234,6 +255,7 @@ void PluginInfoHostImpl::PluginsLoaded(
|
2018-02-12 22:22:51 +01:00
|
|
|
plugin_metadata->identifier(), &output->status);
|
|
|
|
}
|
|
|
|
|
|
|
|
+#if !BUILDFLAG(ENABLE_CEF)
|
|
|
|
if (output->status == chrome::mojom::PluginStatus::kNotFound) {
|
|
|
|
// Check to see if the component updater can fetch an implementation.
|
|
|
|
base::PostTaskAndReplyWithResult(
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -245,7 +267,9 @@ void PluginInfoHostImpl::PluginsLoaded(
|
2018-02-12 22:22:51 +01:00
|
|
|
base::BindOnce(&PluginInfoHostImpl::ComponentPluginLookupDone, this,
|
|
|
|
params, std::move(output), std::move(callback),
|
|
|
|
std::move(plugin_metadata)));
|
|
|
|
- } else {
|
|
|
|
+ } else
|
|
|
|
+#endif // !BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ {
|
|
|
|
GetPluginInfoFinish(params, std::move(output), std::move(callback),
|
|
|
|
std::move(plugin_metadata));
|
|
|
|
}
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -258,6 +282,14 @@ void PluginInfoHostImpl::Context::DecidePluginStatus(
|
2017-12-07 22:44:24 +01:00
|
|
|
PluginMetadata::SecurityStatus security_status,
|
|
|
|
const std::string& plugin_identifier,
|
|
|
|
chrome::mojom::PluginStatus* status) const {
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ // Don't override the user decision.
|
|
|
|
+ if (*status == chrome::mojom::PluginStatus::kBlocked ||
|
|
|
|
+ *status == chrome::mojom::PluginStatus::kDisabled) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
if (security_status == PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) {
|
|
|
|
*status = chrome::mojom::PluginStatus::kAllowed;
|
|
|
|
return;
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -382,16 +414,36 @@ bool PluginInfoHostImpl::Context::FindEnabledPlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
+ const bool is_main_frame =
|
|
|
|
+ main_frame_origin.IsSameOriginWith(url::Origin::Create(url));
|
|
|
|
+
|
|
|
|
+#if BUILDFLAG(ENABLE_CEF)
|
|
|
|
+ CefPluginServiceFilter* filter = static_cast<CefPluginServiceFilter*>(
|
|
|
|
+ PluginService::GetInstance()->GetFilter());
|
|
|
|
+ DCHECK(filter);
|
|
|
|
+
|
|
|
|
+ size_t i = 0;
|
|
|
|
+ for (; i < matching_plugins.size(); ++i) {
|
|
|
|
+ if (filter->IsPluginAvailable(render_process_id_, render_frame_id,
|
|
|
|
+ resource_context_, url, is_main_frame,
|
|
|
|
+ main_frame_origin, &matching_plugins[i],
|
|
|
|
+ status)) {
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+#else // !BUILDFLAG(ENABLE_CEF)
|
|
|
|
content::PluginServiceFilter* filter =
|
|
|
|
PluginService::GetInstance()->GetFilter();
|
|
|
|
size_t i = 0;
|
|
|
|
for (; i < matching_plugins.size(); ++i) {
|
|
|
|
if (!filter || filter->IsPluginAvailable(
|
|
|
|
render_process_id_, render_frame_id, resource_context_,
|
|
|
|
- url, main_frame_origin, &matching_plugins[i])) {
|
|
|
|
+ url, is_main_frame, main_frame_origin,
|
|
|
|
+ &matching_plugins[i])) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
+#endif // !BUILDFLAG(ENABLE_CEF)
|
|
|
|
|
|
|
|
// If we broke out of the loop, we have found an enabled plugin.
|
|
|
|
bool enabled = i < matching_plugins.size();
|
|
|
|
diff --git chrome/renderer/chrome_content_renderer_client.cc chrome/renderer/chrome_content_renderer_client.cc
|
2018-03-20 21:15:08 +01:00
|
|
|
index 700886c6ce89..8a47ec9f91a3 100644
|
2017-12-07 22:44:24 +01:00
|
|
|
--- chrome/renderer/chrome_content_renderer_client.cc
|
|
|
|
+++ chrome/renderer/chrome_content_renderer_client.cc
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -774,6 +774,7 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
|
|
|
|
if ((status == chrome::mojom::PluginStatus::kUnauthorized ||
|
|
|
|
status == chrome::mojom::PluginStatus::kBlocked) &&
|
|
|
|
+ observer &&
|
|
|
|
observer->IsPluginTemporarilyAllowed(identifier)) {
|
|
|
|
status = chrome::mojom::PluginStatus::kAllowed;
|
|
|
|
}
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -961,7 +962,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
render_frame->GetRemoteAssociatedInterfaces()->GetInterface(
|
|
|
|
&plugin_auth_host);
|
|
|
|
plugin_auth_host->BlockedUnauthorizedPlugin(group_name, identifier);
|
|
|
|
- observer->DidBlockContentType(content_type, group_name);
|
|
|
|
+ if (observer)
|
|
|
|
+ observer->DidBlockContentType(content_type, group_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case chrome::mojom::PluginStatus::kBlocked: {
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -970,7 +972,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED, group_name));
|
|
|
|
placeholder->AllowLoading();
|
|
|
|
RenderThread::Get()->RecordAction(UserMetricsAction("Plugin_Blocked"));
|
|
|
|
- observer->DidBlockContentType(content_type, group_name);
|
|
|
|
+ if (observer)
|
|
|
|
+ observer->DidBlockContentType(content_type, group_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case chrome::mojom::PluginStatus::kBlockedByPolicy: {
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -980,7 +983,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
group_name));
|
|
|
|
RenderThread::Get()->RecordAction(
|
|
|
|
UserMetricsAction("Plugin_BlockedByPolicy"));
|
|
|
|
- observer->DidBlockContentType(content_type, group_name);
|
|
|
|
+ if (observer)
|
|
|
|
+ observer->DidBlockContentType(content_type, group_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case chrome::mojom::PluginStatus::kBlockedNoLoading: {
|
2018-03-20 21:15:08 +01:00
|
|
|
@@ -988,7 +992,8 @@ WebPlugin* ChromeContentRendererClient::CreatePlugin(
|
2017-12-07 22:44:24 +01:00
|
|
|
IDR_BLOCKED_PLUGIN_HTML,
|
|
|
|
l10n_util::GetStringFUTF16(IDS_PLUGIN_BLOCKED_NO_LOADING,
|
|
|
|
group_name));
|
|
|
|
- observer->DidBlockContentType(content_type, group_name);
|
|
|
|
+ if (observer)
|
|
|
|
+ observer->DidBlockContentType(content_type, group_name);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
case chrome::mojom::PluginStatus::kComponentUpdateRequired: {
|
2018-02-03 01:01:36 +01:00
|
|
|
diff --git chrome/renderer/plugins/chrome_plugin_placeholder.cc chrome/renderer/plugins/chrome_plugin_placeholder.cc
|
2018-03-20 21:15:08 +01:00
|
|
|
index 6bc73727e61b..4f84ab989060 100644
|
2018-02-03 01:01:36 +01:00
|
|
|
--- chrome/renderer/plugins/chrome_plugin_placeholder.cc
|
|
|
|
+++ chrome/renderer/plugins/chrome_plugin_placeholder.cc
|
2018-02-15 01:12:09 +01:00
|
|
|
@@ -350,8 +350,11 @@ void ChromePluginPlaceholder::OnBlockedContent(
|
2018-02-03 01:01:36 +01:00
|
|
|
|
|
|
|
if (status ==
|
|
|
|
content::RenderFrame::PeripheralContentStatus::CONTENT_STATUS_TINY) {
|
|
|
|
- ContentSettingsObserver::Get(render_frame())
|
|
|
|
- ->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_);
|
|
|
|
+ ContentSettingsObserver* observer =
|
|
|
|
+ ContentSettingsObserver::Get(render_frame());
|
|
|
|
+ if (observer) {
|
|
|
|
+ observer->DidBlockContentType(CONTENT_SETTINGS_TYPE_PLUGINS, title_);
|
|
|
|
+ }
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string message = base::StringPrintf(
|