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

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

Issue 801173002: Fix message routing for BrowserPlugin in iframe (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix tests that don't have a RenderThreadImpl Created 6 years 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.h" 5 #include "content/renderer/browser_plugin/browser_plugin_manager.h"
6
7 #include "base/memory/scoped_ptr.h" 6 #include "base/memory/scoped_ptr.h"
8 #include "content/common/browser_plugin/browser_plugin_constants.h" 7 #include "content/common/browser_plugin/browser_plugin_constants.h"
9 #include "content/common/browser_plugin/browser_plugin_messages.h" 8 #include "content/common/browser_plugin/browser_plugin_messages.h"
10 #include "content/common/frame_messages.h" 9 #include "content/common/frame_messages.h"
11 #include "content/public/renderer/browser_plugin_delegate.h" 10 #include "content/public/renderer/browser_plugin_delegate.h"
12 #include "content/public/renderer/render_thread.h" 11 #include "content/public/renderer/content_renderer_client.h"
13 #include "content/renderer/browser_plugin/browser_plugin.h" 12 #include "content/renderer/browser_plugin/browser_plugin.h"
13 #include "content/renderer/render_thread_impl.h"
14 #include "ipc/ipc_message_macros.h" 14 #include "ipc/ipc_message_macros.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 // static 18 // static
19 BrowserPluginManager* BrowserPluginManager::Create( 19 BrowserPluginManager* BrowserPluginManager::Get() {
20 RenderViewImpl* render_view) { 20 if (!RenderThreadImpl::current())
21 return new BrowserPluginManager(render_view); 21 return nullptr;
22 return RenderThreadImpl::current()->browser_plugin_manager();
22 } 23 }
23 24
24 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) 25 BrowserPluginManager::BrowserPluginManager() {
25 : RenderViewObserver(render_view),
26 render_view_(render_view->AsWeakPtr()) {
27 } 26 }
28 27
29 BrowserPluginManager::~BrowserPluginManager() { 28 BrowserPluginManager::~BrowserPluginManager() {
30 } 29 }
31 30
32 void BrowserPluginManager::AddBrowserPlugin( 31 void BrowserPluginManager::AddBrowserPlugin(
33 int browser_plugin_instance_id, 32 int browser_plugin_instance_id,
34 BrowserPlugin* browser_plugin) { 33 BrowserPlugin* browser_plugin) {
35 instances_.AddWithID(browser_plugin, browser_plugin_instance_id); 34 instances_.AddWithID(browser_plugin, browser_plugin_instance_id);
36 } 35 }
37 36
38 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) { 37 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) {
39 instances_.Remove(browser_plugin_instance_id); 38 instances_.Remove(browser_plugin_instance_id);
40 } 39 }
41 40
42 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( 41 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(
43 int browser_plugin_instance_id) const { 42 int browser_plugin_instance_id) const {
44 return instances_.Lookup(browser_plugin_instance_id); 43 return instances_.Lookup(browser_plugin_instance_id);
45 } 44 }
46 45
47 int BrowserPluginManager::GetNextInstanceID() { 46 int BrowserPluginManager::GetNextInstanceID() {
48 return RenderThread::Get()->GenerateRoutingID(); 47 return RenderThreadImpl::current()->GenerateRoutingID();
49 } 48 }
50 49
51 void BrowserPluginManager::UpdateDeviceScaleFactor() { 50 void BrowserPluginManager::UpdateDeviceScaleFactor() {
52 IDMap<BrowserPlugin>::iterator iter(&instances_); 51 IDMap<BrowserPlugin>::iterator iter(&instances_);
53 while (!iter.IsAtEnd()) { 52 while (!iter.IsAtEnd()) {
54 iter.GetCurrentValue()->UpdateDeviceScaleFactor(); 53 iter.GetCurrentValue()->UpdateDeviceScaleFactor();
55 iter.Advance(); 54 iter.Advance();
56 } 55 }
57 } 56 }
58 57
(...skipping 11 matching lines...) Expand all
70 plugin->Attach(); 69 plugin->Attach();
71 } 70 }
72 71
73 void BrowserPluginManager::Detach(int browser_plugin_instance_id) { 72 void BrowserPluginManager::Detach(int browser_plugin_instance_id) {
74 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); 73 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id);
75 if (plugin) 74 if (plugin)
76 plugin->Detach(); 75 plugin->Detach();
77 } 76 }
78 77
79 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin( 78 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin(
80 RenderViewImpl* render_view, 79 RenderFrame* render_frame,
81 blink::WebFrame* frame,
82 scoped_ptr<BrowserPluginDelegate> delegate) { 80 scoped_ptr<BrowserPluginDelegate> delegate) {
83 return new BrowserPlugin(render_view, frame, delegate.Pass()); 81 return new BrowserPlugin(render_frame, delegate.Pass());
84 } 82 }
85 83
86 void BrowserPluginManager::DidCommitCompositorFrame() { 84 void BrowserPluginManager::DidCommitCompositorFrame(
85 int render_view_routing_id) {
87 IDMap<BrowserPlugin>::iterator iter(&instances_); 86 IDMap<BrowserPlugin>::iterator iter(&instances_);
88 while (!iter.IsAtEnd()) { 87 while (!iter.IsAtEnd()) {
89 iter.GetCurrentValue()->DidCommitCompositorFrame(); 88 if (iter.GetCurrentValue()->render_view_routing_id() ==
89 render_view_routing_id) {
90 iter.GetCurrentValue()->DidCommitCompositorFrame();
91 }
90 iter.Advance(); 92 iter.Advance();
91 } 93 }
92 } 94 }
93 95
94 bool BrowserPluginManager::OnMessageReceived( 96 bool BrowserPluginManager::OnControlMessageReceived(
95 const IPC::Message& message) { 97 const IPC::Message& message) {
96 if (!BrowserPlugin::ShouldForwardToBrowserPlugin(message)) 98 if (!BrowserPlugin::ShouldForwardToBrowserPlugin(message) &&
99 !content::GetContentClient()->renderer()->
100 ShouldForwardToGuestContainer(message)) {
97 return false; 101 return false;
102 }
98 103
99 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone; 104 int browser_plugin_instance_id = browser_plugin::kInstanceIDNone;
100 // All allowed messages must have |browser_plugin_instance_id| as their 105 // All allowed messages must have |browser_plugin_instance_id| as their
101 // first parameter. 106 // first parameter.
102 PickleIterator iter(message); 107 PickleIterator iter(message);
103 bool success = iter.ReadInt(&browser_plugin_instance_id); 108 bool success = iter.ReadInt(&browser_plugin_instance_id);
104 DCHECK(success); 109 DCHECK(success);
105 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); 110 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id);
106 if (plugin && plugin->OnMessageReceived(message)) 111 if (plugin && plugin->OnMessageReceived(message))
107 return true; 112 return true;
108 113
109 // TODO(fsamuel): This is probably forcing the compositor to continue working 114 // TODO(fsamuel): This is probably forcing the compositor to continue working
110 // even on display:none. We should optimize this. 115 // even on display:none. We should optimize this.
111 if (message.type() == BrowserPluginMsg_CompositorFrameSwapped::ID) { 116 if (message.type() == BrowserPluginMsg_CompositorFrameSwapped::ID) {
112 OnCompositorFrameSwappedPluginUnavailable(message); 117 OnCompositorFrameSwappedPluginUnavailable(message);
113 return true; 118 return true;
114 } 119 }
115 120
116 return false; 121 return false;
117 } 122 }
118 123
119 bool BrowserPluginManager::Send(IPC::Message* msg) { 124 bool BrowserPluginManager::Send(IPC::Message* msg) {
120 return RenderThread::Get()->Send(msg); 125 return RenderThreadImpl::current()->Send(msg);
121 } 126 }
122 127
123 void BrowserPluginManager::OnCompositorFrameSwappedPluginUnavailable( 128 void BrowserPluginManager::OnCompositorFrameSwappedPluginUnavailable(
124 const IPC::Message& message) { 129 const IPC::Message& message) {
125 BrowserPluginMsg_CompositorFrameSwapped::Param param; 130 BrowserPluginMsg_CompositorFrameSwapped::Param param;
126 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param)) 131 if (!BrowserPluginMsg_CompositorFrameSwapped::Read(&message, &param))
127 return; 132 return;
128 133
129 FrameHostMsg_CompositorFrameSwappedACK_Params params; 134 FrameHostMsg_CompositorFrameSwappedACK_Params params;
130 params.producing_host_id = param.b.producing_host_id; 135 params.producing_host_id = param.b.producing_host_id;
131 params.producing_route_id = param.b.producing_route_id; 136 params.producing_route_id = param.b.producing_route_id;
132 params.output_surface_id = param.b.output_surface_id; 137 params.output_surface_id = param.b.output_surface_id;
133 Send(new BrowserPluginHostMsg_CompositorFrameSwappedACK( 138 Send(new BrowserPluginHostMsg_CompositorFrameSwappedACK(
134 routing_id(), param.a, params)); 139 message.routing_id(), param.a, params));
135 } 140 }
136 141
137 } // namespace content 142 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/browser_plugin/browser_plugin_manager.h ('k') | content/renderer/child_frame_compositing_helper.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698