OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/guest_view/browser/guest_view_base.h" | 5 #include "components/guest_view/browser/guest_view_base.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/macros.h" | 10 #include "base/macros.h" |
11 #include "base/memory/ptr_util.h" | 11 #include "base/memory/ptr_util.h" |
12 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
13 #include "components/guest_view/browser/guest_view_event.h" | 13 #include "components/guest_view/browser/guest_view_event.h" |
14 #include "components/guest_view/browser/guest_view_manager.h" | 14 #include "components/guest_view/browser/guest_view_manager.h" |
15 #include "components/guest_view/common/guest_view_constants.h" | 15 #include "components/guest_view/common/guest_view_constants.h" |
16 #include "components/guest_view/common/guest_view_messages.h" | 16 #include "components/guest_view/common/guest_view_messages.h" |
17 #include "components/zoom/page_zoom.h" | 17 #include "components/zoom/page_zoom.h" |
18 #include "components/zoom/zoom_controller.h" | 18 #include "components/zoom/zoom_controller.h" |
19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
20 #include "content/public/browser/render_frame_host.h" | 20 #include "content/public/browser/render_frame_host.h" |
21 #include "content/public/browser/render_process_host.h" | 21 #include "content/public/browser/render_process_host.h" |
22 #include "content/public/browser/render_view_host.h" | 22 #include "content/public/browser/render_view_host.h" |
| 23 #include "content/public/browser/render_widget_host.h" |
23 #include "content/public/browser/render_widget_host_view.h" | 24 #include "content/public/browser/render_widget_host_view.h" |
24 #include "content/public/browser/web_contents.h" | 25 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/page_zoom.h" | 26 #include "content/public/common/page_zoom.h" |
26 #include "content/public/common/url_constants.h" | 27 #include "content/public/common/url_constants.h" |
27 #include "third_party/WebKit/public/web/WebInputEvent.h" | 28 #include "third_party/WebKit/public/web/WebInputEvent.h" |
28 | 29 |
29 using content::WebContents; | 30 using content::WebContents; |
30 | 31 |
31 namespace content { | 32 namespace content { |
32 struct FrameNavigateParams; | 33 struct FrameNavigateParams; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
409 | 410 |
410 SetUpSizing(*attach_params()); | 411 SetUpSizing(*attach_params()); |
411 | 412 |
412 // The guest should have the same muting state as the owner. | 413 // The guest should have the same muting state as the owner. |
413 web_contents()->SetAudioMuted(owner_web_contents()->IsAudioMuted()); | 414 web_contents()->SetAudioMuted(owner_web_contents()->IsAudioMuted()); |
414 | 415 |
415 // Give the derived class an opportunity to perform some actions. | 416 // Give the derived class an opportunity to perform some actions. |
416 DidAttachToEmbedder(); | 417 DidAttachToEmbedder(); |
417 | 418 |
418 // Inform the associated GuestViewContainer that the contentWindow is ready. | 419 // Inform the associated GuestViewContainer that the contentWindow is ready. |
419 embedder_web_contents()->Send(new GuestViewMsg_GuestAttached( | 420 GetOwnerFrame()->GetView()->GetRenderWidgetHost()->Send( |
420 element_instance_id_, | 421 new GuestViewMsg_GuestAttached(element_instance_id_, |
421 guest_proxy_routing_id)); | 422 guest_proxy_routing_id)); |
422 | 423 |
423 SendQueuedEvents(); | 424 SendQueuedEvents(); |
424 } | 425 } |
425 | 426 |
426 void GuestViewBase::DidDetach() { | 427 void GuestViewBase::DidDetach() { |
427 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); | 428 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); |
428 StopTrackingEmbedderZoomLevel(); | 429 StopTrackingEmbedderZoomLevel(); |
429 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( | 430 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( |
430 element_instance_id_)); | 431 element_instance_id_)); |
431 element_instance_id_ = kInstanceIDNone; | 432 element_instance_id_ = kInstanceIDNone; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
719 attached() && embedder_web_contents()->GetDelegate()) { | 720 attached() && embedder_web_contents()->GetDelegate()) { |
720 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), | 721 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), |
721 request_id, | 722 request_id, |
722 number_of_matches, | 723 number_of_matches, |
723 selection_rect, | 724 selection_rect, |
724 active_match_ordinal, | 725 active_match_ordinal, |
725 final_update); | 726 final_update); |
726 } | 727 } |
727 } | 728 } |
728 | 729 |
| 730 content::RenderFrameHost* GuestViewBase::GetOwnerFrame() { |
| 731 if (GetOwnerWebContents()) |
| 732 return GetOwnerWebContents()->GetMainFrame(); |
| 733 return nullptr; |
| 734 } |
| 735 |
729 void GuestViewBase::OnZoomChanged( | 736 void GuestViewBase::OnZoomChanged( |
730 const zoom::ZoomController::ZoomChangedEventData& data) { | 737 const zoom::ZoomController::ZoomChangedEventData& data) { |
731 if (data.web_contents == embedder_web_contents()) { | 738 if (data.web_contents == embedder_web_contents()) { |
732 // The embedder's zoom level has changed. | 739 // The embedder's zoom level has changed. |
733 auto* guest_zoom_controller = | 740 auto* guest_zoom_controller = |
734 zoom::ZoomController::FromWebContents(web_contents()); | 741 zoom::ZoomController::FromWebContents(web_contents()); |
735 if (content::ZoomValuesEqual(data.new_zoom_level, | 742 if (content::ZoomValuesEqual(data.new_zoom_level, |
736 guest_zoom_controller->GetZoomLevel())) { | 743 guest_zoom_controller->GetZoomLevel())) { |
737 return; | 744 return; |
738 } | 745 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
886 | 893 |
887 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, | 894 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, |
888 bool due_to_auto_resize) { | 895 bool due_to_auto_resize) { |
889 if (due_to_auto_resize) | 896 if (due_to_auto_resize) |
890 GuestSizeChangedDueToAutoSize(guest_size_, new_size); | 897 GuestSizeChangedDueToAutoSize(guest_size_, new_size); |
891 DispatchOnResizeEvent(guest_size_, new_size); | 898 DispatchOnResizeEvent(guest_size_, new_size); |
892 guest_size_ = new_size; | 899 guest_size_ = new_size; |
893 } | 900 } |
894 | 901 |
895 } // namespace guest_view | 902 } // namespace guest_view |
OLD | NEW |