| Index: content/browser/browser_plugin/browser_plugin_content_origin_whitelist.cc
|
| diff --git a/content/browser/browser_plugin/browser_plugin_content_origin_whitelist.cc b/content/browser/browser_plugin/browser_plugin_content_origin_whitelist.cc
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..ab6365418accf9e6a35d64cb162d014beca5aa3d
|
| --- /dev/null
|
| +++ b/content/browser/browser_plugin/browser_plugin_content_origin_whitelist.cc
|
| @@ -0,0 +1,61 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#include "content/browser/browser_plugin/browser_plugin_content_origin_whitelist.h"
|
| +
|
| +#include "content/common/frame_messages.h"
|
| +#include "content/public/browser/navigation_details.h"
|
| +#include "content/public/browser/render_frame_host.h"
|
| +#include "content/public/browser/web_contents.h"
|
| +
|
| +namespace content {
|
| +
|
| +BrowserPluginContentOriginWhitelist::BrowserPluginContentOriginWhitelist(
|
| + WebContents* web_contents)
|
| + : WebContentsObserver(web_contents) {
|
| +}
|
| +
|
| +BrowserPluginContentOriginWhitelist::~BrowserPluginContentOriginWhitelist() {
|
| +}
|
| +
|
| +void BrowserPluginContentOriginWhitelist::RenderFrameCreated(
|
| + RenderFrameHost* render_frame_host) {
|
| + if (!whitelist_.empty()) {
|
| + Send(new FrameMsg_UpdatePluginContentOriginWhitelist(
|
| + render_frame_host->GetRoutingID(), whitelist_));
|
| + }
|
| +}
|
| +
|
| +bool BrowserPluginContentOriginWhitelist::OnMessageReceived(
|
| + const IPC::Message& message,
|
| + RenderFrameHost* render_frame_host) {
|
| + bool handled = true;
|
| + IPC_BEGIN_MESSAGE_MAP(BrowserPluginContentOriginWhitelist, message)
|
| + IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed,
|
| + OnPluginContentOriginAllowed)
|
| + IPC_MESSAGE_UNHANDLED(handled = false)
|
| + IPC_END_MESSAGE_MAP()
|
| +
|
| + return handled;
|
| +}
|
| +
|
| +void BrowserPluginContentOriginWhitelist::DidNavigateMainFrame(
|
| + const LoadCommittedDetails& details,
|
| + const FrameNavigateParams& params) {
|
| + if (details.is_navigation_to_different_page()) {
|
| + // We expect RenderFrames to clear their replicated whitelist independently.
|
| + whitelist_.clear();
|
| + }
|
| +}
|
| +
|
| +void BrowserPluginContentOriginWhitelist::OnPluginContentOriginAllowed(
|
| + const GURL& content_origin) {
|
| + whitelist_.insert(content_origin);
|
| +
|
| + web_contents()->SendToAllFrames(
|
| + new FrameMsg_UpdatePluginContentOriginWhitelist(
|
| + MSG_ROUTING_NONE, whitelist_));
|
| +}
|
| +
|
| +} // namespace content
|
|
|