| OLD | NEW |
| 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/browser/browser_plugin/browser_plugin_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
| 10 #include "base/pickle.h" | 10 #include "base/pickle.h" |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 static_cast<WebContentsImpl*>(delegate_->CreateNewGuestWindow(params)); | 229 static_cast<WebContentsImpl*>(delegate_->CreateNewGuestWindow(params)); |
| 230 DCHECK(new_contents); | 230 DCHECK(new_contents); |
| 231 return new_contents; | 231 return new_contents; |
| 232 } | 232 } |
| 233 | 233 |
| 234 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( | 234 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( |
| 235 const IPC::Message& message) { | 235 const IPC::Message& message) { |
| 236 RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>( | 236 RenderWidgetHostViewGuest* rwhv = static_cast<RenderWidgetHostViewGuest*>( |
| 237 web_contents()->GetRenderWidgetHostView()); | 237 web_contents()->GetRenderWidgetHostView()); |
| 238 // Until the guest is attached, it should not be handling input events. | 238 // Until the guest is attached, it should not be handling input events. |
| 239 if (attached() && rwhv && rwhv->OnMessageReceivedFromEmbedder( | 239 if (attached() && rwhv && |
| 240 rwhv->OnMessageReceivedFromEmbedder( |
| 240 message, | 241 message, |
| 241 static_cast<RenderViewHostImpl*>( | 242 RenderWidgetHostImpl::From( |
| 242 embedder_web_contents()->GetRenderViewHost()))) { | 243 embedder_web_contents()->GetRenderViewHost()->GetWidget()))) { |
| 243 return true; | 244 return true; |
| 244 } | 245 } |
| 245 | 246 |
| 246 bool handled = true; | 247 bool handled = true; |
| 247 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 248 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
| 248 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, | 249 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, |
| 249 OnCompositorFrameSwappedACK) | 250 OnCompositorFrameSwappedACK) |
| 250 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Detach, OnDetach) | 251 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_Detach, OnDetach) |
| 251 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, | 252 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, |
| 252 OnDragStatusUpdate) | 253 OnDragStatusUpdate) |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 325 // navigations still continue to function inside the app. | 326 // navigations still continue to function inside the app. |
| 326 renderer_prefs->browser_handles_all_top_level_requests = false; | 327 renderer_prefs->browser_handles_all_top_level_requests = false; |
| 327 // Disable "client blocked" error page for browser plugin. | 328 // Disable "client blocked" error page for browser plugin. |
| 328 renderer_prefs->disable_client_blocked_error_page = true; | 329 renderer_prefs->disable_client_blocked_error_page = true; |
| 329 | 330 |
| 330 embedder_visibility_observer_.reset(new EmbedderVisibilityObserver(this)); | 331 embedder_visibility_observer_.reset(new EmbedderVisibilityObserver(this)); |
| 331 | 332 |
| 332 DCHECK(GetWebContents()->GetRenderViewHost()); | 333 DCHECK(GetWebContents()->GetRenderViewHost()); |
| 333 | 334 |
| 334 // Initialize the device scale factor by calling |NotifyScreenInfoChanged|. | 335 // Initialize the device scale factor by calling |NotifyScreenInfoChanged|. |
| 335 auto render_widget_host = | 336 auto render_widget_host = RenderWidgetHostImpl::From( |
| 336 RenderWidgetHostImpl::From(GetWebContents()->GetRenderViewHost()); | 337 GetWebContents()->GetRenderViewHost()->GetWidget()); |
| 337 render_widget_host->NotifyScreenInfoChanged(); | 338 render_widget_host->NotifyScreenInfoChanged(); |
| 338 | 339 |
| 339 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will | 340 // TODO(chrishtr): this code is wrong. The navigate_on_drag_drop field will |
| 340 // be reset again the next time preferences are updated. | 341 // be reset again the next time preferences are updated. |
| 341 WebPreferences prefs = | 342 WebPreferences prefs = |
| 342 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); | 343 GetWebContents()->GetRenderViewHost()->GetWebkitPreferences(); |
| 343 prefs.navigate_on_drag_drop = false; | 344 prefs.navigate_on_drag_drop = false; |
| 344 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); | 345 GetWebContents()->GetRenderViewHost()->UpdateWebkitPreferences(prefs); |
| 345 } | 346 } |
| 346 | 347 |
| (...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 941 if (mouse_locked_) | 942 if (mouse_locked_) |
| 942 Send(new ViewMsg_MouseLockLost(routing_id())); | 943 Send(new ViewMsg_MouseLockLost(routing_id())); |
| 943 mouse_locked_ = false; | 944 mouse_locked_ = false; |
| 944 } | 945 } |
| 945 | 946 |
| 946 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, | 947 void BrowserPluginGuest::OnUpdateGeometry(int browser_plugin_instance_id, |
| 947 const gfx::Rect& view_rect) { | 948 const gfx::Rect& view_rect) { |
| 948 // The plugin has moved within the embedder without resizing or the | 949 // The plugin has moved within the embedder without resizing or the |
| 949 // embedder/container's view rect changing. | 950 // embedder/container's view rect changing. |
| 950 guest_window_rect_ = view_rect; | 951 guest_window_rect_ = view_rect; |
| 951 RenderViewHostImpl* rvh = static_cast<RenderViewHostImpl*>( | 952 RenderWidgetHostImpl* rwh = RenderWidgetHostImpl::From( |
| 952 GetWebContents()->GetRenderViewHost()); | 953 GetWebContents()->GetRenderViewHost()->GetWidget()); |
| 953 if (rvh) | 954 if (rwh) |
| 954 rvh->SendScreenRects(); | 955 rwh->SendScreenRects(); |
| 955 } | 956 } |
| 956 | 957 |
| 957 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { | 958 void BrowserPluginGuest::OnHasTouchEventHandlers(bool accept) { |
| 958 SendMessageToEmbedder( | 959 SendMessageToEmbedder( |
| 959 new BrowserPluginMsg_ShouldAcceptTouchEvents( | 960 new BrowserPluginMsg_ShouldAcceptTouchEvents( |
| 960 browser_plugin_instance_id(), accept)); | 961 browser_plugin_instance_id(), accept)); |
| 961 } | 962 } |
| 962 | 963 |
| 963 #if defined(OS_MACOSX) | 964 #if defined(OS_MACOSX) |
| 964 void BrowserPluginGuest::OnShowPopup( | 965 void BrowserPluginGuest::OnShowPopup( |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1012 range, character_bounds); | 1013 range, character_bounds); |
| 1013 } | 1014 } |
| 1014 #endif | 1015 #endif |
| 1015 | 1016 |
| 1016 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { | 1017 void BrowserPluginGuest::SetContextMenuPosition(const gfx::Point& position) { |
| 1017 if (delegate_) | 1018 if (delegate_) |
| 1018 delegate_->SetContextMenuPosition(position); | 1019 delegate_->SetContextMenuPosition(position); |
| 1019 } | 1020 } |
| 1020 | 1021 |
| 1021 } // namespace content | 1022 } // namespace content |
| OLD | NEW |