Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(318)

Side by Side Diff: chrome/browser/plugins/plugin_info_message_filter.cc

Issue 2378573005: [HBD] Blanket BLOCK on all non-HTTP(s) and non-FILE URLs for Flash. (Closed)
Patch Set: Merge branch 'master' of https://chromium.googlesource.com/chromium/src into 293-hbd-implement-blan… Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/plugins/plugin_info_message_filter.h" 5 #include "chrome/browser/plugins/plugin_info_message_filter.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 24 matching lines...) Expand all
35 #include "components/content_settings/core/browser/host_content_settings_map.h" 35 #include "components/content_settings/core/browser/host_content_settings_map.h"
36 #include "components/content_settings/core/common/content_settings.h" 36 #include "components/content_settings/core/common/content_settings.h"
37 #include "components/prefs/pref_service.h" 37 #include "components/prefs/pref_service.h"
38 #include "components/rappor/rappor_service.h" 38 #include "components/rappor/rappor_service.h"
39 #include "content/public/browser/browser_thread.h" 39 #include "content/public/browser/browser_thread.h"
40 #include "content/public/browser/plugin_service.h" 40 #include "content/public/browser/plugin_service.h"
41 #include "content/public/browser/plugin_service_filter.h" 41 #include "content/public/browser/plugin_service_filter.h"
42 #include "content/public/common/content_constants.h" 42 #include "content/public/common/content_constants.h"
43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h" 43 #include "net/base/registry_controlled_domains/registry_controlled_domain.h"
44 #include "url/gurl.h" 44 #include "url/gurl.h"
45 #include "url/origin.h"
45 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR. 46 #include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
46 47
47 #if defined(ENABLE_EXTENSIONS) 48 #if defined(ENABLE_EXTENSIONS)
48 #include "components/guest_view/browser/guest_view_base.h" 49 #include "components/guest_view/browser/guest_view_base.h"
49 #include "extensions/browser/extension_registry.h" 50 #include "extensions/browser/extension_registry.h"
50 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h" 51 #include "extensions/browser/guest_view/web_view/web_view_renderer_state.h"
51 #include "extensions/common/constants.h" 52 #include "extensions/common/constants.h"
52 #include "extensions/common/extension.h" 53 #include "extensions/common/extension.h"
53 #include "extensions/common/manifest_handlers/webview_info.h" 54 #include "extensions/common/manifest_handlers/webview_info.h"
54 #endif 55 #endif
(...skipping 27 matching lines...) Expand all
82 status, PLUGIN_AVAILABILITY_STATUS_MAX); 83 status, PLUGIN_AVAILABILITY_STATUS_MAX);
83 #endif // defined(WIDEVINE_CDM_AVAILABLE) 84 #endif // defined(WIDEVINE_CDM_AVAILABLE)
84 } 85 }
85 86
86 #endif // defined(ENABLE_PEPPER_CDMS) 87 #endif // defined(ENABLE_PEPPER_CDMS)
87 88
88 // Report usage metrics for Silverlight and Flash plugin instantiations to the 89 // Report usage metrics for Silverlight and Flash plugin instantiations to the
89 // RAPPOR service. 90 // RAPPOR service.
90 void ReportMetrics(const std::string& mime_type, 91 void ReportMetrics(const std::string& mime_type,
91 const GURL& url, 92 const GURL& url,
92 const GURL& origin_url) { 93 const url::Origin& main_frame_origin) {
93 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 94 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
94 95
95 if (chrome::IsIncognitoSessionActive()) 96 if (chrome::IsIncognitoSessionActive())
96 return; 97 return;
97 rappor::RapporService* rappor_service = g_browser_process->rappor_service(); 98 rappor::RapporService* rappor_service = g_browser_process->rappor_service();
98 if (!rappor_service) 99 if (!rappor_service)
99 return; 100 return;
101 if (main_frame_origin.unique())
102 return;
100 103
101 if (mime_type == content::kFlashPluginSwfMimeType || 104 if (mime_type == content::kFlashPluginSwfMimeType ||
102 mime_type == content::kFlashPluginSplMimeType) { 105 mime_type == content::kFlashPluginSplMimeType) {
103 rappor_service->RecordSample( 106 rappor_service->RecordSample(
104 "Plugins.FlashOriginUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, 107 "Plugins.FlashOriginUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
105 net::registry_controlled_domains::GetDomainAndRegistry( 108 net::registry_controlled_domains::GetDomainAndRegistry(
106 origin_url, 109 GURL(main_frame_origin.Serialize()),
nasko 2016/10/05 21:14:31 main_frame_origin.GetURL()
tommycli 2016/10/05 21:41:22 Done.
107 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); 110 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES));
108 rappor_service->RecordSample( 111 rappor_service->RecordSample(
109 "Plugins.FlashUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE, 112 "Plugins.FlashUrl", rappor::ETLD_PLUS_ONE_RAPPOR_TYPE,
110 net::registry_controlled_domains::GetDomainAndRegistry( 113 net::registry_controlled_domains::GetDomainAndRegistry(
111 url, 114 url,
112 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES)); 115 net::registry_controlled_domains::INCLUDE_PRIVATE_REGISTRIES));
113 } 116 }
114 } 117 }
115 118
116 #if defined(ENABLE_EXTENSIONS) 119 #if defined(ENABLE_EXTENSIONS)
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 203
201 // Destroy on the UI thread because we contain a |PrefMember|. 204 // Destroy on the UI thread because we contain a |PrefMember|.
202 content::BrowserThread::DeleteOnUIThread::Destruct(this); 205 content::BrowserThread::DeleteOnUIThread::Destruct(this);
203 } 206 }
204 207
205 PluginInfoMessageFilter::~PluginInfoMessageFilter() {} 208 PluginInfoMessageFilter::~PluginInfoMessageFilter() {}
206 209
207 struct PluginInfoMessageFilter::GetPluginInfo_Params { 210 struct PluginInfoMessageFilter::GetPluginInfo_Params {
208 int render_frame_id; 211 int render_frame_id;
209 GURL url; 212 GURL url;
210 GURL top_origin_url; 213 url::Origin main_frame_origin;
211 std::string mime_type; 214 std::string mime_type;
212 }; 215 };
213 216
214 void PluginInfoMessageFilter::OnGetPluginInfo( 217 void PluginInfoMessageFilter::OnGetPluginInfo(
215 int render_frame_id, 218 int render_frame_id,
216 const GURL& url, 219 const GURL& url,
217 const GURL& top_origin_url, 220 const url::Origin& main_frame_origin,
218 const std::string& mime_type, 221 const std::string& mime_type,
219 IPC::Message* reply_msg) { 222 IPC::Message* reply_msg) {
220 GetPluginInfo_Params params = { 223 GetPluginInfo_Params params = {render_frame_id, url, main_frame_origin,
221 render_frame_id, 224 mime_type};
222 url,
223 top_origin_url,
224 mime_type
225 };
226 PluginService::GetInstance()->GetPlugins( 225 PluginService::GetInstance()->GetPlugins(
227 base::Bind(&PluginInfoMessageFilter::PluginsLoaded, 226 base::Bind(&PluginInfoMessageFilter::PluginsLoaded,
228 weak_ptr_factory_.GetWeakPtr(), 227 weak_ptr_factory_.GetWeakPtr(),
229 params, reply_msg)); 228 params, reply_msg));
230 } 229 }
231 230
232 void PluginInfoMessageFilter::PluginsLoaded( 231 void PluginInfoMessageFilter::PluginsLoaded(
233 const GetPluginInfo_Params& params, 232 const GetPluginInfo_Params& params,
234 IPC::Message* reply_msg, 233 IPC::Message* reply_msg,
235 const std::vector<WebPluginInfo>& plugins) { 234 const std::vector<WebPluginInfo>& plugins) {
236 std::unique_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output( 235 std::unique_ptr<ChromeViewHostMsg_GetPluginInfo_Output> output(
237 new ChromeViewHostMsg_GetPluginInfo_Output()); 236 new ChromeViewHostMsg_GetPluginInfo_Output());
238 // This also fills in |actual_mime_type|. 237 // This also fills in |actual_mime_type|.
239 std::unique_ptr<PluginMetadata> plugin_metadata; 238 std::unique_ptr<PluginMetadata> plugin_metadata;
240 if (context_.FindEnabledPlugin(params.render_frame_id, params.url, 239 if (context_.FindEnabledPlugin(params.render_frame_id, params.url,
241 params.top_origin_url, params.mime_type, 240 params.main_frame_origin, params.mime_type,
242 &output->status, &output->plugin, 241 &output->status, &output->plugin,
243 &output->actual_mime_type, &plugin_metadata)) { 242 &output->actual_mime_type, &plugin_metadata)) {
244 context_.DecidePluginStatus(params, output->plugin, plugin_metadata.get(), 243 context_.DecidePluginStatus(params, output->plugin, plugin_metadata.get(),
245 &output->status); 244 &output->status);
246 } 245 }
247 246
248 if (output->status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) { 247 if (output->status == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) {
249 // Check to see if the component updater can fetch an implementation. 248 // Check to see if the component updater can fetch an implementation.
250 base::PostTaskAndReplyWithResult( 249 base::PostTaskAndReplyWithResult(
251 main_thread_task_runner_.get(), FROM_HERE, 250 main_thread_task_runner_.get(), FROM_HERE,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 *status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 311 *status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
313 return; 312 return;
314 } 313 }
315 314
316 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT; 315 ContentSetting plugin_setting = CONTENT_SETTING_DEFAULT;
317 bool uses_default_content_setting = true; 316 bool uses_default_content_setting = true;
318 bool is_managed = false; 317 bool is_managed = false;
319 // Check plugin content settings. The primary URL is the top origin URL and 318 // Check plugin content settings. The primary URL is the top origin URL and
320 // the secondary URL is the plugin URL. 319 // the secondary URL is the plugin URL.
321 PluginUtils::GetPluginContentSetting( 320 PluginUtils::GetPluginContentSetting(
322 host_content_settings_map_, plugin, params.top_origin_url, params.url, 321 host_content_settings_map_, plugin, params.main_frame_origin, params.url,
323 plugin_metadata->identifier(), &plugin_setting, 322 plugin_metadata->identifier(), &plugin_setting,
324 &uses_default_content_setting, &is_managed); 323 &uses_default_content_setting, &is_managed);
325 324
326 // TODO(tommycli): Remove once we deprecate the plugin ASK policy. 325 // TODO(tommycli): Remove once we deprecate the plugin ASK policy.
327 bool legacy_ask_user = plugin_setting == CONTENT_SETTING_ASK; 326 bool legacy_ask_user = plugin_setting == CONTENT_SETTING_ASK;
328 plugin_setting = PluginsFieldTrial::EffectiveContentSetting( 327 plugin_setting = PluginsFieldTrial::EffectiveContentSetting(
329 CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting); 328 CONTENT_SETTINGS_TYPE_PLUGINS, plugin_setting);
330 329
331 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT); 330 DCHECK(plugin_setting != CONTENT_SETTING_DEFAULT);
332 DCHECK(plugin_setting != CONTENT_SETTING_ASK); 331 DCHECK(plugin_setting != CONTENT_SETTING_ASK);
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
390 if (extensions::WebViewRendererState::GetInstance()->IsGuest( 389 if (extensions::WebViewRendererState::GetInstance()->IsGuest(
391 render_process_id_)) 390 render_process_id_))
392 *status = ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized; 391 *status = ChromeViewHostMsg_GetPluginInfo_Status::kUnauthorized;
393 } 392 }
394 #endif 393 #endif
395 } 394 }
396 395
397 bool PluginInfoMessageFilter::Context::FindEnabledPlugin( 396 bool PluginInfoMessageFilter::Context::FindEnabledPlugin(
398 int render_frame_id, 397 int render_frame_id,
399 const GURL& url, 398 const GURL& url,
400 const GURL& top_origin_url, 399 const url::Origin& main_frame_origin,
401 const std::string& mime_type, 400 const std::string& mime_type,
402 ChromeViewHostMsg_GetPluginInfo_Status* status, 401 ChromeViewHostMsg_GetPluginInfo_Status* status,
403 WebPluginInfo* plugin, 402 WebPluginInfo* plugin,
404 std::string* actual_mime_type, 403 std::string* actual_mime_type,
405 std::unique_ptr<PluginMetadata>* plugin_metadata) const { 404 std::unique_ptr<PluginMetadata>* plugin_metadata) const {
406 *status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed; 405 *status = ChromeViewHostMsg_GetPluginInfo_Status::kAllowed;
407 406
408 bool allow_wildcard = true; 407 bool allow_wildcard = true;
409 std::vector<WebPluginInfo> matching_plugins; 408 std::vector<WebPluginInfo> matching_plugins;
410 std::vector<std::string> mime_types; 409 std::vector<std::string> mime_types;
(...skipping 12 matching lines...) Expand all
423 #endif // defined(GOOGLE_CHROME_BUILD) 422 #endif // defined(GOOGLE_CHROME_BUILD)
424 if (matching_plugins.empty()) { 423 if (matching_plugins.empty()) {
425 *status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound; 424 *status = ChromeViewHostMsg_GetPluginInfo_Status::kNotFound;
426 return false; 425 return false;
427 } 426 }
428 427
429 content::PluginServiceFilter* filter = 428 content::PluginServiceFilter* filter =
430 PluginService::GetInstance()->GetFilter(); 429 PluginService::GetInstance()->GetFilter();
431 size_t i = 0; 430 size_t i = 0;
432 for (; i < matching_plugins.size(); ++i) { 431 for (; i < matching_plugins.size(); ++i) {
433 if (!filter || filter->IsPluginAvailable(render_process_id_, 432 if (!filter ||
434 render_frame_id, 433 filter->IsPluginAvailable(render_process_id_, render_frame_id,
435 resource_context_, 434 resource_context_, url, main_frame_origin,
436 url, 435 &matching_plugins[i])) {
437 top_origin_url,
438 &matching_plugins[i])) {
439 break; 436 break;
440 } 437 }
441 } 438 }
442 439
443 // If we broke out of the loop, we have found an enabled plugin. 440 // If we broke out of the loop, we have found an enabled plugin.
444 bool enabled = i < matching_plugins.size(); 441 bool enabled = i < matching_plugins.size();
445 if (!enabled) { 442 if (!enabled) {
446 // Otherwise, we only found disabled plugins, so we take the first one. 443 // Otherwise, we only found disabled plugins, so we take the first one.
447 i = 0; 444 i = 0;
448 *status = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled; 445 *status = ChromeViewHostMsg_GetPluginInfo_Status::kDisabled;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
492 output->group_name = plugin_metadata->name(); 489 output->group_name = plugin_metadata->name();
493 } 490 }
494 491
495 context_.MaybeGrantAccess(output->status, output->plugin.path); 492 context_.MaybeGrantAccess(output->status, output->plugin.path);
496 493
497 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output); 494 ChromeViewHostMsg_GetPluginInfo::WriteReplyParams(reply_msg, *output);
498 Send(reply_msg); 495 Send(reply_msg);
499 if (output->status != ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) { 496 if (output->status != ChromeViewHostMsg_GetPluginInfo_Status::kNotFound) {
500 main_thread_task_runner_->PostTask( 497 main_thread_task_runner_->PostTask(
501 FROM_HERE, base::Bind(&ReportMetrics, output->actual_mime_type, 498 FROM_HERE, base::Bind(&ReportMetrics, output->actual_mime_type,
502 params.url, params.top_origin_url)); 499 params.url, params.main_frame_origin));
503 } 500 }
504 } 501 }
505 502
506 void PluginInfoMessageFilter::Context::MaybeGrantAccess( 503 void PluginInfoMessageFilter::Context::MaybeGrantAccess(
507 ChromeViewHostMsg_GetPluginInfo_Status status, 504 ChromeViewHostMsg_GetPluginInfo_Status status,
508 const base::FilePath& path) const { 505 const base::FilePath& path) const {
509 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed || 506 if (status == ChromeViewHostMsg_GetPluginInfo_Status::kAllowed ||
510 status == ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) { 507 status == ChromeViewHostMsg_GetPluginInfo_Status::kPlayImportantContent) {
511 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin( 508 ChromePluginServiceFilter::GetInstance()->AuthorizePlugin(
512 render_process_id_, path); 509 render_process_id_, path);
513 } 510 }
514 } 511 }
515 512
516 bool PluginInfoMessageFilter::Context::IsPluginEnabled( 513 bool PluginInfoMessageFilter::Context::IsPluginEnabled(
517 const content::WebPluginInfo& plugin) const { 514 const content::WebPluginInfo& plugin) const {
518 return plugin_prefs_->IsPluginEnabled(plugin); 515 return plugin_prefs_->IsPluginEnabled(plugin);
519 } 516 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698