| Index: chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc
|
| diff --git a/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc b/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc
|
| index f8e601db41e245801c327d7f2956776b798dd7a0..be0c3f04a16c2ed83d9a2a5c23cae94ce16b0afc 100644
|
| --- a/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc
|
| +++ b/chrome/browser/renderer_host/pepper/pepper_flash_browser_host.cc
|
| @@ -4,13 +4,10 @@
|
|
|
| #include "chrome/browser/renderer_host/pepper/pepper_flash_browser_host.h"
|
|
|
| +#include "base/callback.h"
|
| #include "base/time.h"
|
| -#include "content/public/browser/browser_context.h"
|
| +#include "chrome/browser/renderer_host/pepper/flash_lso_settings_helper.h"
|
| #include "content/public/browser/browser_ppapi_host.h"
|
| -#include "content/public/browser/browser_thread.h"
|
| -#include "content/public/browser/content_browser_client.h"
|
| -#include "content/public/browser/render_process_host.h"
|
| -#include "content/public/browser/resource_context.h"
|
| #include "googleurl/src/gurl.h"
|
| #include "ipc/ipc_message_macros.h"
|
| #include "ppapi/c/pp_errors.h"
|
| @@ -27,36 +24,19 @@
|
| #endif
|
|
|
| using content::BrowserPpapiHost;
|
| -using content::BrowserThread;
|
| -using content::RenderProcessHost;
|
| -using content::ResourceContext;
|
|
|
| namespace chrome {
|
|
|
| -namespace {
|
| -
|
| -// Get the ResourceContext on the UI thread for the given render process ID.
|
| -ResourceContext* GetResourceContext(int render_process_id) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
|
| - RenderProcessHost* render_process_host = RenderProcessHost::FromID(
|
| - render_process_id);
|
| - if (render_process_host && render_process_host->GetBrowserContext())
|
| - return render_process_host->GetBrowserContext()->GetResourceContext();
|
| - return NULL;
|
| -}
|
| -
|
| -} // namespace
|
| -
|
| PepperFlashBrowserHost::PepperFlashBrowserHost(
|
| BrowserPpapiHost* host,
|
| PP_Instance instance,
|
| PP_Resource resource)
|
| : ResourceHost(host->GetPpapiHost(), instance, resource),
|
| host_(host),
|
| - resource_context_(NULL),
|
| weak_factory_(ALLOW_THIS_IN_INITIALIZER_LIST(this)) {
|
| - int unused;
|
| - host->GetRenderViewIDsForInstance(instance, &render_process_id_, &unused);
|
| + int render_process_id, unused;
|
| + host->GetRenderViewIDsForInstance(instance, &render_process_id, &unused);
|
| + lso_settings_helper_ = new FlashLSOSettingsHelper(render_process_id);
|
| }
|
|
|
| PepperFlashBrowserHost::~PepperFlashBrowserHost() {
|
| @@ -108,50 +88,18 @@ int32_t PepperFlashBrowserHost::OnMsgGetLocalTimeZoneOffset(
|
|
|
| int32_t PepperFlashBrowserHost::OnMsgGetLocalDataRestrictions(
|
| ppapi::host::HostMessageContext* context) {
|
| - // Getting the LocalDataRestrictions needs to be done on the IO thread,
|
| - // however it relies on the ResourceContext which can only be accessed from
|
| - // the UI thread. We lazily initialize |resource_context_| by grabbing the
|
| - // pointer from the UI thread and then call |GetLocalDataRestrictions| with
|
| - // it.
|
| - GURL document_url = host_->GetDocumentURLForInstance(pp_instance());
|
| - GURL plugin_url = host_->GetPluginURLForInstance(pp_instance());
|
| - if (resource_context_) {
|
| - GetLocalDataRestrictions(context->MakeReplyMessageContext(), document_url,
|
| - plugin_url, resource_context_);
|
| - } else {
|
| - BrowserThread::PostTaskAndReplyWithResult(BrowserThread::UI, FROM_HERE,
|
| - base::Bind(&GetResourceContext, render_process_id_),
|
| - base::Bind(&PepperFlashBrowserHost::GetLocalDataRestrictions,
|
| - weak_factory_.GetWeakPtr(),
|
| - context->MakeReplyMessageContext(),
|
| - document_url, plugin_url));
|
| - }
|
| + lso_settings_helper_->GetLocalDataRestrictions(
|
| + host_->GetDocumentURLForInstance(pp_instance()),
|
| + host_->GetPluginURLForInstance(pp_instance()),
|
| + base::Bind(&PepperFlashBrowserHost::OnGetLocalDataRestrictions,
|
| + weak_factory_.GetWeakPtr(),
|
| + context->MakeReplyMessageContext()));
|
| return PP_OK_COMPLETIONPENDING;
|
| }
|
|
|
| -void PepperFlashBrowserHost::GetLocalDataRestrictions(
|
| +void PepperFlashBrowserHost::OnGetLocalDataRestrictions(
|
| ppapi::host::ReplyMessageContext reply_context,
|
| - const GURL& document_url,
|
| - const GURL& plugin_url,
|
| - ResourceContext* resource_context) {
|
| - DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
|
| - // Note that the resource context lives on the IO thread and is owned by the
|
| - // browser profile so its lifetime should outlast ours.
|
| - if (!resource_context_)
|
| - resource_context_ = resource_context;
|
| -
|
| - PP_FlashLSORestrictions restrictions = PP_FLASHLSORESTRICTIONS_NONE;
|
| - if (resource_context_ && document_url.is_valid() && plugin_url.is_valid()) {
|
| - content::ContentBrowserClient* client =
|
| - content::GetContentClient()->browser();
|
| - if (!client->AllowPluginLocalDataAccess(document_url, plugin_url,
|
| - resource_context_)) {
|
| - restrictions = PP_FLASHLSORESTRICTIONS_BLOCK;
|
| - } else if (client->AllowPluginLocalDataSessionOnly(plugin_url,
|
| - resource_context_)) {
|
| - restrictions = PP_FLASHLSORESTRICTIONS_IN_MEMORY;
|
| - }
|
| - }
|
| + PP_FlashLSORestrictions restrictions) {
|
| SendReply(reply_context, PpapiPluginMsg_Flash_GetLocalDataRestrictionsReply(
|
| static_cast<int32_t>(restrictions)));
|
| }
|
|
|