Upstream version 11.39.266.0
[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/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
17 BrowserPluginManagerImpl::BrowserPluginManagerImpl(RenderViewImpl* render_view)
18     : BrowserPluginManager(render_view) {
19 }
20
21 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() {
22 }
23
24 BrowserPlugin* 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
31 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) {
32   return RenderThread::Get()->Send(msg);
33 }
34
35 bool 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
52 void 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