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