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" |
25 #include "content/public/browser/site_instance.h" | |
24 #include "content/public/browser/web_contents.h" | 26 #include "content/public/browser/web_contents.h" |
25 #include "content/public/common/page_zoom.h" | 27 #include "content/public/common/page_zoom.h" |
26 #include "content/public/common/url_constants.h" | 28 #include "content/public/common/url_constants.h" |
27 #include "third_party/WebKit/public/web/WebInputEvent.h" | 29 #include "third_party/WebKit/public/web/WebInputEvent.h" |
28 | 30 |
29 using content::WebContents; | 31 using content::WebContents; |
30 | 32 |
31 namespace content { | 33 namespace content { |
32 struct FrameNavigateParams; | 34 struct FrameNavigateParams; |
33 } | 35 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
112 guest_->web_contents()->SetPageScale(page_scale_factor); | 114 guest_->web_contents()->SetPageScale(page_scale_factor); |
113 } | 115 } |
114 | 116 |
115 void DidUpdateAudioMutingState(bool muted) override { | 117 void DidUpdateAudioMutingState(bool muted) override { |
116 if (destroyed_) | 118 if (destroyed_) |
117 return; | 119 return; |
118 | 120 |
119 guest_->web_contents()->SetAudioMuted(muted); | 121 guest_->web_contents()->SetAudioMuted(muted); |
120 } | 122 } |
121 | 123 |
124 void RenderFrameDeleted(content::RenderFrameHost* rfh) { | |
125 guest_->OnRenderFrameHostDeleted(rfh->GetProcess()->GetID(), | |
126 rfh->GetRoutingID()); | |
127 } | |
128 | |
122 private: | 129 private: |
123 bool is_fullscreen_; | 130 bool is_fullscreen_; |
124 bool destroyed_; | 131 bool destroyed_; |
125 GuestViewBase* guest_; | 132 GuestViewBase* guest_; |
126 | 133 |
127 void Destroy() { | 134 void Destroy() { |
128 if (destroyed_) | 135 if (destroyed_) |
129 return; | 136 return; |
130 destroyed_ = true; | 137 destroyed_ = true; |
131 guest_->Destroy(); | 138 guest_->Destroy(); |
(...skipping 261 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
393 | 400 |
394 WebContents* GuestViewBase::CreateNewGuestWindow( | 401 WebContents* GuestViewBase::CreateNewGuestWindow( |
395 const WebContents::CreateParams& create_params) { | 402 const WebContents::CreateParams& create_params) { |
396 auto* guest_manager = GuestViewManager::FromBrowserContext(browser_context()); | 403 auto* guest_manager = GuestViewManager::FromBrowserContext(browser_context()); |
397 return guest_manager->CreateGuestWithWebContentsParams( | 404 return guest_manager->CreateGuestWithWebContentsParams( |
398 GetViewType(), | 405 GetViewType(), |
399 owner_web_contents(), | 406 owner_web_contents(), |
400 create_params); | 407 create_params); |
401 } | 408 } |
402 | 409 |
410 void GuestViewBase::OnRenderFrameHostDeleted(int process_id, int routing_id) {} | |
411 | |
403 void GuestViewBase::DidAttach(int guest_proxy_routing_id) { | 412 void GuestViewBase::DidAttach(int guest_proxy_routing_id) { |
404 DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE || | 413 DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE || |
405 guest_proxy_routing_id == guest_proxy_routing_id_); | 414 guest_proxy_routing_id == guest_proxy_routing_id_); |
406 guest_proxy_routing_id_ = guest_proxy_routing_id; | 415 guest_proxy_routing_id_ = guest_proxy_routing_id; |
407 | 416 |
408 opener_lifetime_observer_.reset(); | 417 opener_lifetime_observer_.reset(); |
409 | 418 |
410 SetUpSizing(*attach_params()); | 419 SetUpSizing(*attach_params()); |
411 | 420 |
412 // The guest should have the same muting state as the owner. | 421 // The guest should have the same muting state as the owner. |
413 web_contents()->SetAudioMuted(owner_web_contents()->IsAudioMuted()); | 422 web_contents()->SetAudioMuted(owner_web_contents()->IsAudioMuted()); |
414 | 423 |
415 // Give the derived class an opportunity to perform some actions. | 424 // Give the derived class an opportunity to perform some actions. |
416 DidAttachToEmbedder(); | 425 DidAttachToEmbedder(); |
417 | 426 |
418 // Inform the associated GuestViewContainer that the contentWindow is ready. | 427 // Inform the associated GuestViewContainer that the contentWindow is ready. |
419 embedder_web_contents()->Send(new GuestViewMsg_GuestAttached( | 428 GetOwnerRenderWidgetHost()->Send(new GuestViewMsg_GuestAttached( |
420 element_instance_id_, | 429 element_instance_id_, guest_proxy_routing_id)); |
421 guest_proxy_routing_id)); | |
422 | 430 |
423 SendQueuedEvents(); | 431 SendQueuedEvents(); |
424 } | 432 } |
425 | 433 |
426 void GuestViewBase::DidDetach() { | 434 void GuestViewBase::DidDetach() { |
427 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); | 435 GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); |
428 StopTrackingEmbedderZoomLevel(); | 436 StopTrackingEmbedderZoomLevel(); |
429 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( | 437 owner_web_contents()->Send(new GuestViewMsg_GuestDetached( |
430 element_instance_id_)); | 438 element_instance_id_)); |
431 element_instance_id_ = kInstanceIDNone; | 439 element_instance_id_ = kInstanceIDNone; |
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 attached() && embedder_web_contents()->GetDelegate()) { | 727 attached() && embedder_web_contents()->GetDelegate()) { |
720 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), | 728 embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), |
721 request_id, | 729 request_id, |
722 number_of_matches, | 730 number_of_matches, |
723 selection_rect, | 731 selection_rect, |
724 active_match_ordinal, | 732 active_match_ordinal, |
725 final_update); | 733 final_update); |
726 } | 734 } |
727 } | 735 } |
728 | 736 |
737 content::RenderWidgetHost* GuestViewBase::GetOwnerRenderWidgetHost() { | |
738 if (GetOwnerWebContents() && | |
739 GetOwnerWebContents()->GetRenderWidgetHostView()) { | |
740 return GetOwnerWebContents() | |
741 ->GetRenderWidgetHostView() | |
742 ->GetRenderWidgetHost(); | |
743 } | |
744 return nullptr; | |
745 } | |
746 | |
747 content::SiteInstance* GuestViewBase::GetOwnerSiteInstance() { | |
748 if (auto* owner_contents = GetOwnerWebContents()) | |
749 return owner_contents->GetSiteInstance(); | |
Charlie Reis
2016/11/16 22:25:27
Please put comments in both of these methods about
EhsanK
2016/11/16 22:47:49
Done.
| |
750 return nullptr; | |
751 } | |
752 | |
729 void GuestViewBase::OnZoomChanged( | 753 void GuestViewBase::OnZoomChanged( |
730 const zoom::ZoomController::ZoomChangedEventData& data) { | 754 const zoom::ZoomController::ZoomChangedEventData& data) { |
731 if (data.web_contents == embedder_web_contents()) { | 755 if (data.web_contents == embedder_web_contents()) { |
732 // The embedder's zoom level has changed. | 756 // The embedder's zoom level has changed. |
733 auto* guest_zoom_controller = | 757 auto* guest_zoom_controller = |
734 zoom::ZoomController::FromWebContents(web_contents()); | 758 zoom::ZoomController::FromWebContents(web_contents()); |
735 if (content::ZoomValuesEqual(data.new_zoom_level, | 759 if (content::ZoomValuesEqual(data.new_zoom_level, |
736 guest_zoom_controller->GetZoomLevel())) { | 760 guest_zoom_controller->GetZoomLevel())) { |
737 return; | 761 return; |
738 } | 762 } |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
886 | 910 |
887 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, | 911 void GuestViewBase::UpdateGuestSize(const gfx::Size& new_size, |
888 bool due_to_auto_resize) { | 912 bool due_to_auto_resize) { |
889 if (due_to_auto_resize) | 913 if (due_to_auto_resize) |
890 GuestSizeChangedDueToAutoSize(guest_size_, new_size); | 914 GuestSizeChangedDueToAutoSize(guest_size_, new_size); |
891 DispatchOnResizeEvent(guest_size_, new_size); | 915 DispatchOnResizeEvent(guest_size_, new_size); |
892 guest_size_ = new_size; | 916 guest_size_ = new_size; |
893 } | 917 } |
894 | 918 |
895 } // namespace guest_view | 919 } // namespace guest_view |
OLD | NEW |