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

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: Address issues pointed in comments 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 448 matching lines...) Expand 10 before | Expand all | Expand 10 after
459 render_process_id_, render_frame_id, options)) { 459 render_process_id_, render_frame_id, options)) {
460 net::URLRequestContext* context = GetRequestContextForURL(url); 460 net::URLRequestContext* context = GetRequestContextForURL(url);
461 // Pass a null callback since we don't care about when the 'set' completes. 461 // Pass a null callback since we don't care about when the 'set' completes.
462 context->cookie_store()->SetCookieWithOptionsAsync( 462 context->cookie_store()->SetCookieWithOptionsAsync(
463 url, cookie, options, net::CookieStore::SetCookiesCallback()); 463 url, cookie, options, net::CookieStore::SetCookiesCallback());
464 } 464 }
465 } 465 }
466 466
467 #if defined(ENABLE_PLUGINS) 467 #if defined(ENABLE_PLUGINS)
468 468
469 void RenderFrameMessageFilter::OnGetPlugins( 469 void RenderFrameMessageFilter::OnGetPlugins(bool refresh,
470 bool refresh, 470 url::Origin main_frame_origin,
471 IPC::Message* reply_msg) { 471 IPC::Message* reply_msg) {
472 // Don't refresh if the specified threshold has not been passed. Note that 472 // Don't refresh if the specified threshold has not been passed. Note that
473 // this check is performed before off-loading to the file thread. The reason 473 // this check is performed before off-loading to the file thread. The reason
474 // we do this is that some pages tend to request that the list of plugins be 474 // we do this is that some pages tend to request that the list of plugins be
475 // refreshed at an excessive rate. This instigates disk scanning, as the list 475 // refreshed at an excessive rate. This instigates disk scanning, as the list
476 // is accumulated by doing multiple reads from disk. This effect is 476 // is accumulated by doing multiple reads from disk. This effect is
477 // multiplied when we have several pages requesting this operation. 477 // multiplied when we have several pages requesting this operation.
478 if (refresh) { 478 if (refresh) {
479 const base::TimeDelta threshold = base::TimeDelta::FromSeconds( 479 const base::TimeDelta threshold = base::TimeDelta::FromSeconds(
480 kPluginsRefreshThresholdInSeconds); 480 kPluginsRefreshThresholdInSeconds);
481 const base::TimeTicks now = base::TimeTicks::Now(); 481 const base::TimeTicks now = base::TimeTicks::Now();
482 if (now - last_plugin_refresh_time_ >= threshold) { 482 if (now - last_plugin_refresh_time_ >= threshold) {
483 // Only refresh if the threshold hasn't been exceeded yet. 483 // Only refresh if the threshold hasn't been exceeded yet.
484 PluginServiceImpl::GetInstance()->RefreshPlugins(); 484 PluginServiceImpl::GetInstance()->RefreshPlugins();
485 last_plugin_refresh_time_ = now; 485 last_plugin_refresh_time_ = now;
486 } 486 }
487 } 487 }
488 488
489 PluginServiceImpl::GetInstance()->GetPlugins(base::Bind( 489 PluginServiceImpl::GetInstance()->GetPlugins(
490 &RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg)); 490 base::Bind(&RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg,
491 main_frame_origin));
491 } 492 }
492 493
493 void RenderFrameMessageFilter::GetPluginsCallback( 494 void RenderFrameMessageFilter::GetPluginsCallback(
494 IPC::Message* reply_msg, 495 IPC::Message* reply_msg,
496 url::Origin main_frame_origin,
495 const std::vector<WebPluginInfo>& all_plugins) { 497 const std::vector<WebPluginInfo>& all_plugins) {
496 // Filter the plugin list. 498 // Filter the plugin list.
497 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter(); 499 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter();
498 std::vector<WebPluginInfo> plugins; 500 std::vector<WebPluginInfo> plugins;
499 501
500 int child_process_id = -1; 502 int child_process_id = -1;
501 int routing_id = MSG_ROUTING_NONE; 503 int routing_id = MSG_ROUTING_NONE;
502 // In this loop, copy the WebPluginInfo (and do not use a reference) because 504 // In this loop, copy the WebPluginInfo (and do not use a reference) because
503 // the filter might mutate it. 505 // the filter might mutate it.
504 for (WebPluginInfo plugin : all_plugins) { 506 for (WebPluginInfo plugin : all_plugins) {
505 if (!filter || filter->IsPluginAvailable(child_process_id, 507 if (!filter ||
506 routing_id, 508 filter->IsPluginAvailable(
alexmos 2016/08/02 22:06:27 Looking at IsPluginAvailable implementations, they
trizzofo 2016/08/03 00:08:37 Yes, we are working on it: https://crrev.com/22084
507 resource_context_, 509 child_process_id, routing_id, resource_context_, GURL(),
508 GURL(), 510 GURL(main_frame_origin.Serialize()), &plugin)) {
alexmos 2016/08/02 22:06:27 Is there a way to just use url::Origins in IsPlugi
trizzofo 2016/08/03 00:08:37 The only reason why we're using unique origins is
alexmos 2016/08/04 05:32:02 Ah, looking at your https://crrev.com/2208463002,
trizzofo 2016/08/05 02:04:25 Yes, I took a better look at url::Origin construct
509 GURL(),
510 &plugin)) {
511 plugins.push_back(plugin); 511 plugins.push_back(plugin);
512 } 512 }
513 } 513 }
514 514
515 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); 515 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins);
516 Send(reply_msg); 516 Send(reply_msg);
517 } 517 }
518 518
519 void RenderFrameMessageFilter::OnGetPluginInfo( 519 void RenderFrameMessageFilter::OnGetPluginInfo(
520 int render_frame_id, 520 int render_frame_id,
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
611 net::URLRequestContext* context = 611 net::URLRequestContext* context =
612 GetContentClient()->browser()->OverrideRequestContextForURL( 612 GetContentClient()->browser()->OverrideRequestContextForURL(
613 url, resource_context_); 613 url, resource_context_);
614 if (!context) 614 if (!context)
615 context = request_context_->GetURLRequestContext(); 615 context = request_context_->GetURLRequestContext();
616 616
617 return context; 617 return context;
618 } 618 }
619 619
620 } // namespace content 620 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698