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

Side by Side Diff: content/browser/frame_host/render_frame_message_filter.cc

Issue 2156803002: [HBD] Remove PluginCache and reload plugin list when origin changes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Changes per dcheng@'s comment Created 4 years, 4 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/frame_host/render_frame_message_filter.h" 5 #include "content/browser/frame_host/render_frame_message_filter.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/macros.h" 8 #include "base/macros.h"
9 #include "base/metrics/field_trial.h" 9 #include "base/metrics/field_trial.h"
10 #include "base/strings/string_util.h" 10 #include "base/strings/string_util.h"
(...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 context->cookie_store()->GetCookieListWithOptionsAsync( 445 context->cookie_store()->GetCookieListWithOptionsAsync(
446 url, options, 446 url, options,
447 base::Bind(&RenderFrameMessageFilter::CheckPolicyForCookies, this, 447 base::Bind(&RenderFrameMessageFilter::CheckPolicyForCookies, this,
448 render_frame_id, url, first_party_for_cookies, callback)); 448 render_frame_id, url, first_party_for_cookies, callback));
449 } 449 }
450 450
451 #if defined(ENABLE_PLUGINS) 451 #if defined(ENABLE_PLUGINS)
452 452
453 void RenderFrameMessageFilter::OnGetPlugins( 453 void RenderFrameMessageFilter::OnGetPlugins(
454 bool refresh, 454 bool refresh,
455 const url::Origin& main_frame_origin,
piman 2016/08/19 21:59:22 This origin comes from an untrusted source. Do we
trizzofo 2016/08/20 00:00:41 Since OnGetPluginInfo() (that effectively determin
455 IPC::Message* reply_msg) { 456 IPC::Message* reply_msg) {
456 // Don't refresh if the specified threshold has not been passed. Note that 457 // Don't refresh if the specified threshold has not been passed. Note that
457 // this check is performed before off-loading to the file thread. The reason 458 // this check is performed before off-loading to the file thread. The reason
458 // we do this is that some pages tend to request that the list of plugins be 459 // we do this is that some pages tend to request that the list of plugins be
459 // refreshed at an excessive rate. This instigates disk scanning, as the list 460 // refreshed at an excessive rate. This instigates disk scanning, as the list
460 // is accumulated by doing multiple reads from disk. This effect is 461 // is accumulated by doing multiple reads from disk. This effect is
461 // multiplied when we have several pages requesting this operation. 462 // multiplied when we have several pages requesting this operation.
462 if (refresh) { 463 if (refresh) {
463 const base::TimeDelta threshold = base::TimeDelta::FromSeconds( 464 const base::TimeDelta threshold = base::TimeDelta::FromSeconds(
464 kPluginsRefreshThresholdInSeconds); 465 kPluginsRefreshThresholdInSeconds);
465 const base::TimeTicks now = base::TimeTicks::Now(); 466 const base::TimeTicks now = base::TimeTicks::Now();
466 if (now - last_plugin_refresh_time_ >= threshold) { 467 if (now - last_plugin_refresh_time_ >= threshold) {
467 // Only refresh if the threshold hasn't been exceeded yet. 468 // Only refresh if the threshold hasn't been exceeded yet.
468 PluginServiceImpl::GetInstance()->RefreshPlugins(); 469 PluginServiceImpl::GetInstance()->RefreshPlugins();
469 last_plugin_refresh_time_ = now; 470 last_plugin_refresh_time_ = now;
470 } 471 }
471 } 472 }
472 473
473 PluginServiceImpl::GetInstance()->GetPlugins(base::Bind( 474 PluginServiceImpl::GetInstance()->GetPlugins(
474 &RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg)); 475 base::Bind(&RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg,
476 main_frame_origin));
475 } 477 }
476 478
477 void RenderFrameMessageFilter::GetPluginsCallback( 479 void RenderFrameMessageFilter::GetPluginsCallback(
478 IPC::Message* reply_msg, 480 IPC::Message* reply_msg,
481 const url::Origin& main_frame_origin,
479 const std::vector<WebPluginInfo>& all_plugins) { 482 const std::vector<WebPluginInfo>& all_plugins) {
480 // Filter the plugin list. 483 // Filter the plugin list.
481 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter(); 484 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter();
482 std::vector<WebPluginInfo> plugins; 485 std::vector<WebPluginInfo> plugins;
483 486
484 int child_process_id = -1; 487 int child_process_id = -1;
485 int routing_id = MSG_ROUTING_NONE; 488 int routing_id = MSG_ROUTING_NONE;
489 GURL policy_url =
490 main_frame_origin.unique() ? GURL() : GURL(main_frame_origin.Serialize());
486 // In this loop, copy the WebPluginInfo (and do not use a reference) because 491 // In this loop, copy the WebPluginInfo (and do not use a reference) because
487 // the filter might mutate it. 492 // the filter might mutate it.
488 for (WebPluginInfo plugin : all_plugins) { 493 for (WebPluginInfo plugin : all_plugins) {
489 if (!filter || filter->IsPluginAvailable(child_process_id, 494 // TODO(crbug.com/621724): Pass an url::Origin instead of a GURL.
490 routing_id, 495 if (!filter ||
491 resource_context_, 496 filter->IsPluginAvailable(child_process_id, routing_id,
492 GURL(), 497 resource_context_, GURL(), policy_url,
493 GURL(), 498 &plugin)) {
494 &plugin)) {
495 plugins.push_back(plugin); 499 plugins.push_back(plugin);
496 } 500 }
497 } 501 }
498 502
499 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); 503 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins);
500 Send(reply_msg); 504 Send(reply_msg);
501 } 505 }
502 506
503 void RenderFrameMessageFilter::OnGetPluginInfo( 507 void RenderFrameMessageFilter::OnGetPluginInfo(
504 int render_frame_id, 508 int render_frame_id,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
595 net::URLRequestContext* context = 599 net::URLRequestContext* context =
596 GetContentClient()->browser()->OverrideRequestContextForURL( 600 GetContentClient()->browser()->OverrideRequestContextForURL(
597 url, resource_context_); 601 url, resource_context_);
598 if (!context) 602 if (!context)
599 context = request_context_->GetURLRequestContext(); 603 context = request_context_->GetURLRequestContext();
600 604
601 return context; 605 return context;
602 } 606 }
603 607
604 } // namespace content 608 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698