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 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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( |
470 bool refresh, | 470 bool refresh, |
| 471 const url::Origin& main_frame_origin, |
471 IPC::Message* reply_msg) { | 472 IPC::Message* reply_msg) { |
472 // Don't refresh if the specified threshold has not been passed. Note that | 473 // 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 | 474 // 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 | 475 // 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 | 476 // refreshed at an excessive rate. This instigates disk scanning, as the list |
476 // is accumulated by doing multiple reads from disk. This effect is | 477 // is accumulated by doing multiple reads from disk. This effect is |
477 // multiplied when we have several pages requesting this operation. | 478 // multiplied when we have several pages requesting this operation. |
478 if (refresh) { | 479 if (refresh) { |
479 const base::TimeDelta threshold = base::TimeDelta::FromSeconds( | 480 const base::TimeDelta threshold = base::TimeDelta::FromSeconds( |
480 kPluginsRefreshThresholdInSeconds); | 481 kPluginsRefreshThresholdInSeconds); |
481 const base::TimeTicks now = base::TimeTicks::Now(); | 482 const base::TimeTicks now = base::TimeTicks::Now(); |
482 if (now - last_plugin_refresh_time_ >= threshold) { | 483 if (now - last_plugin_refresh_time_ >= threshold) { |
483 // Only refresh if the threshold hasn't been exceeded yet. | 484 // Only refresh if the threshold hasn't been exceeded yet. |
484 PluginServiceImpl::GetInstance()->RefreshPlugins(); | 485 PluginServiceImpl::GetInstance()->RefreshPlugins(); |
485 last_plugin_refresh_time_ = now; | 486 last_plugin_refresh_time_ = now; |
486 } | 487 } |
487 } | 488 } |
488 | 489 |
489 PluginServiceImpl::GetInstance()->GetPlugins(base::Bind( | 490 PluginServiceImpl::GetInstance()->GetPlugins( |
490 &RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg)); | 491 base::Bind(&RenderFrameMessageFilter::GetPluginsCallback, this, reply_msg, |
| 492 main_frame_origin)); |
491 } | 493 } |
492 | 494 |
493 void RenderFrameMessageFilter::GetPluginsCallback( | 495 void RenderFrameMessageFilter::GetPluginsCallback( |
494 IPC::Message* reply_msg, | 496 IPC::Message* reply_msg, |
| 497 const url::Origin& main_frame_origin, |
495 const std::vector<WebPluginInfo>& all_plugins) { | 498 const std::vector<WebPluginInfo>& all_plugins) { |
496 // Filter the plugin list. | 499 // Filter the plugin list. |
497 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter(); | 500 PluginServiceFilter* filter = PluginServiceImpl::GetInstance()->GetFilter(); |
498 std::vector<WebPluginInfo> plugins; | 501 std::vector<WebPluginInfo> plugins; |
499 | 502 |
500 int child_process_id = -1; | 503 int child_process_id = -1; |
501 int routing_id = MSG_ROUTING_NONE; | 504 int routing_id = MSG_ROUTING_NONE; |
502 // In this loop, copy the WebPluginInfo (and do not use a reference) because | 505 // In this loop, copy the WebPluginInfo (and do not use a reference) because |
503 // the filter might mutate it. | 506 // the filter might mutate it. |
504 for (WebPluginInfo plugin : all_plugins) { | 507 for (WebPluginInfo plugin : all_plugins) { |
505 if (!filter || filter->IsPluginAvailable(child_process_id, | 508 if (!filter || |
506 routing_id, | 509 filter->IsPluginAvailable( |
507 resource_context_, | 510 child_process_id, routing_id, resource_context_, GURL(), |
508 GURL(), | 511 GURL(main_frame_origin.Serialize()), &plugin)) { |
509 GURL(), | |
510 &plugin)) { | |
511 plugins.push_back(plugin); | 512 plugins.push_back(plugin); |
512 } | 513 } |
513 } | 514 } |
514 | 515 |
515 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); | 516 FrameHostMsg_GetPlugins::WriteReplyParams(reply_msg, plugins); |
516 Send(reply_msg); | 517 Send(reply_msg); |
517 } | 518 } |
518 | 519 |
519 void RenderFrameMessageFilter::OnGetPluginInfo( | 520 void RenderFrameMessageFilter::OnGetPluginInfo( |
520 int render_frame_id, | 521 int render_frame_id, |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
611 net::URLRequestContext* context = | 612 net::URLRequestContext* context = |
612 GetContentClient()->browser()->OverrideRequestContextForURL( | 613 GetContentClient()->browser()->OverrideRequestContextForURL( |
613 url, resource_context_); | 614 url, resource_context_); |
614 if (!context) | 615 if (!context) |
615 context = request_context_->GetURLRequestContext(); | 616 context = request_context_->GetURLRequestContext(); |
616 | 617 |
617 return context; | 618 return context; |
618 } | 619 } |
619 | 620 |
620 } // namespace content | 621 } // namespace content |
OLD | NEW |