[email protected] | dca589ef | 2012-01-09 11:53:32 | [diff] [blame] | 1 | // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
| 4 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 5 | #include "chrome/browser/plugins/plugin_info_host_impl.h" |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 6 | |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 7 | #include <stddef.h> |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 8 | |
waffles | cd59e9b | 2016-08-30 04:34:44 | [diff] [blame] | 9 | #include <algorithm> |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 10 | #include <memory> |
dcheng | e73d8520c | 2015-12-27 01:19:09 | [diff] [blame] | 11 | #include <utility> |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 12 | |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 13 | #include "base/bind.h" |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 14 | #include "base/memory/singleton.h" |
Eugene Kim | 0b4b457 | 2018-09-01 02:37:58 | [diff] [blame] | 15 | #include "base/stl_util.h" |
[email protected] | e309f31 | 2013-06-07 21:50:08 | [diff] [blame] | 16 | #include "base/strings/utf_string_conversions.h" |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 17 | #include "base/task/post_task.h" |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 18 | #include "base/task_runner_util.h" |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame^] | 19 | #include "build/branding_buildflags.h" |
avi | b896c71 | 2015-12-26 02:10:43 | [diff] [blame] | 20 | #include "build/build_config.h" |
wfh | dfcab2e4 | 2014-11-07 06:48:32 | [diff] [blame] | 21 | #include "chrome/browser/browser_process.h" |
peconn | 5100d43 | 2015-09-16 12:03:08 | [diff] [blame] | 22 | #include "chrome/browser/content_settings/host_content_settings_map_factory.h" |
[email protected] | 6be31d20 | 2013-02-01 18:20:54 | [diff] [blame] | 23 | #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
[email protected] | cd33d28 | 2012-09-21 12:53:04 | [diff] [blame] | 24 | #include "chrome/browser/plugins/plugin_finder.h" |
[email protected] | de75c70 | 2012-09-25 23:06:02 | [diff] [blame] | 25 | #include "chrome/browser/plugins/plugin_metadata.h" |
[email protected] | 601e3c8 | 2013-10-03 01:31:20 | [diff] [blame] | 26 | #include "chrome/browser/plugins/plugin_prefs.h" |
raymes | 978301a2 | 2016-09-22 00:54:28 | [diff] [blame] | 27 | #include "chrome/browser/plugins/plugin_utils.h" |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 28 | #include "chrome/browser/profiles/profile.h" |
wfh | dfcab2e4 | 2014-11-07 06:48:32 | [diff] [blame] | 29 | #include "chrome/browser/ui/browser_otr_state.h" |
Scott Violet | 6200d33 | 2018-02-23 21:29:23 | [diff] [blame] | 30 | #include "chrome/common/buildflags.h" |
waffles | cd59e9b | 2016-08-30 04:34:44 | [diff] [blame] | 31 | #include "chrome/common/chrome_content_client.h" |
tommycli | c0c4f94 | 2016-09-19 19:35:00 | [diff] [blame] | 32 | #include "chrome/common/chrome_features.h" |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 33 | #include "chrome/common/plugin.mojom.h" |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 34 | #include "chrome/common/pref_names.h" |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 35 | #include "components/component_updater/component_updater_service.h" |
mukai | 8eaec82 | 2014-10-25 17:53:16 | [diff] [blame] | 36 | #include "components/content_settings/core/browser/content_settings_utils.h" |
| 37 | #include "components/content_settings/core/browser/host_content_settings_map.h" |
mukai | 077089f | 2014-09-11 18:41:52 | [diff] [blame] | 38 | #include "components/content_settings/core/common/content_settings.h" |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 39 | #include "components/keyed_service/content/browser_context_keyed_service_shutdown_notifier_factory.h" |
Scott Violet | 9ae8289 | 2018-03-01 18:38:12 | [diff] [blame] | 40 | #include "components/nacl/common/buildflags.h" |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 41 | #include "components/pref_registry/pref_registry_syncable.h" |
brettw | b1fc1b8 | 2016-02-02 00:19:08 | [diff] [blame] | 42 | #include "components/prefs/pref_service.h" |
nzolghadr | d87a308d | 2016-12-07 15:45:56 | [diff] [blame] | 43 | #include "components/rappor/rappor_service_impl.h" |
Steven Holte | f0f4677 | 2017-12-11 20:54:51 | [diff] [blame] | 44 | #include "components/ukm/content/source_url_recorder.h" |
Eric Seckler | 8652dcd5 | 2018-09-20 10:42:28 | [diff] [blame] | 45 | #include "content/public/browser/browser_task_traits.h" |
[email protected] | 3a5180ae | 2011-12-21 02:39:38 | [diff] [blame] | 46 | #include "content/public/browser/plugin_service.h" |
[email protected] | 31f376c | 2012-03-13 16:43:09 | [diff] [blame] | 47 | #include "content/public/browser/plugin_service_filter.h" |
tommycli | 910b408 | 2017-04-03 17:04:15 | [diff] [blame] | 48 | #include "content/public/browser/render_frame_host.h" |
wfh | dfcab2e4 | 2014-11-07 06:48:32 | [diff] [blame] | 49 | #include "content/public/common/content_constants.h" |
Scott Violet | c8240b0 | 2018-03-08 22:03:59 | [diff] [blame] | 50 | #include "extensions/buildflags/buildflags.h" |
wfh | dfcab2e4 | 2014-11-07 06:48:32 | [diff] [blame] | 51 | #include "net/base/registry_controlled_domains/registry_controlled_domain.h" |
Scott Violet | 02e38b9 | 2018-03-27 23:42:14 | [diff] [blame] | 52 | #include "ppapi/buildflags/buildflags.h" |
Steven Holte | f0f4677 | 2017-12-11 20:54:51 | [diff] [blame] | 53 | #include "services/metrics/public/cpp/ukm_builders.h" |
Mounir Lamouri | fd9dcefa | 2017-07-06 10:26:55 | [diff] [blame] | 54 | #include "services/metrics/public/cpp/ukm_recorder.h" |
[email protected] | 761fa470 | 2013-07-02 15:25:15 | [diff] [blame] | 55 | #include "url/gurl.h" |
tommycli | f2a1e9f | 2016-10-06 18:34:36 | [diff] [blame] | 56 | #include "url/origin.h" |
[email protected] | b9b88a08 | 2013-03-21 03:51:02 | [diff] [blame] | 57 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 58 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
fsamuel | 8dfa19a | 2015-05-05 01:00:39 | [diff] [blame] | 59 | #include "components/guest_view/browser/guest_view_base.h" |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 60 | #include "extensions/browser/extension_registry.h" |
hanxi | 0d0a1e9 | 2014-08-26 18:39:48 | [diff] [blame] | 61 | #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" |
lfg | 44c8a68f | 2015-04-16 16:38:15 | [diff] [blame] | 62 | #include "extensions/common/constants.h" |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 63 | #include "extensions/common/extension.h" |
| 64 | #include "extensions/common/manifest_handlers/webview_info.h" |
[email protected] | 21a2013 | 2014-07-16 00:48:59 | [diff] [blame] | 65 | #endif |
| 66 | |
Nico Weber | af3b00b | 2017-09-11 17:58:17 | [diff] [blame] | 67 | #if BUILDFLAG(ENABLE_NACL) |
[email protected] | e0ff1aa | 2014-08-16 01:38:11 | [diff] [blame] | 68 | #include "components/nacl/common/nacl_constants.h" |
| 69 | #endif |
| 70 | |
[email protected] | 3a5180ae | 2011-12-21 02:39:38 | [diff] [blame] | 71 | using content::PluginService; |
[email protected] | d7bd3e5 | 2013-07-21 04:29:20 | [diff] [blame] | 72 | using content::WebPluginInfo; |
[email protected] | 3a5180ae | 2011-12-21 02:39:38 | [diff] [blame] | 73 | |
[email protected] | b9b88a08 | 2013-03-21 03:51:02 | [diff] [blame] | 74 | namespace { |
| 75 | |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 76 | class PluginInfoHostImplShutdownNotifierFactory |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 77 | : public BrowserContextKeyedServiceShutdownNotifierFactory { |
| 78 | public: |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 79 | static PluginInfoHostImplShutdownNotifierFactory* GetInstance() { |
| 80 | return base::Singleton<PluginInfoHostImplShutdownNotifierFactory>::get(); |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 81 | } |
| 82 | |
| 83 | private: |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 84 | friend struct base::DefaultSingletonTraits< |
| 85 | PluginInfoHostImplShutdownNotifierFactory>; |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 86 | |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 87 | PluginInfoHostImplShutdownNotifierFactory() |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 88 | : BrowserContextKeyedServiceShutdownNotifierFactory( |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 89 | "PluginInfoHostImpl") {} |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 90 | |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 91 | ~PluginInfoHostImplShutdownNotifierFactory() override {} |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 92 | |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 93 | DISALLOW_COPY_AND_ASSIGN(PluginInfoHostImplShutdownNotifierFactory); |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 94 | }; |
| 95 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 96 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 97 | // Returns whether a request from a plugin to load |resource| from a renderer |
| 98 | // with process id |process_id| is a request for an internal resource by an app |
| 99 | // listed in |accessible_resources| in its manifest. |
| 100 | bool IsPluginLoadingAccessibleResourceInWebView( |
| 101 | extensions::ExtensionRegistry* extension_registry, |
| 102 | int process_id, |
| 103 | const GURL& resource) { |
| 104 | extensions::WebViewRendererState* renderer_state = |
| 105 | extensions::WebViewRendererState::GetInstance(); |
| 106 | std::string partition_id; |
| 107 | if (!renderer_state->IsGuest(process_id) || |
| 108 | !renderer_state->GetPartitionID(process_id, &partition_id)) { |
| 109 | return false; |
| 110 | } |
| 111 | |
| 112 | const std::string extension_id = resource.host(); |
paulmeyer | ad727fc6 | 2015-09-09 15:29:59 | [diff] [blame] | 113 | const extensions::Extension* extension = extension_registry->GetExtensionById( |
| 114 | extension_id, extensions::ExtensionRegistry::ENABLED); |
| 115 | if (!extension || !extensions::WebviewInfo::IsResourceWebviewAccessible( |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 116 | extension, partition_id, resource.path())) { |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 117 | return false; |
| 118 | } |
| 119 | |
| 120 | // Make sure the renderer making the request actually belongs to the |
| 121 | // same extension. |
| 122 | std::string owner_extension; |
| 123 | return renderer_state->GetOwnerInfo(process_id, nullptr, &owner_extension) && |
| 124 | owner_extension == extension_id; |
| 125 | } |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 126 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 127 | |
[email protected] | b9b88a08 | 2013-03-21 03:51:02 | [diff] [blame] | 128 | } // namespace |
| 129 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 130 | PluginInfoHostImpl::Context::Context(int render_process_id, Profile* profile) |
[email protected] | 0a8f3a7f | 2012-01-17 16:17:19 | [diff] [blame] | 131 | : render_process_id_(render_process_id), |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 132 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 133 | extension_registry_(extensions::ExtensionRegistry::Get(profile)), |
| 134 | #endif |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 135 | host_content_settings_map_( |
| 136 | HostContentSettingsMapFactory::GetForProfile(profile)), |
[email protected] | 601e3c8 | 2013-10-03 01:31:20 | [diff] [blame] | 137 | plugin_prefs_(PluginPrefs::GetForProfile(profile)) { |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 138 | allow_outdated_plugins_.Init(prefs::kPluginsAllowOutdated, |
[email protected] | 96a5c34 | 2012-12-04 18:14:02 | [diff] [blame] | 139 | profile->GetPrefs()); |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 140 | run_all_flash_in_allow_mode_.Init(prefs::kRunAllFlashInAllowMode, |
| 141 | profile->GetPrefs()); |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 142 | } |
| 143 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 144 | PluginInfoHostImpl::Context::~Context() {} |
[email protected] | 0a8f3a7f | 2012-01-17 16:17:19 | [diff] [blame] | 145 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 146 | void PluginInfoHostImpl::Context::ShutdownOnUIThread() { |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 147 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 148 | allow_outdated_plugins_.Destroy(); |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 149 | run_all_flash_in_allow_mode_.Destroy(); |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 150 | } |
| 151 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 152 | PluginInfoHostImpl::PluginInfoHostImpl(int render_process_id, Profile* profile) |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 153 | : context_(render_process_id, profile) { |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 154 | shutdown_notifier_ = |
Daniel Bratell | 84928c5 | 2018-01-16 21:40:34 | [diff] [blame] | 155 | PluginInfoHostImplShutdownNotifierFactory::GetInstance() |
| 156 | ->Get(profile) |
| 157 | ->Subscribe(base::Bind(&PluginInfoHostImpl::ShutdownOnUIThread, |
| 158 | base::Unretained(this))); |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 159 | } |
| 160 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 161 | void PluginInfoHostImpl::ShutdownOnUIThread() { |
rbpotter | 654f42d | 2016-12-02 22:17:07 | [diff] [blame] | 162 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 163 | context_.ShutdownOnUIThread(); |
| 164 | shutdown_notifier_.reset(); |
[email protected] | 0a8f3a7f | 2012-01-17 16:17:19 | [diff] [blame] | 165 | } |
| 166 | |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 167 | // static |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 168 | void PluginInfoHostImpl::RegisterUserPrefs( |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 169 | user_prefs::PrefRegistrySyncable* registry) { |
| 170 | registry->RegisterBooleanPref(prefs::kPluginsAllowOutdated, false); |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 171 | registry->RegisterBooleanPref(prefs::kRunAllFlashInAllowMode, false); |
| 172 | } |
| 173 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 174 | PluginInfoHostImpl::~PluginInfoHostImpl() {} |
[email protected] | 649d1c0 | 2012-04-27 02:56:21 | [diff] [blame] | 175 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 176 | struct PluginInfoHostImpl::GetPluginInfo_Params { |
[email protected] | 60eca4eb | 2013-12-06 00:02:16 | [diff] [blame] | 177 | int render_frame_id; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 178 | GURL url; |
tommycli | f2a1e9f | 2016-10-06 18:34:36 | [diff] [blame] | 179 | url::Origin main_frame_origin; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 180 | std::string mime_type; |
| 181 | }; |
| 182 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 183 | void PluginInfoHostImpl::GetPluginInfo(int32_t render_frame_id, |
| 184 | const GURL& url, |
| 185 | const url::Origin& origin, |
| 186 | const std::string& mime_type, |
tzik | cd02d3b | 2018-08-09 21:32:47 | [diff] [blame] | 187 | GetPluginInfoCallback callback) { |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 188 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 189 | GetPluginInfo_Params params = {render_frame_id, url, origin, mime_type}; |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 190 | PluginService::GetInstance()->GetPlugins( |
| 191 | base::BindOnce(&PluginInfoHostImpl::PluginsLoaded, |
| 192 | weak_factory_.GetWeakPtr(), params, std::move(callback))); |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 193 | } |
| 194 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 195 | void PluginInfoHostImpl::PluginsLoaded( |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 196 | const GetPluginInfo_Params& params, |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 197 | GetPluginInfoCallback callback, |
[email protected] | dfdfeb7 | 2012-06-08 11:29:02 | [diff] [blame] | 198 | const std::vector<WebPluginInfo>& plugins) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 199 | chrome::mojom::PluginInfoPtr output = chrome::mojom::PluginInfo::New(); |
[email protected] | 79fa336 | 2012-03-28 16:21:11 | [diff] [blame] | 200 | // This also fills in |actual_mime_type|. |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 201 | std::unique_ptr<PluginMetadata> plugin_metadata; |
[email protected] | 60eca4eb | 2013-12-06 00:02:16 | [diff] [blame] | 202 | if (context_.FindEnabledPlugin(params.render_frame_id, params.url, |
tommycli | f2a1e9f | 2016-10-06 18:34:36 | [diff] [blame] | 203 | params.main_frame_origin, params.mime_type, |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 204 | &output->status, &output->plugin, |
| 205 | &output->actual_mime_type, &plugin_metadata)) { |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 206 | context_.DecidePluginStatus( |
| 207 | params.url, params.main_frame_origin, output->plugin, |
| 208 | plugin_metadata->GetSecurityStatus(output->plugin), |
| 209 | plugin_metadata->identifier(), &output->status); |
[email protected] | 79fa336 | 2012-03-28 16:21:11 | [diff] [blame] | 210 | } |
[email protected] | cd33d28 | 2012-09-21 12:53:04 | [diff] [blame] | 211 | |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 212 | if (output->status == chrome::mojom::PluginStatus::kNotFound) { |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 213 | // Check to see if the component updater can fetch an implementation. |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 214 | std::unique_ptr<component_updater::ComponentInfo> cus_plugin_info = |
| 215 | g_browser_process->component_updater()->GetComponentForMimeType( |
| 216 | params.mime_type); |
| 217 | ComponentPluginLookupDone(params, std::move(output), std::move(callback), |
| 218 | std::move(plugin_metadata), |
| 219 | std::move(cus_plugin_info)); |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 220 | } else { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 221 | GetPluginInfoFinish(params, std::move(output), std::move(callback), |
| 222 | std::move(plugin_metadata)); |
wfh | be79ad5 | 2014-11-07 19:02:07 | [diff] [blame] | 223 | } |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 224 | } |
| 225 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 226 | void PluginInfoHostImpl::Context::DecidePluginStatus( |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 227 | const GURL& url, |
| 228 | const url::Origin& main_frame_origin, |
[email protected] | 546abf3 | 2012-09-14 16:55:09 | [diff] [blame] | 229 | const WebPluginInfo& plugin, |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 230 | PluginMetadata::SecurityStatus security_status, |
| 231 | const std::string& plugin_identifier, |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 232 | chrome::mojom::PluginStatus* status) const { |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 233 | if (security_status == PluginMetadata::SECURITY_STATUS_FULLY_TRUSTED) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 234 | *status = chrome::mojom::PluginStatus::kAllowed; |
wfh | e53608b | 2016-04-07 02:18:53 | [diff] [blame] | 235 | return; |
| 236 | } |
| 237 | |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 238 | ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; |
| 239 | bool uses_default_content_setting = true; |
[email protected] | 6a9d1deb | 2014-01-13 19:39:41 | [diff] [blame] | 240 | bool is_managed = false; |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 241 | // Check plugin content settings. The primary URL is the top origin URL and |
| 242 | // the secondary URL is the plugin URL. |
raymes | 978301a2 | 2016-09-22 00:54:28 | [diff] [blame] | 243 | PluginUtils::GetPluginContentSetting( |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 244 | host_content_settings_map_, plugin, main_frame_origin, url, |
| 245 | plugin_identifier, &plugin_setting, &uses_default_content_setting, |
| 246 | &is_managed); |
tommycli | e2b1f1b | 2015-03-31 22:54:59 | [diff] [blame] | 247 | |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 248 | DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); |
tommycli | e2b1f1b | 2015-03-31 22:54:59 | [diff] [blame] | 249 | DCHECK(plugin_setting != CONTENT_SETTING_ASK); |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 250 | |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 251 | if (*status == chrome::mojom::PluginStatus::kFlashHiddenPreferHtml) { |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 252 | if (plugin_setting == CONTENT_SETTING_BLOCK) { |
Tommy C. Li | 717a34a | 2019-03-28 16:24:51 | [diff] [blame] | 253 | *status = is_managed ? chrome::mojom::PluginStatus::kBlockedByPolicy |
| 254 | : chrome::mojom::PluginStatus::kBlockedNoLoading; |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 255 | } |
| 256 | return; |
| 257 | } |
| 258 | |
bauerb | ecab4f5 | 2017-03-13 20:16:41 | [diff] [blame] | 259 | #if BUILDFLAG(ENABLE_PLUGINS) |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 260 | // Check if the plugin is outdated. |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 261 | if (security_status == PluginMetadata::SECURITY_STATUS_OUT_OF_DATE && |
[email protected] | 9f230ed | 2012-05-24 11:19:40 | [diff] [blame] | 262 | !allow_outdated_plugins_.GetValue()) { |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 263 | if (allow_outdated_plugins_.IsManaged()) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 264 | *status = chrome::mojom::PluginStatus::kOutdatedDisallowed; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 265 | } else { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 266 | *status = chrome::mojom::PluginStatus::kOutdatedBlocked; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 267 | } |
| 268 | return; |
| 269 | } |
bauerb | ecab4f5 | 2017-03-13 20:16:41 | [diff] [blame] | 270 | #endif // BUILDFLAG(ENABLE_PLUGINS) |
[email protected] | ef97ce34 | 2012-09-24 20:05:02 | [diff] [blame] | 271 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 272 | // Check if the plugin is crashing too much. |
[email protected] | ef97ce34 | 2012-09-24 20:05:02 | [diff] [blame] | 273 | if (PluginService::GetInstance()->IsPluginUnstable(plugin.path) && |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 274 | plugin_setting != CONTENT_SETTING_BLOCK && uses_default_content_setting) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 275 | *status = chrome::mojom::PluginStatus::kUnauthorized; |
[email protected] | ef97ce34 | 2012-09-24 20:05:02 | [diff] [blame] | 276 | return; |
| 277 | } |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 278 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 279 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 280 | // If an app has explicitly made internal resources available by listing them |
| 281 | // in |accessible_resources| in the manifest, then allow them to be loaded by |
| 282 | // plugins inside a guest-view. |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 283 | if (url.SchemeIs(extensions::kExtensionScheme) && !is_managed && |
lfg | 44c8a68f | 2015-04-16 16:38:15 | [diff] [blame] | 284 | plugin_setting == CONTENT_SETTING_BLOCK && |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 285 | IsPluginLoadingAccessibleResourceInWebView(extension_registry_, |
| 286 | render_process_id_, url)) { |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 287 | plugin_setting = CONTENT_SETTING_ALLOW; |
| 288 | } |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 289 | #endif // BUILDFLAG(ENABLE_EXTENSIONS) |
Sadrul Habib Chowdhury | f43c33c | 2014-12-04 15:53:52 | [diff] [blame] | 290 | |
tommycli | 608ec89b | 2016-09-28 16:39:00 | [diff] [blame] | 291 | if (plugin_setting == CONTENT_SETTING_DETECT_IMPORTANT_CONTENT || |
| 292 | (plugin_setting == CONTENT_SETTING_ALLOW && |
Bernhard Bauer | 1919073 | 2017-09-28 09:03:33 | [diff] [blame] | 293 | !run_all_flash_in_allow_mode_.GetValue())) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 294 | *status = chrome::mojom::PluginStatus::kPlayImportantContent; |
tommycli | e2b1f1b | 2015-03-31 22:54:59 | [diff] [blame] | 295 | } else if (plugin_setting == CONTENT_SETTING_BLOCK) { |
Tommy C. Li | 717a34a | 2019-03-28 16:24:51 | [diff] [blame] | 296 | *status = is_managed ? chrome::mojom::PluginStatus::kBlockedByPolicy |
| 297 | : chrome::mojom::PluginStatus::kBlocked; |
[email protected] | 6a9d1deb | 2014-01-13 19:39:41 | [diff] [blame] | 298 | } |
[email protected] | aea757d | 2013-09-27 22:27:38 | [diff] [blame] | 299 | |
brettw | 00899e6 | 2016-11-12 02:10:17 | [diff] [blame] | 300 | #if BUILDFLAG(ENABLE_EXTENSIONS) |
tommycli | 550b222 | 2015-09-03 21:06:10 | [diff] [blame] | 301 | // Allow an embedder of <webview> to block a plugin from being loaded inside |
| 302 | // the guest. In order to do this, set the status to 'Unauthorized' here, |
| 303 | // and update the status as appropriate depending on the response from the |
| 304 | // embedder. |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 305 | if (*status == chrome::mojom::PluginStatus::kAllowed || |
| 306 | *status == chrome::mojom::PluginStatus::kBlocked || |
| 307 | *status == chrome::mojom::PluginStatus::kPlayImportantContent) { |
[email protected] | 140d6cd9 | 2014-08-12 18:26:46 | [diff] [blame] | 308 | if (extensions::WebViewRendererState::GetInstance()->IsGuest( |
tommycli | 550b222 | 2015-09-03 21:06:10 | [diff] [blame] | 309 | render_process_id_)) |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 310 | *status = chrome::mojom::PluginStatus::kUnauthorized; |
[email protected] | aea757d | 2013-09-27 22:27:38 | [diff] [blame] | 311 | } |
tommycli | 550b222 | 2015-09-03 21:06:10 | [diff] [blame] | 312 | #endif |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 313 | } |
| 314 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 315 | bool PluginInfoHostImpl::Context::FindEnabledPlugin( |
[email protected] | 60eca4eb | 2013-12-06 00:02:16 | [diff] [blame] | 316 | int render_frame_id, |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 317 | const GURL& url, |
tommycli | f2a1e9f | 2016-10-06 18:34:36 | [diff] [blame] | 318 | const url::Origin& main_frame_origin, |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 319 | const std::string& mime_type, |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 320 | chrome::mojom::PluginStatus* status, |
[email protected] | dfdfeb7 | 2012-06-08 11:29:02 | [diff] [blame] | 321 | WebPluginInfo* plugin, |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 322 | std::string* actual_mime_type, |
dcheng | 4af4858 | 2016-04-19 00:29:35 | [diff] [blame] | 323 | std::unique_ptr<PluginMetadata>* plugin_metadata) const { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 324 | *status = chrome::mojom::PluginStatus::kAllowed; |
bauerb | 96d29c0 | 2015-04-09 08:40:35 | [diff] [blame] | 325 | |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 326 | bool allow_wildcard = true; |
[email protected] | dfdfeb7 | 2012-06-08 11:29:02 | [diff] [blame] | 327 | std::vector<WebPluginInfo> matching_plugins; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 328 | std::vector<std::string> mime_types; |
| 329 | PluginService::GetInstance()->GetPluginInfoArray( |
| 330 | url, mime_type, allow_wildcard, &matching_plugins, &mime_types); |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame^] | 331 | #if BUILDFLAG(GOOGLE_CHROME_BRANDING) |
Eugene Kim | 0b4b457 | 2018-09-01 02:37:58 | [diff] [blame] | 332 | base::EraseIf(matching_plugins, [&](const WebPluginInfo& info) { |
| 333 | return info.path.value() == ChromeContentClient::kNotPresent; |
| 334 | }); |
Nico Weber | eaa0841 | 2019-08-14 01:24:37 | [diff] [blame^] | 335 | #endif // BUILDFLAG(GOOGLE_CHROME_BRANDING) |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 336 | if (matching_plugins.empty()) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 337 | *status = chrome::mojom::PluginStatus::kNotFound; |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 338 | return false; |
| 339 | } |
| 340 | |
[email protected] | 3a5180ae | 2011-12-21 02:39:38 | [diff] [blame] | 341 | content::PluginServiceFilter* filter = |
| 342 | PluginService::GetInstance()->GetFilter(); |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 343 | size_t i = 0; |
| 344 | for (; i < matching_plugins.size(); ++i) { |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 345 | if (!filter || |
| 346 | filter->IsPluginAvailable(render_process_id_, render_frame_id, url, |
| 347 | main_frame_origin, &matching_plugins[i])) { |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 348 | break; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 349 | } |
| 350 | } |
| 351 | |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 352 | // If we broke out of the loop, we have found an enabled plugin. |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 353 | bool enabled = i < matching_plugins.size(); |
| 354 | if (!enabled) { |
tommycli | e86b298 | 2015-03-16 20:16:45 | [diff] [blame] | 355 | // Otherwise, we only found disabled plugins, so we take the first one. |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 356 | i = 0; |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 357 | *status = chrome::mojom::PluginStatus::kDisabled; |
tommycli | c0c4f94 | 2016-09-19 19:35:00 | [diff] [blame] | 358 | |
Tommy C. Li | 5834262 | 2019-03-27 23:08:51 | [diff] [blame] | 359 | // Special case for Flash: this is our Prefer HTML over Plugins logic. |
| 360 | if (matching_plugins[0].name == |
| 361 | base::ASCIIToUTF16(content::kFlashPluginName)) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 362 | *status = chrome::mojom::PluginStatus::kFlashHiddenPreferHtml; |
tommycli | e97656b8 | 2016-11-30 16:43:00 | [diff] [blame] | 363 | |
| 364 | // In the Prefer HTML case, the plugin is actually enabled, but hidden. |
| 365 | // It will still be blocked in the body of DecidePluginStatus. |
| 366 | enabled = true; |
tommycli | c0c4f94 | 2016-09-19 19:35:00 | [diff] [blame] | 367 | } |
[email protected] | 4da40567 | 2012-10-25 10:43:03 | [diff] [blame] | 368 | } |
| 369 | |
| 370 | *plugin = matching_plugins[i]; |
| 371 | *actual_mime_type = mime_types[i]; |
| 372 | if (plugin_metadata) |
| 373 | *plugin_metadata = PluginFinder::GetInstance()->GetPluginMetadata(*plugin); |
| 374 | |
| 375 | return enabled; |
[email protected] | 8aa7a41 | 2011-11-07 12:33:42 | [diff] [blame] | 376 | } |
| 377 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 378 | void PluginInfoHostImpl::ComponentPluginLookupDone( |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 379 | const GetPluginInfo_Params& params, |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 380 | chrome::mojom::PluginInfoPtr output, |
| 381 | GetPluginInfoCallback callback, |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 382 | std::unique_ptr<PluginMetadata> plugin_metadata, |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 383 | std::unique_ptr<component_updater::ComponentInfo> cus_plugin_info) { |
| 384 | if (cus_plugin_info) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 385 | output->status = chrome::mojom::PluginStatus::kComponentUpdateRequired; |
waffles | e7759f7 | 2016-10-10 23:41:25 | [diff] [blame] | 386 | #if defined(OS_LINUX) |
| 387 | if (cus_plugin_info->version != base::Version("0")) { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 388 | output->status = chrome::mojom::PluginStatus::kRestartRequired; |
waffles | e7759f7 | 2016-10-10 23:41:25 | [diff] [blame] | 389 | } |
thestig | d6e43818 | 2017-06-01 23:16:27 | [diff] [blame] | 390 | #endif |
Tommy C. Li | 7c493d19 | 2019-03-28 21:50:26 | [diff] [blame] | 391 | // Component Updater wouldn't provide a deprecated plugin. |
| 392 | bool plugin_is_deprecated = false; |
Jeremy Roman | ec48d7a | 2018-03-01 17:35:09 | [diff] [blame] | 393 | plugin_metadata = std::make_unique<PluginMetadata>( |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 394 | cus_plugin_info->id, cus_plugin_info->name, false, GURL(), GURL(), |
Tommy C. Li | 7c493d19 | 2019-03-28 21:50:26 | [diff] [blame] | 395 | base::ASCIIToUTF16(cus_plugin_info->id), std::string(), |
| 396 | plugin_is_deprecated); |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 397 | } |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 398 | GetPluginInfoFinish(params, std::move(output), std::move(callback), |
| 399 | std::move(plugin_metadata)); |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 400 | } |
| 401 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 402 | void PluginInfoHostImpl::GetPluginInfoFinish( |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 403 | const GetPluginInfo_Params& params, |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 404 | chrome::mojom::PluginInfoPtr output, |
| 405 | GetPluginInfoCallback callback, |
| 406 | std::unique_ptr<PluginMetadata> plugin_metadata) { |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 407 | if (plugin_metadata) { |
| 408 | output->group_identifier = plugin_metadata->identifier(); |
| 409 | output->group_name = plugin_metadata->name(); |
| 410 | } |
| 411 | |
| 412 | context_.MaybeGrantAccess(output->status, output->plugin.path); |
| 413 | |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 414 | if (output->status != chrome::mojom::PluginStatus::kNotFound) { |
Clark DuVall | 1df2052b | 2019-08-05 19:58:46 | [diff] [blame] | 415 | ReportMetrics(params.render_frame_id, output->actual_mime_type, params.url, |
| 416 | params.main_frame_origin); |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 417 | } |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 418 | std::move(callback).Run(std::move(output)); |
waffles | 77255cc | 2016-08-02 17:25:12 | [diff] [blame] | 419 | } |
| 420 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 421 | void PluginInfoHostImpl::ReportMetrics(int render_frame_id, |
| 422 | const base::StringPiece& mime_type, |
| 423 | const GURL& url, |
Steven Holte | f0f4677 | 2017-12-11 20:54:51 | [diff] [blame] | 424 | const url::Origin& main_frame_origin) { |
tommycli | 910b408 | 2017-04-03 17:04:15 | [diff] [blame] | 425 | DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 426 | |
| 427 | content::RenderFrameHost* frame = content::RenderFrameHost::FromID( |
| 428 | context_.render_process_id(), render_frame_id); |
| 429 | content::WebContents* web_contents = |
| 430 | content::WebContents::FromRenderFrameHost(frame); |
| 431 | // This can occur the web contents has already been closed or navigated away. |
| 432 | if (!web_contents) |
| 433 | return; |
| 434 | |
| 435 | if (web_contents->GetBrowserContext()->IsOffTheRecord()) |
| 436 | return; |
| 437 | |
| 438 | rappor::RapporServiceImpl* rappor_service = |
| 439 | g_browser_process->rappor_service(); |
| 440 | if (!rappor_service) |
| 441 | return; |
Chris Palmer | ab5e5b5 | 2018-09-28 19:19:30 | [diff] [blame] | 442 | if (main_frame_origin.opaque()) |
tommycli | 910b408 | 2017-04-03 17:04:15 | [diff] [blame] | 443 | return; |
| 444 | |
| 445 | if (mime_type != content::kFlashPluginSwfMimeType && |
| 446 | mime_type != content::kFlashPluginSplMimeType) { |
| 447 | return; |
| 448 | } |
| 449 | |
| 450 | rappor_service->RecordSampleString( |
| 451 | "Plugins.FlashOriginUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 452 | net::registry_controlled_domains::GetDomainAndRegistry( |
| 453 | main_frame_origin.GetURL(), |
| 454 | net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); |
| 455 | rappor_service->RecordSampleString( |
| 456 | "Plugins.FlashUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, |
| 457 | net::registry_controlled_domains::GetDomainAndRegistry( |
| 458 | url, net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); |
| 459 | |
Steven Holte | f0f4677 | 2017-12-11 20:54:51 | [diff] [blame] | 460 | ukm::builders::Plugins_FlashInstance( |
| 461 | ukm::GetSourceIdForWebContentsDocument(web_contents)) |
| 462 | .Record(ukm::UkmRecorder::Get()); |
tommycli | 910b408 | 2017-04-03 17:04:15 | [diff] [blame] | 463 | } |
| 464 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 465 | void PluginInfoHostImpl::Context::MaybeGrantAccess( |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 466 | chrome::mojom::PluginStatus status, |
[email protected] | 650b2d5 | 2013-02-10 03:41:45 | [diff] [blame] | 467 | const base::FilePath& path) const { |
Nicholas Verne | b5df4f7 | 2017-11-08 09:12:07 | [diff] [blame] | 468 | if (status == chrome::mojom::PluginStatus::kAllowed || |
| 469 | status == chrome::mojom::PluginStatus::kPlayImportantContent) { |
[email protected] | 6be31d20 | 2013-02-01 18:20:54 | [diff] [blame] | 470 | ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( |
| 471 | render_process_id_, path); |
| 472 | } |
| 473 | } |
| 474 | |
Nicholas Verne | d391eae | 2017-11-13 02:41:38 | [diff] [blame] | 475 | bool PluginInfoHostImpl::Context::IsPluginEnabled( |
[email protected] | 4cbbeb4 | 2014-07-22 19:29:38 | [diff] [blame] | 476 | const content::WebPluginInfo& plugin) const { |
| 477 | return plugin_prefs_->IsPluginEnabled(plugin); |
| 478 | } |