| 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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 161 render_view_routing_id_, browser_plugin_instance_id_)); | 161 render_view_routing_id_, browser_plugin_instance_id_)); |
| 162 } | 162 } |
| 163 | 163 |
| 164 void BrowserPlugin::DidCommitCompositorFrame() { | 164 void BrowserPlugin::DidCommitCompositorFrame() { |
| 165 if (compositing_helper_.get()) | 165 if (compositing_helper_.get()) |
| 166 compositing_helper_->DidCommitCompositorFrame(); | 166 compositing_helper_->DidCommitCompositorFrame(); |
| 167 } | 167 } |
| 168 | 168 |
| 169 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, | 169 void BrowserPlugin::OnAdvanceFocus(int browser_plugin_instance_id, |
| 170 bool reverse) { | 170 bool reverse) { |
| 171 RenderViewImpl* render_view = | 171 auto render_view = RenderViewImpl::FromRoutingID(render_view_routing_id()); |
| 172 RenderViewImpl::FromRoutingID(render_view_routing_id()); | |
| 173 if (!render_view) | 172 if (!render_view) |
| 174 return; | 173 return; |
| 175 render_view->GetWebView()->advanceFocus(reverse); | 174 render_view->GetWebView()->advanceFocus(reverse); |
| 176 } | 175 } |
| 177 | 176 |
| 178 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { | 177 void BrowserPlugin::OnCompositorFrameSwapped(const IPC::Message& message) { |
| 179 if (!attached()) | 178 if (!attached()) |
| 180 return; | 179 return; |
| 181 | 180 |
| 182 BrowserPluginMsg_CompositorFrameSwapped::Param param; | 181 BrowserPluginMsg_CompositorFrameSwapped::Param param; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 224 compositing_helper_->SetContentsOpaque(opaque); | 223 compositing_helper_->SetContentsOpaque(opaque); |
| 225 } | 224 } |
| 226 | 225 |
| 227 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id, | 226 void BrowserPlugin::OnSetCursor(int browser_plugin_instance_id, |
| 228 const WebCursor& cursor) { | 227 const WebCursor& cursor) { |
| 229 cursor_ = cursor; | 228 cursor_ = cursor; |
| 230 } | 229 } |
| 231 | 230 |
| 232 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id, | 231 void BrowserPlugin::OnSetMouseLock(int browser_plugin_instance_id, |
| 233 bool enable) { | 232 bool enable) { |
| 234 RenderViewImpl* render_view = | 233 auto render_view = RenderViewImpl::FromRoutingID(render_view_routing_id()); |
| 235 RenderViewImpl::FromRoutingID(render_view_routing_id()); | |
| 236 if (enable) { | 234 if (enable) { |
| 237 if (mouse_locked_ || !render_view) | 235 if (mouse_locked_ || !render_view) |
| 238 return; | 236 return; |
| 239 render_view->mouse_lock_dispatcher()->LockMouse(this); | 237 render_view->mouse_lock_dispatcher()->LockMouse(this); |
| 240 } else { | 238 } else { |
| 241 if (!mouse_locked_) { | 239 if (!mouse_locked_) { |
| 242 OnLockMouseACK(false); | 240 OnLockMouseACK(false); |
| 243 return; | 241 return; |
| 244 } | 242 } |
| 245 if (!render_view) | 243 if (!render_view) |
| (...skipping 18 matching lines...) Expand all Loading... |
| 264 } | 262 } |
| 265 | 263 |
| 266 void BrowserPlugin::ShowSadGraphic() { | 264 void BrowserPlugin::ShowSadGraphic() { |
| 267 // If the BrowserPlugin is scheduled to be deleted, then container_ will be | 265 // If the BrowserPlugin is scheduled to be deleted, then container_ will be |
| 268 // NULL so we shouldn't attempt to access it. | 266 // NULL so we shouldn't attempt to access it. |
| 269 if (container_) | 267 if (container_) |
| 270 container_->invalidate(); | 268 container_->invalidate(); |
| 271 } | 269 } |
| 272 | 270 |
| 273 float BrowserPlugin::GetDeviceScaleFactor() const { | 271 float BrowserPlugin::GetDeviceScaleFactor() const { |
| 274 RenderViewImpl* render_view = | 272 auto render_view = RenderViewImpl::FromRoutingID(render_view_routing_id()); |
| 275 RenderViewImpl::FromRoutingID(render_view_routing_id()); | |
| 276 if (!render_view) | 273 if (!render_view) |
| 277 return 1.0f; | 274 return 1.0f; |
| 278 return render_view->GetWebView()->deviceScaleFactor(); | 275 return render_view->GetWebView()->deviceScaleFactor(); |
| 279 } | 276 } |
| 280 | 277 |
| 281 void BrowserPlugin::UpdateDeviceScaleFactor() { | 278 void BrowserPlugin::UpdateDeviceScaleFactor() { |
| 282 if (last_device_scale_factor_ == GetDeviceScaleFactor()) | 279 if (last_device_scale_factor_ == GetDeviceScaleFactor()) |
| 283 return; | 280 return; |
| 284 | 281 |
| 285 BrowserPluginHostMsg_ResizeGuest_Params params; | 282 BrowserPluginHostMsg_ResizeGuest_Params params; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 296 bool should_be_focused = ShouldGuestBeFocused(); | 293 bool should_be_focused = ShouldGuestBeFocused(); |
| 297 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( | 294 BrowserPluginManager::Get()->Send(new BrowserPluginHostMsg_SetFocus( |
| 298 render_view_routing_id_, | 295 render_view_routing_id_, |
| 299 browser_plugin_instance_id_, | 296 browser_plugin_instance_id_, |
| 300 should_be_focused, | 297 should_be_focused, |
| 301 focus_type)); | 298 focus_type)); |
| 302 } | 299 } |
| 303 | 300 |
| 304 bool BrowserPlugin::ShouldGuestBeFocused() const { | 301 bool BrowserPlugin::ShouldGuestBeFocused() const { |
| 305 bool embedder_focused = false; | 302 bool embedder_focused = false; |
| 306 RenderViewImpl* render_view = | 303 auto render_view = RenderViewImpl::FromRoutingID(render_view_routing_id()); |
| 307 RenderViewImpl::FromRoutingID(render_view_routing_id()); | |
| 308 if (render_view) | 304 if (render_view) |
| 309 embedder_focused = render_view->has_focus(); | 305 embedder_focused = render_view->has_focus(); |
| 310 return plugin_focused_ && embedder_focused; | 306 return plugin_focused_ && embedder_focused; |
| 311 } | 307 } |
| 312 | 308 |
| 313 WebPluginContainer* BrowserPlugin::container() const { | 309 WebPluginContainer* BrowserPlugin::container() const { |
| 314 return container_; | 310 return container_; |
| 315 } | 311 } |
| 316 | 312 |
| 317 bool BrowserPlugin::initialize(WebPluginContainer* container) { | 313 bool BrowserPlugin::initialize(WebPluginContainer* container) { |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 | 357 |
| 362 void BrowserPlugin::destroy() { | 358 void BrowserPlugin::destroy() { |
| 363 if (container_) { | 359 if (container_) { |
| 364 // The BrowserPlugin's WebPluginContainer is deleted immediately after this | 360 // The BrowserPlugin's WebPluginContainer is deleted immediately after this |
| 365 // call returns, so let's not keep a reference to it around. | 361 // call returns, so let's not keep a reference to it around. |
| 366 g_plugin_container_map.Get().erase(container_); | 362 g_plugin_container_map.Get().erase(container_); |
| 367 } | 363 } |
| 368 | 364 |
| 369 container_ = NULL; | 365 container_ = NULL; |
| 370 // Will be a no-op if the mouse is not currently locked. | 366 // Will be a no-op if the mouse is not currently locked. |
| 371 RenderViewImpl* render_view = | 367 auto render_view = RenderViewImpl::FromRoutingID(render_view_routing_id()); |
| 372 RenderViewImpl::FromRoutingID(render_view_routing_id()); | |
| 373 if (render_view) | 368 if (render_view) |
| 374 render_view->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); | 369 render_view->mouse_lock_dispatcher()->OnLockTargetDestroyed(this); |
| 375 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); | 370 base::MessageLoop::current()->DeleteSoon(FROM_HERE, this); |
| 376 } | 371 } |
| 377 | 372 |
| 378 v8::Local<v8::Object> BrowserPlugin::v8ScriptableObject(v8::Isolate* isolate) { | 373 v8::Local<v8::Object> BrowserPlugin::v8ScriptableObject(v8::Isolate* isolate) { |
| 379 return delegate_->V8ScriptableObject(isolate); | 374 return delegate_->V8ScriptableObject(isolate); |
| 380 } | 375 } |
| 381 | 376 |
| 382 bool BrowserPlugin::supportsKeyboardFocus() const { | 377 bool BrowserPlugin::supportsKeyboardFocus() const { |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 667 const blink::WebMouseEvent& event) { | 662 const blink::WebMouseEvent& event) { |
| 668 BrowserPluginManager::Get()->Send( | 663 BrowserPluginManager::Get()->Send( |
| 669 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, | 664 new BrowserPluginHostMsg_HandleInputEvent(render_view_routing_id_, |
| 670 browser_plugin_instance_id_, | 665 browser_plugin_instance_id_, |
| 671 plugin_rect_, | 666 plugin_rect_, |
| 672 &event)); | 667 &event)); |
| 673 return true; | 668 return true; |
| 674 } | 669 } |
| 675 | 670 |
| 676 } // namespace content | 671 } // namespace content |
| OLD | NEW |