OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "content/browser/plugin_content_origin_whitelist.h" |
| 6 |
| 7 #include "content/common/frame_messages.h" |
| 8 #include "content/public/browser/navigation_details.h" |
| 9 #include "content/public/browser/render_frame_host.h" |
| 10 #include "content/public/browser/web_contents.h" |
| 11 |
| 12 namespace content { |
| 13 |
| 14 PluginContentOriginWhitelist::PluginContentOriginWhitelist( |
| 15 WebContents* web_contents) |
| 16 : WebContentsObserver(web_contents) { |
| 17 } |
| 18 |
| 19 PluginContentOriginWhitelist::~PluginContentOriginWhitelist() { |
| 20 } |
| 21 |
| 22 void PluginContentOriginWhitelist::RenderFrameCreated( |
| 23 RenderFrameHost* render_frame_host) { |
| 24 if (!whitelist_.empty()) { |
| 25 Send(new FrameMsg_UpdatePluginContentOriginWhitelist( |
| 26 render_frame_host->GetRoutingID(), whitelist_)); |
| 27 } |
| 28 } |
| 29 |
| 30 bool PluginContentOriginWhitelist::OnMessageReceived( |
| 31 const IPC::Message& message, |
| 32 RenderFrameHost* render_frame_host) { |
| 33 bool handled = true; |
| 34 IPC_BEGIN_MESSAGE_MAP(PluginContentOriginWhitelist, message) |
| 35 IPC_MESSAGE_HANDLER(FrameHostMsg_PluginContentOriginAllowed, |
| 36 OnPluginContentOriginAllowed) |
| 37 IPC_MESSAGE_UNHANDLED(handled = false) |
| 38 IPC_END_MESSAGE_MAP() |
| 39 |
| 40 return handled; |
| 41 } |
| 42 |
| 43 void PluginContentOriginWhitelist::DidNavigateMainFrame( |
| 44 const LoadCommittedDetails& details, |
| 45 const FrameNavigateParams& params) { |
| 46 if (details.is_navigation_to_different_page()) { |
| 47 // We expect RenderFrames to clear their replicated whitelist independently. |
| 48 whitelist_.clear(); |
| 49 } |
| 50 } |
| 51 |
| 52 void PluginContentOriginWhitelist::OnPluginContentOriginAllowed( |
| 53 const GURL& content_origin) { |
| 54 whitelist_.insert(content_origin); |
| 55 |
| 56 web_contents()->SendToAllFrames( |
| 57 new FrameMsg_UpdatePluginContentOriginWhitelist( |
| 58 MSG_ROUTING_NONE, whitelist_)); |
| 59 } |
| 60 |
| 61 } // namespace content |
OLD | NEW |