OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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.h" | 5 #include "content/renderer/browser_plugin/browser_plugin.h" |
6 | 6 |
7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 bool BrowserPlugin::GetAllowTransparencyAttribute() const { | 142 bool BrowserPlugin::GetAllowTransparencyAttribute() const { |
143 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); | 143 return HasDOMAttribute(browser_plugin::kAttributeAllowTransparency); |
144 } | 144 } |
145 | 145 |
146 void BrowserPlugin::ParseAllowTransparencyAttribute() { | 146 void BrowserPlugin::ParseAllowTransparencyAttribute() { |
147 if (!ready()) | 147 if (!ready()) |
148 return; | 148 return; |
149 | 149 |
150 bool opaque = !GetAllowTransparencyAttribute(); | 150 bool opaque = !GetAllowTransparencyAttribute(); |
151 | 151 |
152 if (compositing_helper_) | 152 if (compositing_helper_.get()) |
153 compositing_helper_->SetContentsOpaque(opaque); | 153 compositing_helper_->SetContentsOpaque(opaque); |
154 | 154 |
155 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( | 155 browser_plugin_manager()->Send(new BrowserPluginHostMsg_SetContentsOpaque( |
156 render_view_routing_id_, | 156 render_view_routing_id_, |
157 browser_plugin_instance_id_, | 157 browser_plugin_instance_id_, |
158 opaque)); | 158 opaque)); |
159 } | 159 } |
160 | 160 |
161 void BrowserPlugin::Attach() { | 161 void BrowserPlugin::Attach() { |
162 if (ready()) { | 162 if (ready()) { |
163 attached_ = false; | 163 attached_ = false; |
164 guest_crashed_ = false; | 164 guest_crashed_ = false; |
165 EnableCompositing(false); | 165 EnableCompositing(false); |
166 if (compositing_helper_) { | 166 if (compositing_helper_.get()) { |
167 compositing_helper_->OnContainerDestroy(); | 167 compositing_helper_->OnContainerDestroy(); |
168 compositing_helper_ = NULL; | 168 compositing_helper_ = NULL; |
169 } | 169 } |
170 } | 170 } |
171 | 171 |
172 // TODO(fsamuel): Add support for reattachment. | 172 // TODO(fsamuel): Add support for reattachment. |
173 BrowserPluginHostMsg_Attach_Params attach_params; | 173 BrowserPluginHostMsg_Attach_Params attach_params; |
174 attach_params.focused = ShouldGuestBeFocused(); | 174 attach_params.focused = ShouldGuestBeFocused(); |
175 attach_params.visible = visible_; | 175 attach_params.visible = visible_; |
176 attach_params.opaque = !GetAllowTransparencyAttribute(); | 176 attach_params.opaque = !GetAllowTransparencyAttribute(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
226 param.b.producing_route_id, | 226 param.b.producing_route_id, |
227 param.b.output_surface_id, | 227 param.b.output_surface_id, |
228 param.b.producing_host_id, | 228 param.b.producing_host_id, |
229 param.b.shared_memory_handle); | 229 param.b.shared_memory_handle); |
230 } | 230 } |
231 | 231 |
232 void BrowserPlugin::OnCopyFromCompositingSurface(int browser_plugin_instance_id, | 232 void BrowserPlugin::OnCopyFromCompositingSurface(int browser_plugin_instance_id, |
233 int request_id, | 233 int request_id, |
234 gfx::Rect source_rect, | 234 gfx::Rect source_rect, |
235 gfx::Size dest_size) { | 235 gfx::Size dest_size) { |
236 if (!compositing_helper_) { | 236 if (!compositing_helper_.get()) { |
237 browser_plugin_manager()->Send( | 237 browser_plugin_manager()->Send( |
238 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( | 238 new BrowserPluginHostMsg_CopyFromCompositingSurfaceAck( |
239 render_view_routing_id_, | 239 render_view_routing_id_, |
240 browser_plugin_instance_id_, | 240 browser_plugin_instance_id_, |
241 request_id, | 241 request_id, |
242 SkBitmap())); | 242 SkBitmap())); |
243 return; | 243 return; |
244 } | 244 } |
245 compositing_helper_->CopyFromCompositingSurface(request_id, source_rect, | 245 compositing_helper_->CopyFromCompositingSurface(request_id, source_rect, |
246 dest_size); | 246 dest_size); |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
398 // available in render tree. | 398 // available in render tree. |
399 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); | 399 browser_plugin_instance_id_ = browser_plugin_manager()->GetNextInstanceID(); |
400 UpdateDOMAttribute("internalinstanceid", | 400 UpdateDOMAttribute("internalinstanceid", |
401 base::IntToString(browser_plugin_instance_id_)); | 401 base::IntToString(browser_plugin_instance_id_)); |
402 | 402 |
403 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); | 403 browser_plugin_manager()->AddBrowserPlugin(browser_plugin_instance_id_, this); |
404 return true; | 404 return true; |
405 } | 405 } |
406 | 406 |
407 void BrowserPlugin::EnableCompositing(bool enable) { | 407 void BrowserPlugin::EnableCompositing(bool enable) { |
408 bool enabled = !!compositing_helper_; | 408 bool enabled = !!compositing_helper_.get(); |
409 if (enabled == enable) | 409 if (enabled == enable) |
410 return; | 410 return; |
411 | 411 |
412 if (enable) { | 412 if (enable) { |
413 DCHECK(!compositing_helper_.get()); | 413 DCHECK(!compositing_helper_.get()); |
414 if (!compositing_helper_.get()) { | 414 if (!compositing_helper_.get()) { |
415 compositing_helper_ = ChildFrameCompositingHelper::CreateForBrowserPlugin( | 415 compositing_helper_ = ChildFrameCompositingHelper::CreateForBrowserPlugin( |
416 weak_ptr_factory_.GetWeakPtr()); | 416 weak_ptr_factory_.GetWeakPtr()); |
417 } | 417 } |
418 } | 418 } |
(...skipping 390 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
809 const blink::WebMouseEvent& event) { | 809 const blink::WebMouseEvent& event) { |
810 browser_plugin_manager()->Send( | 810 browser_plugin_manager()->Send( |
811 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 811 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
812 browser_plugin_instance_id_, | 812 browser_plugin_instance_id_, |
813 plugin_rect_, | 813 plugin_rect_, |
814 &event)); | 814 &event)); |
815 return true; | 815 return true; |
816 } | 816 } |
817 | 817 |
818 } // namespace content | 818 } // namespace content |
OLD | NEW |