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

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: Added AppShell Test 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 return RenderThreadImpl::current()->browser_plugin_manager();
21 return new BrowserPluginManager(render_view);
22 } 21 }
23 22
24 BrowserPluginManager::BrowserPluginManager(RenderViewImpl* render_view) 23 BrowserPluginManager::BrowserPluginManager() {
25 : RenderViewObserver(render_view),
26 render_view_(render_view->AsWeakPtr()) {
27 } 24 }
28 25
29 BrowserPluginManager::~BrowserPluginManager() { 26 BrowserPluginManager::~BrowserPluginManager() {
30 } 27 }
31 28
32 void BrowserPluginManager::AddBrowserPlugin( 29 void BrowserPluginManager::AddBrowserPlugin(
33 int browser_plugin_instance_id, 30 int browser_plugin_instance_id,
34 BrowserPlugin* browser_plugin) { 31 BrowserPlugin* browser_plugin) {
35 instances_.AddWithID(browser_plugin, browser_plugin_instance_id); 32 instances_.AddWithID(browser_plugin, browser_plugin_instance_id);
36 } 33 }
37 34
38 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) { 35 void BrowserPluginManager::RemoveBrowserPlugin(int browser_plugin_instance_id) {
39 instances_.Remove(browser_plugin_instance_id); 36 instances_.Remove(browser_plugin_instance_id);
40 } 37 }
41 38
42 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin( 39 BrowserPlugin* BrowserPluginManager::GetBrowserPlugin(
43 int browser_plugin_instance_id) const { 40 int browser_plugin_instance_id) const {
44 return instances_.Lookup(browser_plugin_instance_id); 41 return instances_.Lookup(browser_plugin_instance_id);
45 } 42 }
46 43
47 int BrowserPluginManager::GetNextInstanceID() { 44 int BrowserPluginManager::GetNextInstanceID() {
48 return RenderThread::Get()->GenerateRoutingID(); 45 return RenderThreadImpl::current()->GenerateRoutingID();
49 } 46 }
50 47
51 void BrowserPluginManager::UpdateDeviceScaleFactor() { 48 void BrowserPluginManager::UpdateDeviceScaleFactor() {
52 IDMap<BrowserPlugin>::iterator iter(&instances_); 49 IDMap<BrowserPlugin>::iterator iter(&instances_);
53 while (!iter.IsAtEnd()) { 50 while (!iter.IsAtEnd()) {
54 iter.GetCurrentValue()->UpdateDeviceScaleFactor(); 51 iter.GetCurrentValue()->UpdateDeviceScaleFactor();
55 iter.Advance(); 52 iter.Advance();
56 } 53 }
57 } 54 }
58 55
(...skipping 11 matching lines...) Expand all
70 plugin->Attach(); 67 plugin->Attach();
71 } 68 }
72 69
73 void BrowserPluginManager::Detach(int browser_plugin_instance_id) { 70 void BrowserPluginManager::Detach(int browser_plugin_instance_id) {
74 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id); 71 BrowserPlugin* plugin = GetBrowserPlugin(browser_plugin_instance_id);
75 if (plugin) 72 if (plugin)
76 plugin->Detach(); 73 plugin->Detach();
77 } 74 }
78 75
79 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin( 76 BrowserPlugin* BrowserPluginManager::CreateBrowserPlugin(
80 RenderViewImpl* render_view, 77 RenderFrame* render_frame,
81 blink::WebFrame* frame,
82 scoped_ptr<BrowserPluginDelegate> delegate) { 78 scoped_ptr<BrowserPluginDelegate> delegate) {
83 return new BrowserPlugin(render_view, frame, delegate.Pass()); 79 return new BrowserPlugin(render_frame, delegate.Pass());
84 } 80 }
85 81
86 void BrowserPluginManager::DidCommitCompositorFrame() { 82 void BrowserPluginManager::DidCommitCompositorFrame(
83 int render_view_routing_id) {
87 IDMap<BrowserPlugin>::iterator iter(&instances_); 84 IDMap<BrowserPlugin>::iterator iter(&instances_);
88 while (!iter.IsAtEnd()) { 85 while (!iter.IsAtEnd()) {
86 if (iter.GetCurrentValue()->render_view_routing_id() !=
87 render_view_routing_id) {
88 iter.Advance();
lazyboy 2014/12/18 16:50:27 Looking at this now, it could simply be while(..)
89 continue;
90 }
89 iter.GetCurrentValue()->DidCommitCompositorFrame(); 91 iter.GetCurrentValue()->DidCommitCompositorFrame();
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