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.h" | 9 #include "base/message_loop.h" |
10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
(...skipping 304 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
315 break; | 315 break; |
316 } | 316 } |
317 } | 317 } |
318 | 318 |
319 void BrowserPluginGuest::AddNewContents(WebContents* source, | 319 void BrowserPluginGuest::AddNewContents(WebContents* source, |
320 WebContents* new_contents, | 320 WebContents* new_contents, |
321 WindowOpenDisposition disposition, | 321 WindowOpenDisposition disposition, |
322 const gfx::Rect& initial_pos, | 322 const gfx::Rect& initial_pos, |
323 bool user_gesture, | 323 bool user_gesture, |
324 bool* was_blocked) { | 324 bool* was_blocked) { |
325 *was_blocked = false; | 325 if (was_blocked) |
Charlie Reis
2013/04/04 21:48:46
Any reason, or just to be clean?
Fady Samuel
2013/04/04 22:35:15
Yes, this gets called from WebContentsImpl::ShowCr
| |
326 *was_blocked = false; | |
326 RequestNewWindowPermission(static_cast<WebContentsImpl*>(new_contents), | 327 RequestNewWindowPermission(static_cast<WebContentsImpl*>(new_contents), |
327 disposition, initial_pos, user_gesture); | 328 disposition, initial_pos, user_gesture); |
328 } | 329 } |
329 | 330 |
330 void BrowserPluginGuest::CanDownload( | 331 void BrowserPluginGuest::CanDownload( |
331 RenderViewHost* render_view_host, | 332 RenderViewHost* render_view_host, |
332 int request_id, | 333 int request_id, |
333 const std::string& request_method, | 334 const std::string& request_method, |
334 const base::Callback<void(bool)>& callback) { | 335 const base::Callback<void(bool)>& callback) { |
335 if (download_request_callback_map_.size() >= | 336 if (download_request_callback_map_.size() >= |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
691 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, | 692 IPC_MESSAGE_HANDLER(ViewHostMsg_HasTouchEventHandlers, |
692 OnHasTouchEventHandlers) | 693 OnHasTouchEventHandlers) |
693 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) | 694 IPC_MESSAGE_HANDLER(ViewHostMsg_LockMouse, OnLockMouse) |
694 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) | 695 IPC_MESSAGE_HANDLER(ViewHostMsg_SetCursor, OnSetCursor) |
695 #if defined(OS_MACOSX) | 696 #if defined(OS_MACOSX) |
696 // MacOSX creates and populates platform-specific select drop-down menus | 697 // MacOSX creates and populates platform-specific select drop-down menus |
697 // whereas other platforms merely create a popup window that the guest | 698 // whereas other platforms merely create a popup window that the guest |
698 // renderer process paints inside. | 699 // renderer process paints inside. |
699 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) | 700 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowPopup, OnShowPopup) |
700 #endif | 701 #endif |
701 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowView, OnShowView) | |
702 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) | 702 IPC_MESSAGE_HANDLER(ViewHostMsg_ShowWidget, OnShowWidget) |
703 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) | 703 IPC_MESSAGE_HANDLER(ViewHostMsg_TakeFocus, OnTakeFocus) |
704 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) | 704 IPC_MESSAGE_HANDLER(ViewHostMsg_UnlockMouse, OnUnlockMouse) |
705 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) | 705 IPC_MESSAGE_HANDLER(DragHostMsg_UpdateDragCursor, OnUpdateDragCursor) |
706 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) | 706 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateFrameName, OnUpdateFrameName) |
707 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) | 707 IPC_MESSAGE_HANDLER(ViewHostMsg_UpdateRect, OnUpdateRect) |
708 IPC_MESSAGE_UNHANDLED(handled = false) | 708 IPC_MESSAGE_UNHANDLED(handled = false) |
709 IPC_END_MESSAGE_MAP() | 709 IPC_END_MESSAGE_MAP() |
710 return handled; | 710 return handled; |
711 } | 711 } |
712 | 712 |
713 void BrowserPluginGuest::Attach( | 713 void BrowserPluginGuest::Attach( |
714 WebContentsImpl* embedder_web_contents, | 714 WebContentsImpl* embedder_web_contents, |
715 BrowserPluginHostMsg_CreateGuest_Params params) { | 715 BrowserPluginHostMsg_CreateGuest_Params params) { |
716 const std::string target_url = opener()->pending_new_windows_[this]; | 716 const std::string target_url = opener()->pending_new_windows_[this]; |
717 if (!GetWebContents()->opener()) { | 717 if (!GetWebContents()->opener()) { |
718 // For guests that have a suppressed opener, we navigate now. | 718 // For guests that have a suppressed opener, we navigate now. |
719 // Navigation triggers the creation of a RenderWidgetHostViewGuest so | 719 // Navigation triggers the creation of a RenderWidgetHostViewGuest so |
720 // we don't need to create one manually. | 720 // we don't need to create one manually. |
721 params.src = target_url; | 721 params.src = target_url; |
722 } else { | 722 } else { |
723 // Ensure that the newly attached guest gets a RenderWidgetHostViewGuest. | 723 // Ensure that the newly attached guest gets a RenderWidgetHostViewGuest. |
724 WebContentsViewGuest* new_view = | 724 WebContentsViewGuest* new_view = |
725 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 725 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
726 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); | 726 new_view->CreateViewForWidget(web_contents()->GetRenderViewHost()); |
727 | |
728 // Reply to ViewHostMsg_ShowView to inform the renderer that the browser has | |
729 // processed the move. The browser may have ignored the move, but it | |
730 // finished processing. This is used because the renderer keeps a temporary | |
731 // cache of the widget position while these asynchronous operations are in | |
732 // progress. | |
733 Send(new ViewMsg_Move_ACK(web_contents()->GetRoutingID())); | |
734 } | 727 } |
735 // Once a new guest is attached to the DOM of the embedder page, then the | 728 // Once a new guest is attached to the DOM of the embedder page, then the |
736 // lifetime of the new guest is no longer managed by the opener guest. | 729 // lifetime of the new guest is no longer managed by the opener guest. |
737 opener()->pending_new_windows_.erase(this); | 730 opener()->pending_new_windows_.erase(this); |
738 | 731 |
739 // The guest's frame name takes precedence over the BrowserPlugin's name. | 732 // The guest's frame name takes precedence over the BrowserPlugin's name. |
740 // The guest's frame name is assigned in | 733 // The guest's frame name is assigned in |
741 // BrowserPluginGuest::WebContentsCreated. | 734 // BrowserPluginGuest::WebContentsCreated. |
742 if (!name_.empty()) | 735 if (!name_.empty()) |
743 params.name.clear(); | 736 params.name.clear(); |
(...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1077 popup_menu_helper.ShowPopupMenu(translated_bounds, | 1070 popup_menu_helper.ShowPopupMenu(translated_bounds, |
1078 params.item_height, | 1071 params.item_height, |
1079 params.item_font_size, | 1072 params.item_font_size, |
1080 params.selected_item, | 1073 params.selected_item, |
1081 params.popup_items, | 1074 params.popup_items, |
1082 params.right_aligned, | 1075 params.right_aligned, |
1083 params.allow_multiple_selection); | 1076 params.allow_multiple_selection); |
1084 } | 1077 } |
1085 #endif | 1078 #endif |
1086 | 1079 |
1087 void BrowserPluginGuest::OnShowView(int route_id, | |
1088 WindowOpenDisposition disposition, | |
1089 const gfx::Rect& initial_bounds, | |
1090 bool user_gesture) { | |
1091 RenderViewHostImpl* rvh = RenderViewHostImpl::FromID( | |
1092 web_contents()->GetRenderProcessHost()->GetID(), route_id); | |
1093 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( | |
1094 WebContents::FromRenderViewHost(rvh)); | |
1095 RequestNewWindowPermission( | |
Charlie Reis
2013/04/04 21:48:46
How does this work now?
Fady Samuel
2013/04/04 22:35:15
BrowserPluginGuest::AddNewContents handles both ca
| |
1096 web_contents, disposition, initial_bounds, user_gesture); | |
1097 } | |
1098 | |
1099 void BrowserPluginGuest::OnShowWidget(int route_id, | 1080 void BrowserPluginGuest::OnShowWidget(int route_id, |
1100 const gfx::Rect& initial_pos) { | 1081 const gfx::Rect& initial_pos) { |
1101 gfx::Rect screen_pos(initial_pos); | 1082 gfx::Rect screen_pos(initial_pos); |
1102 screen_pos.Offset(guest_screen_rect_.OffsetFromOrigin()); | 1083 screen_pos.Offset(guest_screen_rect_.OffsetFromOrigin()); |
1103 GetWebContents()->ShowCreatedWidget(route_id, screen_pos); | 1084 GetWebContents()->ShowCreatedWidget(route_id, screen_pos); |
1104 } | 1085 } |
1105 | 1086 |
1106 void BrowserPluginGuest::OnTakeFocus(bool reverse) { | 1087 void BrowserPluginGuest::OnTakeFocus(bool reverse) { |
1107 SendMessageToEmbedder( | 1088 SendMessageToEmbedder( |
1108 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); | 1089 new BrowserPluginMsg_AdvanceFocus(instance_id(), reverse)); |
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1317 base::Value::CreateStringValue(request_method)); | 1298 base::Value::CreateStringValue(request_method)); |
1318 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); | 1299 request_info.Set(browser_plugin::kURL, base::Value::CreateStringValue(url)); |
1319 | 1300 |
1320 SendMessageToEmbedder( | 1301 SendMessageToEmbedder( |
1321 new BrowserPluginMsg_RequestPermission(instance_id(), | 1302 new BrowserPluginMsg_RequestPermission(instance_id(), |
1322 BrowserPluginPermissionTypeDownload, permission_request_id, | 1303 BrowserPluginPermissionTypeDownload, permission_request_id, |
1323 request_info)); | 1304 request_info)); |
1324 } | 1305 } |
1325 | 1306 |
1326 } // namespace content | 1307 } // namespace content |
OLD | NEW |