1 // Copyright (c) 2012 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/renderer/browser_plugin/browser_plugin_manager_impl.h" 6 7 #include "content/common/browser_plugin/browser_plugin_constants.h" 8 #include "content/common/browser_plugin/browser_plugin_messages.h" 9 #include "content/common/cursors/webcursor.h" 10 #include "content/public/renderer/browser_plugin_delegate.h" 11 #include "content/renderer/browser_plugin/browser_plugin.h" 12 #include "content/renderer/render_thread_impl.h" 13 #include "ui/gfx/point.h" 14 15 namespace content { 16 BrowserPluginManagerImpl(RenderViewImpl * render_view)17BrowserPluginManagerImpl::BrowserPluginManagerImpl(RenderViewImpl* render_view) 18 : BrowserPluginManager(render_view) { 19 } 20 ~BrowserPluginManagerImpl()21BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { 22 } 23 CreateBrowserPlugin(RenderViewImpl * render_view,blink::WebFrame * frame,scoped_ptr<BrowserPluginDelegate> delegate)24BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( 25 RenderViewImpl* render_view, 26 blink::WebFrame* frame, 27 scoped_ptr<BrowserPluginDelegate> delegate) { 28 return new BrowserPlugin(render_view, frame, delegate.Pass()); 29 } 30 Send(IPC::Message * msg)31bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { 32 return RenderThread::Get()->Send(msg); 33 } 34 OnMessageReceived(const IPC::Message & message)35bool BrowserPluginManagerImpl::OnMessageReceived( 36 const IPC::Message& message) { 37 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) { 38 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; 39 // All allowed messages must have |browser_plugin_instance_id| as their 40 // first parameter. 41 PickleIterator iter(message); 42 bool success = iter.ReadInt(&browser_plugin_instance_id); 43 DCHECK(success); 44 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); 45 if (plugin && plugin->OnMessageReceived(message)) 46 return true; 47 } 48 49 return false; 50 } 51 DidCommitCompositorFrame()52void BrowserPluginManagerImpl::DidCommitCompositorFrame() { 53 IDMap<BrowserPlugin>::iterator iter(&instances_); 54 while (!iter.IsAtEnd()) { 55 iter.GetCurrentValue()->DidCommitCompositorFrame(); 56 iter.Advance(); 57 } 58 } 59 60 } // namespace content 61