| 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 <stddef.h> | 7 #include <stddef.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 | 176 |
| 177 BrowserPluginManager::Get()->Send( | 177 BrowserPluginManager::Get()->Send( |
| 178 new BrowserPluginHostMsg_Detach(browser_plugin_instance_id_)); | 178 new BrowserPluginHostMsg_Detach(browser_plugin_instance_id_)); |
| 179 } | 179 } |
| 180 | 180 |
| 181 void BrowserPlugin::DidCommitCompositorFrame() { | 181 void BrowserPlugin::DidCommitCompositorFrame() { |
| 182 } | 182 } |
| 183 | 183 |
| 184 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, | 184 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, |
| 185 bool reverse) { | 185 bool reverse) { |
| 186 auto render_frame = RenderFrameImpl::FromRoutingID(render_frame_routing_id()); | 186 auto* render_frame = |
| 187 auto render_view = render_frame ? render_frame->GetRenderView() : nullptr; | 187 RenderFrameImpl::FromRoutingID(render_frame_routing_id()); |
| 188 auto* render_view = render_frame ? render_frame->GetRenderView() : nullptr; |
| 188 if (!render_view) | 189 if (!render_view) |
| 189 return; | 190 return; |
| 190 render_view->GetWebView()->advanceFocus(reverse); | 191 render_view->GetWebView()->advanceFocus(reverse); |
| 191 } | 192 } |
| 192 | 193 |
| 193 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { | 194 void BrowserPlugin::OnGuestGone(int browser_plugin_instance_id) { |
| 194 guest_crashed_ = true; | 195 guest_crashed_ = true; |
| 195 | 196 |
| 196 EnableCompositing(true); | 197 EnableCompositing(true); |
| 197 compositing_helper_->ChildFrameGone(); | 198 compositing_helper_->ChildFrameGone(); |
| 198 } | 199 } |
| 199 | 200 |
| 200 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id, | 201 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id, |
| 201 const WebCursor& cursor) { | 202 const WebCursor& cursor) { |
| 202 cursor_ = cursor; | 203 cursor_ = cursor; |
| 203 } | 204 } |
| 204 | 205 |
| 205 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id, | 206 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id, |
| 206 bool enable) { | 207 bool enable) { |
| 207 auto render_frame = RenderFrameImpl::FromRoutingID(render_frame_routing_id()); | 208 auto* render_frame = |
| 208 auto render_view = static_cast<RenderViewImpl*>( | 209 RenderFrameImpl::FromRoutingID(render_frame_routing_id()); |
| 210 auto* render_view = static_cast<RenderViewImpl*>( |
| 209 render_frame ? render_frame->GetRenderView() : nullptr); | 211 render_frame ? render_frame->GetRenderView() : nullptr); |
| 210 if (enable) { | 212 if (enable) { |
| 211 if (mouse_locked_ || !render_view) | 213 if (mouse_locked_ || !render_view) |
| 212 return; | 214 return; |
| 213 render_view->mouse_lock_dispatcher()->LockMouse(this); | 215 render_view->mouse_lock_dispatcher()->LockMouse(this); |
| 214 } else { | 216 } else { |
| 215 if (!mouse_locked_) { | 217 if (!mouse_locked_) { |
| 216 OnLockMouseACK(false); | 218 OnLockMouseACK(false); |
| 217 return; | 219 return; |
| 218 } | 220 } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 return; | 254 return; |
| 253 bool should_be_focused = ShouldGuestBeFocused(); | 255 bool should_be_focused = ShouldGuestBeFocused(); |
| 254 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( | 256 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( |
| 255 browser_plugin_instance_id_, | 257 browser_plugin_instance_id_, |
| 256 should_be_focused, | 258 should_be_focused, |
| 257 focus_type)); | 259 focus_type)); |
| 258 } | 260 } |
| 259 | 261 |
| 260 bool BrowserPlugin::ShouldGuestBeFocused() const { | 262 bool BrowserPlugin::ShouldGuestBeFocused() const { |
| 261 bool embedder_focused = false; | 263 bool embedder_focused = false; |
| 262 auto render_frame = RenderFrameImpl::FromRoutingID(render_frame_routing_id()); | 264 auto* render_frame = |
| 263 auto render_view = static_cast<RenderViewImpl*>( | 265 RenderFrameImpl::FromRoutingID(render_frame_routing_id()); |
| 266 auto* render_view = static_cast<RenderViewImpl*>( |
| 264 render_frame ? render_frame->GetRenderView() : nullptr); | 267 render_frame ? render_frame->GetRenderView() : nullptr); |
| 265 if (render_view) | 268 if (render_view) |
| 266 embedder_focused = render_view->has_focus(); | 269 embedder_focused = render_view->has_focus(); |
| 267 return plugin_focused_ && embedder_focused; | 270 return plugin_focused_ && embedder_focused; |
| 268 } | 271 } |
| 269 | 272 |
| 270 WebPluginContainer* BrowserPlugin::container() const { | 273 WebPluginContainer* BrowserPlugin::container() const { |
| 271 return container_; | 274 return container_; |
| 272 } | 275 } |
| 273 | 276 |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 | 316 |
| 314 void BrowserPlugin::destroy() { | 317 void BrowserPlugin::destroy() { |
| 315 if (container_) { | 318 if (container_) { |
| 316 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 319 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
| 317 // call returns, so let's not keep a reference to it around. | 320 // call returns, so let's not keep a reference to it around. |
| 318 g_plugin_container_map.Get().erase(container_); | 321 g_plugin_container_map.Get().erase(container_); |
| 319 } | 322 } |
| 320 | 323 |
| 321 container_ = nullptr; | 324 container_ = nullptr; |
| 322 // Will be a no-op if the mouse is not currently locked. | 325 // Will be a no-op if the mouse is not currently locked. |
| 323 auto render_frame = RenderFrameImpl::FromRoutingID(render_frame_routing_id()); | 326 auto* render_frame = |
| 324 auto render_view = static_cast<RenderViewImpl*>( | 327 RenderFrameImpl::FromRoutingID(render_frame_routing_id()); |
| 328 auto* render_view = static_cast<RenderViewImpl*>( |
| 325 render_frame ? render_frame->GetRenderView() : nullptr); | 329 render_frame ? render_frame->GetRenderView() : nullptr); |
| 326 if (render_view) | 330 if (render_view) |
| 327 render_view->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); | 331 render_view->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); |
| 328 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); | 332 base::ThreadTaskRunnerHandle::Get()->DeleteSoon(FROM_HERE, this); |
| 329 } | 333 } |
| 330 | 334 |
| 331 v8::Local<v8::Object> BrowserPlugin::v8ScriptableObject(v8::Isolate* isolate) { | 335 v8::Local<v8::Object> BrowserPlugin::v8ScriptableObject(v8::Isolate* isolate) { |
| 332 if (!delegate_) | 336 if (!delegate_) |
| 333 return v8::Local<v8::Object>(); | 337 return v8::Local<v8::Object>(); |
| 334 | 338 |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 | 579 |
| 576 bool BrowserPlugin::HandleMouseLockedInputEvent( | 580 bool BrowserPlugin::HandleMouseLockedInputEvent( |
| 577 const blink::WebMouseEvent& event) { | 581 const blink::WebMouseEvent& event) { |
| 578 BrowserPluginManager::Get()->Send( | 582 BrowserPluginManager::Get()->Send( |
| 579 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_, | 583 new BrowserPluginHostMsg_HandleInputEvent(browser_plugin_instance_id_, |
| 580 &event)); | 584 &event)); |
| 581 return true; | 585 return true; |
| 582 } | 586 } |
| 583 | 587 |
| 584 } // namespace content | 588 } // namespace content |
| OLD | NEW |