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

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

Issue 21930006: <webview>: Allocate the view instance ID from the WebView shim (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Merge with ToT Created 7 years, 4 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
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/browser_plugin_constants.h" 7 #include "content/common/browser_plugin/browser_plugin_constants.h"
8 #include "content/common/browser_plugin/browser_plugin_messages.h" 8 #include "content/common/browser_plugin/browser_plugin_messages.h"
9 #include "content/renderer/browser_plugin/browser_plugin.h" 9 #include "content/renderer/browser_plugin/browser_plugin.h"
10 #include "content/renderer/render_thread_impl.h" 10 #include "content/renderer/render_thread_impl.h"
11 #include "ui/gfx/point.h" 11 #include "ui/gfx/point.h"
12 #include "webkit/common/cursors/webcursor.h" 12 #include "webkit/common/cursors/webcursor.h"
13 13
14 namespace content { 14 namespace content {
15 15
16 BrowserPluginManagerImpl::BrowserPluginManagerImpl( 16 BrowserPluginManagerImpl::BrowserPluginManagerImpl(
17 RenderViewImpl* render_view) 17 RenderViewImpl* render_view)
18 : BrowserPluginManager(render_view), 18 : BrowserPluginManager(render_view),
19 browser_plugin_instance_id_counter_(0) { 19 request_id_counter_(0) {
20 } 20 }
21 21
22 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() { 22 BrowserPluginManagerImpl::~BrowserPluginManagerImpl() {
23 } 23 }
24 24
25 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin( 25 BrowserPlugin* BrowserPluginManagerImpl::CreateBrowserPlugin(
26 RenderViewImpl* render_view, 26 RenderViewImpl* render_view,
27 WebKit::WebFrame* frame, 27 WebKit::WebFrame* frame,
28 const WebKit::WebPluginParams& params) { 28 const WebKit::WebPluginParams& params) {
29 return new BrowserPlugin(render_view, frame, params, 29 return new BrowserPlugin(render_view, frame, params);
30 ++browser_plugin_instance_id_counter_);
31 } 30 }
32 31
33 void BrowserPluginManagerImpl::AllocateInstanceID( 32 void BrowserPluginManagerImpl::AllocateInstanceID(
34 BrowserPlugin* browser_plugin) { 33 BrowserPlugin* browser_plugin) {
35 int instance_id = browser_plugin->instance_id(); 34 int request_id = ++request_id_counter_;
36 pending_allocate_guest_instance_id_requests_.AddWithID(browser_plugin, 35 pending_allocate_guest_instance_id_requests_.AddWithID(browser_plugin,
37 instance_id); 36 request_id);
38 Send(new BrowserPluginHostMsg_AllocateInstanceID( 37 Send(new BrowserPluginHostMsg_AllocateInstanceID(
39 browser_plugin->render_view_routing_id(), instance_id)); 38 browser_plugin->render_view_routing_id(), request_id));
40 } 39 }
41 40
42 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) { 41 bool BrowserPluginManagerImpl::Send(IPC::Message* msg) {
43 return RenderThread::Get()->Send(msg); 42 return RenderThread::Get()->Send(msg);
44 } 43 }
45 44
46 bool BrowserPluginManagerImpl::OnMessageReceived( 45 bool BrowserPluginManagerImpl::OnMessageReceived(
47 const IPC::Message& message) { 46 const IPC::Message& message) {
48 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) { 47 if (BrowserPlugin::ShouldForwardToBrowserPlugin(message)) {
49 int guest_instance_id = browser_plugin::kInstanceIDNone; 48 int guest_instance_id = browser_plugin::kInstanceIDNone;
(...skipping 21 matching lines...) Expand all
71 void BrowserPluginManagerImpl::DidCommitCompositorFrame() { 70 void BrowserPluginManagerImpl::DidCommitCompositorFrame() {
72 IDMap<BrowserPlugin>::iterator iter(&instances_); 71 IDMap<BrowserPlugin>::iterator iter(&instances_);
73 while (!iter.IsAtEnd()) { 72 while (!iter.IsAtEnd()) {
74 iter.GetCurrentValue()->DidCommitCompositorFrame(); 73 iter.GetCurrentValue()->DidCommitCompositorFrame();
75 iter.Advance(); 74 iter.Advance();
76 } 75 }
77 } 76 }
78 77
79 void BrowserPluginManagerImpl::OnAllocateInstanceIDACK( 78 void BrowserPluginManagerImpl::OnAllocateInstanceIDACK(
80 const IPC::Message& message, 79 const IPC::Message& message,
81 int browser_plugin_instance_id, 80 int request_id,
82 int guest_instance_id) { 81 int guest_instance_id) {
83 BrowserPlugin* plugin = 82 BrowserPlugin* plugin =
84 pending_allocate_guest_instance_id_requests_.Lookup( 83 pending_allocate_guest_instance_id_requests_.Lookup(request_id);
85 browser_plugin_instance_id);
86 if (!plugin) 84 if (!plugin)
87 return; 85 return;
88 pending_allocate_guest_instance_id_requests_.Remove( 86 pending_allocate_guest_instance_id_requests_.Remove(request_id);
89 browser_plugin_instance_id);
90 plugin->OnInstanceIDAllocated(guest_instance_id); 87 plugin->OnInstanceIDAllocated(guest_instance_id);
91 } 88 }
92 89
93 void BrowserPluginManagerImpl::OnPluginAtPositionRequest( 90 void BrowserPluginManagerImpl::OnPluginAtPositionRequest(
94 const IPC::Message& message, 91 const IPC::Message& message,
95 int request_id, 92 int request_id,
96 const gfx::Point& position) { 93 const gfx::Point& position) {
97 int guest_instance_id = browser_plugin::kInstanceIDNone; 94 int guest_instance_id = browser_plugin::kInstanceIDNone;
98 IDMap<BrowserPlugin>::iterator it(&instances_); 95 IDMap<BrowserPlugin>::iterator it(&instances_);
99 gfx::Point local_position = position; 96 gfx::Point local_position = position;
100 while (!it.IsAtEnd()) { 97 while (!it.IsAtEnd()) {
101 const BrowserPlugin* plugin = it.GetCurrentValue(); 98 const BrowserPlugin* plugin = it.GetCurrentValue();
102 if (!plugin->guest_crashed() && plugin->InBounds(position)) { 99 if (!plugin->guest_crashed() && plugin->InBounds(position)) {
103 guest_instance_id = plugin->guest_instance_id(); 100 guest_instance_id = plugin->guest_instance_id();
104 local_position = plugin->ToLocalCoordinates(position); 101 local_position = plugin->ToLocalCoordinates(position);
105 break; 102 break;
106 } 103 }
107 it.Advance(); 104 it.Advance();
108 } 105 }
109 106
110 Send(new BrowserPluginHostMsg_PluginAtPositionResponse( 107 Send(new BrowserPluginHostMsg_PluginAtPositionResponse(
111 message.routing_id(), guest_instance_id, request_id, local_position)); 108 message.routing_id(), guest_instance_id, request_id, local_position));
112 } 109 }
113 110
114 } // namespace content 111 } // 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