Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(170)

Side by Side Diff: content/renderer/browser_plugin/browser_plugin_manager_impl.cc

Issue 11826005: Browser Plugin: Implement BrowserPluginObserver. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Merge with ToT Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h" 5 #include "content/renderer/browser_plugin/browser_plugin_manager_impl.h"
6 6
7 #include "content/common/browser_plugin_messages.h" 7 #include "content/common/browser_plugin_messages.h"
8 #include "content/renderer/browser_plugin/browser_plugin.h" 8 #include "content/renderer/browser_plugin/browser_plugin_impl.h"
9 #include "content/renderer/render_thread_impl.h" 9 #include "content/renderer/render_thread_impl.h"
10 #include "ui/gfx/point.h" 10 #include "ui/gfx/point.h"
11 #include "webkit/glue/webcursor.h" 11 #include "webkit/glue/webcursor.h"
12 12
13 namespace content { 13 namespace content {
14 14
15 BrowserPluginManagerImpl::BrowserPluginManagerImpl( 15 BrowserPluginManagerImpl::BrowserPluginManagerImpl(
16 RenderViewImpl* render_view) 16 RenderViewImpl* render_view)
17 : BrowserPluginManager(render_view), 17 : BrowserPluginManager(render_view),
18 request_id_counter_(0) { 18 request_id_counter_(0) {
19 } 19 }
20 20
21 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { 21 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() {
22 } 22 }
23 23
24 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( 24 BrowserPluginImpl* BrowserPluginManagerImpl::CreateBrowserPlugin(
25 RenderViewImpl* render_view, 25 RenderViewImpl* render_view,
26 WebKit::WebFrame* frame, 26 WebKit::WebFrame* frame,
27 const WebKit::WebPluginParams& params) { 27 const WebKit::WebPluginParams& params) {
28 return new BrowserPlugin(render_view, frame, params); 28 return new BrowserPluginImpl(render_view, frame, params);
29 } 29 }
30 30
31 void BrowserPluginManagerImpl::AllocateInstanceID( 31 void BrowserPluginManagerImpl::AllocateInstanceID(
32 BrowserPlugin* browser_plugin) { 32 BrowserPluginImpl* browser_plugin) {
33 int request_id = request_id_counter_++; 33 int request_id = request_id_counter_++;
34 pending_allocate_instance_id_requests_.AddWithID(browser_plugin, request_id); 34 pending_allocate_instance_id_requests_.AddWithID(browser_plugin, request_id);
35 Send(new BrowserPluginHostMsg_AllocateInstanceID( 35 Send(new BrowserPluginHostMsg_AllocateInstanceID(
36 browser_plugin->render_view_routing_id(), request_id)); 36 browser_plugin->render_view_routing_id(), request_id));
37 } 37 }
38 38
39 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { 39 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) {
40 return RenderThread::Get()->Send(msg); 40 return RenderThread::Get()->Send(msg);
41 } 41 }
42 42
43 bool BrowserPluginManagerImpl::OnMessageReceived( 43 bool BrowserPluginManagerImpl::OnMessageReceived(
44 const IPC::Message& message) { 44 const IPC::Message& message) {
45 if (ShouldForwardToBrowserPlugin(message)) { 45 if (ShouldForwardToBrowserPlugin(message)) {
46 int instance_id = 0; 46 int instance_id = 0;
47 // All allowed messages must have instance_id as their first parameter. 47 // All allowed messages must have instance_id as their first parameter.
48 PickleIterator iter(message); 48 PickleIterator iter(message);
49 bool success = iter.ReadInt(&instance_id); 49 bool success = iter.ReadInt(&instance_id);
50 DCHECK(success); 50 DCHECK(success);
51 BrowserPlugin* plugin = GetBrowserPlugin(instance_id); 51 BrowserPluginImpl* plugin = GetBrowserPlugin(instance_id);
52 if (plugin && plugin->OnMessageReceived(message)) 52 if (plugin && plugin->OnMessageReceived(message))
53 return true; 53 return true;
54 } 54 }
55 55
56 bool handled = true; 56 bool handled = true;
57 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message) 57 IPC_BEGIN_MESSAGE_MAP(BrowserPluginManagerImpl, message)
58 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AllocateInstanceID_ACK, 58 IPC_MESSAGE_HANDLER(BrowserPluginMsg_AllocateInstanceID_ACK,
59 OnAllocateInstanceIDACK) 59 OnAllocateInstanceIDACK)
60 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped, 60 IPC_MESSAGE_HANDLER(BrowserPluginMsg_BuffersSwapped,
61 OnUnhandledSwap); 61 OnUnhandledSwap);
62 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest, 62 IPC_MESSAGE_HANDLER(BrowserPluginMsg_PluginAtPositionRequest,
63 OnPluginAtPositionRequest); 63 OnPluginAtPositionRequest);
64 IPC_MESSAGE_UNHANDLED(handled = false) 64 IPC_MESSAGE_UNHANDLED(handled = false)
65 IPC_END_MESSAGE_MAP() 65 IPC_END_MESSAGE_MAP()
66 return handled; 66 return handled;
67 } 67 }
68 68
69 void BrowserPluginManagerImpl::OnAllocateInstanceIDACK( 69 void BrowserPluginManagerImpl::OnAllocateInstanceIDACK(
70 const IPC::Message& message, int request_id, int instance_id) { 70 const IPC::Message& message, int request_id, int instance_id) {
71 BrowserPlugin* plugin = 71 BrowserPluginImpl* plugin =
72 pending_allocate_instance_id_requests_.Lookup(request_id); 72 pending_allocate_instance_id_requests_.Lookup(request_id);
73 pending_allocate_instance_id_requests_.Remove(request_id); 73 pending_allocate_instance_id_requests_.Remove(request_id);
74 if (plugin) 74 if (plugin)
75 plugin->SetInstanceID(instance_id); 75 plugin->SetInstanceID(instance_id);
76 } 76 }
77 77
78 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( 78 void BrowserPluginManagerImpl::OnPluginAtPositionRequest(
79 const IPC::Message& message, 79 const IPC::Message& message,
80 int request_id, 80 int request_id,
81 const gfx::Point& position) { 81 const gfx::Point& position) {
82 int instance_id = -1; 82 int instance_id = -1;
83 IDMap<BrowserPlugin>::iterator it(&instances_); 83 IDMap<BrowserPluginImpl>::iterator it(&instances_);
84 gfx::Point local_position = position; 84 gfx::Point local_position = position;
85 while (!it.IsAtEnd()) { 85 while (!it.IsAtEnd()) {
86 const BrowserPlugin* plugin = it.GetCurrentValue(); 86 const BrowserPluginImpl* plugin = it.GetCurrentValue();
87 if (plugin->InBounds(position)) { 87 if (plugin->InBounds(position)) {
88 instance_id = plugin->instance_id(); 88 instance_id = plugin->instance_id();
89 local_position = plugin->ToLocalCoordinates(position); 89 local_position = plugin->ToLocalCoordinates(position);
90 break; 90 break;
91 } 91 }
92 it.Advance(); 92 it.Advance();
93 } 93 }
94 94
95 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( 95 Send(new BrowserPluginHostMsg_PluginAtPositionResponse(
96 message.routing_id(), instance_id, request_id, local_position)); 96 message.routing_id(), instance_id, request_id, local_position));
(...skipping 18 matching lines...) Expand all
115 gpu_host_id, 115 gpu_host_id,
116 mailbox_name, 116 mailbox_name,
117 0)); 117 0));
118 } 118 }
119 119
120 // static 120 // static
121 bool BrowserPluginManagerImpl::ShouldForwardToBrowserPlugin( 121 bool BrowserPluginManagerImpl::ShouldForwardToBrowserPlugin(
122 const IPC::Message& message) { 122 const IPC::Message& message) {
123 switch (message.type()) { 123 switch (message.type()) {
124 case BrowserPluginMsg_AdvanceFocus::ID: 124 case BrowserPluginMsg_AdvanceFocus::ID:
125 case BrowserPluginMsg_BuffersSwapped::ID:
126 case BrowserPluginMsg_ForwardMessage::ID:
125 case BrowserPluginMsg_GuestContentWindowReady::ID: 127 case BrowserPluginMsg_GuestContentWindowReady::ID:
126 case BrowserPluginMsg_GuestGone::ID: 128 case BrowserPluginMsg_GuestGone::ID:
127 case BrowserPluginMsg_GuestResponsive::ID: 129 case BrowserPluginMsg_GuestResponsive::ID:
128 case BrowserPluginMsg_GuestUnresponsive::ID: 130 case BrowserPluginMsg_GuestUnresponsive::ID:
129 case BrowserPluginMsg_LoadAbort::ID: 131 case BrowserPluginMsg_LoadAbort::ID:
130 case BrowserPluginMsg_LoadCommit::ID: 132 case BrowserPluginMsg_LoadCommit::ID:
131 case BrowserPluginMsg_LoadRedirect::ID: 133 case BrowserPluginMsg_LoadRedirect::ID:
132 case BrowserPluginMsg_LoadStart::ID: 134 case BrowserPluginMsg_LoadStart::ID:
133 case BrowserPluginMsg_LoadStop::ID: 135 case BrowserPluginMsg_LoadStop::ID:
134 case BrowserPluginMsg_RequestPermission::ID: 136 case BrowserPluginMsg_RequestPermission::ID:
135 case BrowserPluginMsg_SetCursor::ID: 137 case BrowserPluginMsg_SetCursor::ID:
136 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID: 138 case BrowserPluginMsg_ShouldAcceptTouchEvents::ID:
137 case BrowserPluginMsg_UpdatedName::ID: 139 case BrowserPluginMsg_UpdatedName::ID:
138 case BrowserPluginMsg_UpdateRect::ID: 140 case BrowserPluginMsg_UpdateRect::ID:
139 case BrowserPluginMsg_BuffersSwapped::ID:
140 return true; 141 return true;
141 default: 142 default:
142 break; 143 break;
143 } 144 }
144 return false; 145 return false;
145 } 146 }
146 147
147 } // namespace content 148 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_manager_impl.h ('k') | content/renderer/browser_plugin/mock_browser_plugin.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698