OLD | NEW |
---|---|
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 Loading... | |
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, | |
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; |
486 // In this loop, copy the WebPluginInfo (and do not use a reference) because | 489 // In this loop, copy the WebPluginInfo (and do not use a reference) because |
487 // the filter might mutate it. | 490 // the filter might mutate it. |
488 for (WebPluginInfo plugin : all_plugins) { | 491 for (WebPluginInfo plugin : all_plugins) { |
489 if (!filter || filter->IsPluginAvailable(child_process_id, | 492 if (!filter || |
490 routing_id, | 493 filter->IsPluginAvailable( |
491 resource_context_, | 494 child_process_id, routing_id, resource_context_, GURL(), |
492 GURL(), | 495 GURL(main_frame_origin.Serialize()), &plugin)) { |
dcheng
2016/08/18 21:54:04
Can you file a TODO to plumb this as a url::Origin
trizzofo
2016/08/18 22:23:44
Done!
When the origin is unique, the default cont
dcheng
2016/08/18 22:26:36
Right, but a unique Origin serializes to "null", w
| |
493 GURL(), | |
494 &plugin)) { | |
495 plugins.push_back(plugin); | 496 plugins.push_back(plugin); |
496 } | 497 } |
497 } | 498 } |
498 | 499 |
499 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); | 500 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); |
500 Send(reply_msg); | 501 Send(reply_msg); |
501 } | 502 } |
502 | 503 |
503 void RenderFrameMessageFilter::OnGetPluginInfo( | 504 void RenderFrameMessageFilter::OnGetPluginInfo( |
504 int render_frame_id, | 505 int render_frame_id, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
595 net::URLRequestContext* context = | 596 net::URLRequestContext* context = |
596 GetContentClient()->browser()->OverrideRequestContextForURL( | 597 GetContentClient()->browser()->OverrideRequestContextForURL( |
597 url, resource_context_); | 598 url, resource_context_); |
598 if (!context) | 599 if (!context) |
599 context = request_context_->GetURLRequestContext(); | 600 context = request_context_->GetURLRequestContext(); |
600 | 601 |
601 return context; | 602 return context; |
602 } | 603 } |
603 | 604 |
604 } // namespace content | 605 } // namespace content |
OLD | NEW |