Chromium Code Reviews| Index: components/guest_view/browser/guest_view_base.cc |
| diff --git a/components/guest_view/browser/guest_view_base.cc b/components/guest_view/browser/guest_view_base.cc |
| index c6172cb6ab131b814b2cb335ba69caed2b8ad628..8531a2f1e620524b06b0f282f8e5eab06e7dd5c6 100644 |
| --- a/components/guest_view/browser/guest_view_base.cc |
| +++ b/components/guest_view/browser/guest_view_base.cc |
| @@ -159,6 +159,8 @@ GuestViewBase::GuestViewBase(WebContents* owner_web_contents) |
| owner_web_contents->GetLastCommittedURL().host() : std::string(); |
| } |
| +GuestViewBase::~GuestViewBase() {} |
| + |
| void GuestViewBase::Init(const base::DictionaryValue& create_params, |
| const WebContentsCreatedCallback& callback) { |
| if (initialized_) |
| @@ -226,94 +228,6 @@ void GuestViewBase::InitWithWebContents( |
| DidInitialize(create_params); |
| } |
| -void GuestViewBase::LoadURLWithParams( |
| - const content::NavigationController::LoadURLParams& load_params) { |
| - int guest_proxy_routing_id = host()->LoadURLWithParams(load_params); |
| - DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE || |
| - guest_proxy_routing_id == guest_proxy_routing_id_); |
| - guest_proxy_routing_id_ = guest_proxy_routing_id; |
| -} |
| - |
| -void GuestViewBase::DispatchOnResizeEvent(const gfx::Size& old_size, |
| - const gfx::Size& new_size) { |
| - if (new_size == old_size) |
| - return; |
| - |
| - // Dispatch the onResize event. |
| - scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| - args->SetInteger(kOldWidth, old_size.width()); |
| - args->SetInteger(kOldHeight, old_size.height()); |
| - args->SetInteger(kNewWidth, new_size.width()); |
| - args->SetInteger(kNewHeight, new_size.height()); |
| - DispatchEventToGuestProxy(new GuestViewEvent(kEventResize, args.Pass())); |
| -} |
| - |
| -gfx::Size GuestViewBase::GetDefaultSize() const { |
| - if (is_full_page_plugin()) { |
| - // Full page plugins default to the size of the owner's viewport. |
| - return owner_web_contents() |
| - ->GetRenderWidgetHostView() |
| - ->GetVisibleViewportSize(); |
| - } else { |
| - return gfx::Size(kDefaultWidth, kDefaultHeight); |
| - } |
| -} |
| - |
| -void GuestViewBase::SetSize(const SetSizeParams& params) { |
| - bool enable_auto_size = |
| - params.enable_auto_size ? *params.enable_auto_size : auto_size_enabled_; |
| - gfx::Size min_size = params.min_size ? *params.min_size : min_auto_size_; |
| - gfx::Size max_size = params.max_size ? *params.max_size : max_auto_size_; |
| - |
| - if (params.normal_size) |
| - normal_size_ = *params.normal_size; |
| - |
| - min_auto_size_ = min_size; |
| - min_auto_size_.SetToMin(max_size); |
| - max_auto_size_ = max_size; |
| - max_auto_size_.SetToMax(min_size); |
| - |
| - enable_auto_size &= !min_auto_size_.IsEmpty() && !max_auto_size_.IsEmpty() && |
| - IsAutoSizeSupported(); |
| - |
| - content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| - if (enable_auto_size) { |
| - // Autosize is being enabled. |
| - rvh->EnableAutoResize(min_auto_size_, max_auto_size_); |
| - normal_size_.SetSize(0, 0); |
| - } else { |
| - // Autosize is being disabled. |
| - // Use default width/height if missing from partially defined normal size. |
| - if (normal_size_.width() && !normal_size_.height()) |
| - normal_size_.set_height(GetDefaultSize().height()); |
| - if (!normal_size_.width() && normal_size_.height()) |
| - normal_size_.set_width(GetDefaultSize().width()); |
| - |
| - gfx::Size new_size; |
| - if (!normal_size_.IsEmpty()) { |
| - new_size = normal_size_; |
| - } else if (!guest_size_.IsEmpty()) { |
| - new_size = guest_size_; |
| - } else { |
| - new_size = GetDefaultSize(); |
| - } |
| - |
| - bool changed_due_to_auto_resize = false; |
| - if (auto_size_enabled_) { |
| - // Autosize was previously enabled. |
| - rvh->DisableAutoResize(new_size); |
| - changed_due_to_auto_resize = true; |
| - } else { |
| - // Autosize was already disabled. |
| - guest_host_->SizeContents(new_size); |
| - } |
| - |
| - UpdateGuestSize(new_size, changed_due_to_auto_resize); |
| - } |
| - |
| - auto_size_enabled_ = enable_auto_size; |
| -} |
| - |
| // static |
| void GuestViewBase::CleanUp(content::BrowserContext* browser_context, |
| int embedder_process_id, |
| @@ -356,29 +270,6 @@ bool GuestViewBase::IsGuest(WebContents* web_contents) { |
| return !!GuestViewBase::FromWebContents(web_contents); |
| } |
| -bool GuestViewBase::IsAutoSizeSupported() const { |
| - return false; |
| -} |
| - |
| -bool GuestViewBase::IsPreferredSizeModeEnabled() const { |
| - return false; |
| -} |
| - |
| -bool GuestViewBase::ZoomPropagatesFromEmbedderToGuest() const { |
| - return true; |
| -} |
| - |
| -void GuestViewBase::SetContextMenuPosition(const gfx::Point& position) {} |
| - |
| -WebContents* GuestViewBase::CreateNewGuestWindow( |
| - const WebContents::CreateParams& create_params) { |
| - auto guest_manager = GuestViewManager::FromBrowserContext(browser_context()); |
| - return guest_manager->CreateGuestWithWebContentsParams( |
| - GetViewType(), |
| - owner_web_contents(), |
| - create_params); |
| -} |
| - |
| void GuestViewBase::DidAttach(int guest_proxy_routing_id) { |
| DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE || |
| guest_proxy_routing_id == guest_proxy_routing_id_); |
| @@ -399,38 +290,116 @@ void GuestViewBase::DidAttach(int guest_proxy_routing_id) { |
| SendQueuedEvents(); |
| } |
| -void GuestViewBase::DidDetach() { |
| - GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); |
| - StopTrackingEmbedderZoomLevel(); |
| - owner_web_contents()->Send(new GuestViewMsg_GuestDetached( |
| - element_instance_id_)); |
| - element_instance_id_ = kInstanceIDNone; |
| -} |
| +void GuestViewBase::WillAttach(WebContents* embedder_web_contents, |
| + int element_instance_id, |
| + bool is_full_page_plugin, |
| + const base::Closure& callback) { |
| + // Stop tracking the old embedder's zoom level. |
| + if (owner_web_contents()) |
| + StopTrackingEmbedderZoomLevel(); |
| -bool GuestViewBase::Find(int request_id, |
| - const base::string16& search_text, |
| - const blink::WebFindOptions& options) { |
| - if (ShouldHandleFindRequestsForEmbedder()) { |
| - web_contents()->Find(request_id, search_text, options); |
| - return true; |
| + if (owner_web_contents_ != embedder_web_contents) { |
| + DCHECK_EQ(owner_contents_observer_->web_contents(), owner_web_contents_); |
| + owner_web_contents_ = embedder_web_contents; |
| + owner_contents_observer_.reset( |
| + new OwnerContentsObserver(this, embedder_web_contents)); |
| + owner_host_ = GuestViewManager::FromBrowserContext(browser_context_) |
| + ->IsOwnedByExtension(this) |
| + ? owner_web_contents()->GetLastCommittedURL().host() |
| + : std::string(); |
| } |
| + |
| + // Start tracking the new embedder's zoom level. |
| + StartTrackingEmbedderZoomLevel(); |
| + element_instance_id_ = element_instance_id; |
| + is_full_page_plugin_ = is_full_page_plugin; |
| + |
| + WillAttachToEmbedder(); |
| + |
| + // Completing attachment will resume suspended resource loads and then send |
| + // queued events. |
| + SignalWhenReady(callback); |
| +} |
| + |
| +bool GuestViewBase::IsAutoSizeSupported() const { |
| return false; |
| } |
| -bool GuestViewBase::StopFinding(content::StopFindAction action) { |
| - if (ShouldHandleFindRequestsForEmbedder()) { |
| - web_contents()->StopFinding(action); |
| - return true; |
| - } |
| +bool GuestViewBase::IsPreferredSizeModeEnabled() const { |
| return false; |
| } |
| -WebContents* GuestViewBase::GetOwnerWebContents() const { |
| - return owner_web_contents_; |
| +bool GuestViewBase::ZoomPropagatesFromEmbedderToGuest() const { |
| + return true; |
| } |
| -void GuestViewBase::GuestSizeChanged(const gfx::Size& new_size) { |
| - UpdateGuestSize(new_size, auto_size_enabled_); |
| +void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { |
| + event->Dispatch(this, guest_instance_id_); |
| +} |
| + |
| +void GuestViewBase::DispatchEventToView(GuestViewEvent* event) { |
| + if (!attached() && |
| + (!CanRunInDetachedState() || !can_owner_receive_events())) { |
| + pending_events_.push_back(linked_ptr<GuestViewEvent>(event)); |
| + return; |
| + } |
| + |
| + event->Dispatch(this, view_instance_id_); |
| +} |
| + |
| +void GuestViewBase::SetSize(const SetSizeParams& params) { |
| + bool enable_auto_size = |
| + params.enable_auto_size ? *params.enable_auto_size : auto_size_enabled_; |
| + gfx::Size min_size = params.min_size ? *params.min_size : min_auto_size_; |
| + gfx::Size max_size = params.max_size ? *params.max_size : max_auto_size_; |
| + |
| + if (params.normal_size) |
| + normal_size_ = *params.normal_size; |
| + |
| + min_auto_size_ = min_size; |
| + min_auto_size_.SetToMin(max_size); |
| + max_auto_size_ = max_size; |
| + max_auto_size_.SetToMax(min_size); |
| + |
| + enable_auto_size &= !min_auto_size_.IsEmpty() && !max_auto_size_.IsEmpty() && |
| + IsAutoSizeSupported(); |
| + |
| + content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| + if (enable_auto_size) { |
| + // Autosize is being enabled. |
| + rvh->EnableAutoResize(min_auto_size_, max_auto_size_); |
| + normal_size_.SetSize(0, 0); |
| + } else { |
| + // Autosize is being disabled. |
| + // Use default width/height if missing from partially defined normal size. |
| + if (normal_size_.width() && !normal_size_.height()) |
| + normal_size_.set_height(GetDefaultSize().height()); |
| + if (!normal_size_.width() && normal_size_.height()) |
| + normal_size_.set_width(GetDefaultSize().width()); |
| + |
| + gfx::Size new_size; |
| + if (!normal_size_.IsEmpty()) { |
| + new_size = normal_size_; |
| + } else if (!guest_size_.IsEmpty()) { |
| + new_size = guest_size_; |
| + } else { |
| + new_size = GetDefaultSize(); |
| + } |
| + |
| + bool changed_due_to_auto_resize = false; |
| + if (auto_size_enabled_) { |
| + // Autosize was previously enabled. |
| + rvh->DisableAutoResize(new_size); |
| + changed_due_to_auto_resize = true; |
| + } else { |
| + // Autosize was already disabled. |
| + guest_host_->SizeContents(new_size); |
| + } |
| + |
| + UpdateGuestSize(new_size, changed_due_to_auto_resize); |
| + } |
| + |
| + auto_size_enabled_ = enable_auto_size; |
| } |
| const GURL& GuestViewBase::GetOwnerSiteURL() const { |
| @@ -487,38 +456,52 @@ void GuestViewBase::SetOpener(GuestViewBase* guest) { |
| opener_lifetime_observer_.reset(); |
| } |
| -void GuestViewBase::SetGuestHost(content::GuestHost* guest_host) { |
| - guest_host_ = guest_host; |
| +void GuestViewBase::SetContextMenuPosition(const gfx::Point& position) {} |
| + |
| +void GuestViewBase::HandleKeyboardEvent( |
| + WebContents* source, |
| + const content::NativeWebKeyboardEvent& event) { |
| + if (!attached()) |
| + return; |
| + |
| + // Send the keyboard events back to the embedder to reprocess them. |
| + embedder_web_contents()->GetDelegate()->HandleKeyboardEvent( |
| + embedder_web_contents(), event); |
| } |
| -void GuestViewBase::WillAttach(WebContents* embedder_web_contents, |
| - int element_instance_id, |
| - bool is_full_page_plugin, |
| - const base::Closure& callback) { |
| - // Stop tracking the old embedder's zoom level. |
| - if (owner_web_contents()) |
| - StopTrackingEmbedderZoomLevel(); |
| +bool GuestViewBase::PreHandleGestureEvent(WebContents* source, |
| + const blink::WebGestureEvent& event) { |
| + return event.type == blink::WebGestureEvent::GesturePinchBegin || |
| + event.type == blink::WebGestureEvent::GesturePinchUpdate || |
| + event.type == blink::WebGestureEvent::GesturePinchEnd; |
| +} |
| - if (owner_web_contents_ != embedder_web_contents) { |
| - DCHECK_EQ(owner_contents_observer_->web_contents(), owner_web_contents_); |
| - owner_web_contents_ = embedder_web_contents; |
| - owner_contents_observer_.reset( |
| - new OwnerContentsObserver(this, embedder_web_contents)); |
| - owner_host_ = GuestViewManager::FromBrowserContext(browser_context_)-> |
| - IsOwnedByExtension(this) ? |
| - owner_web_contents()->GetLastCommittedURL().host() : std::string(); |
| +void GuestViewBase::FindReply(WebContents* source, |
| + int request_id, |
| + int number_of_matches, |
| + const gfx::Rect& selection_rect, |
| + int active_match_ordinal, |
| + bool final_update) { |
| + if (ShouldHandleFindRequestsForEmbedder() && attached() && |
| + embedder_web_contents()->GetDelegate()) { |
| + embedder_web_contents()->GetDelegate()->FindReply( |
| + embedder_web_contents(), request_id, number_of_matches, selection_rect, |
| + active_match_ordinal, final_update); |
| } |
| +} |
| - // Start tracking the new embedder's zoom level. |
| - StartTrackingEmbedderZoomLevel(); |
| - element_instance_id_ = element_instance_id; |
| - is_full_page_plugin_ = is_full_page_plugin; |
| - |
| - WillAttachToEmbedder(); |
| +void GuestViewBase::DidNavigateMainFrame( |
| + const content::LoadCommittedDetails& details, |
| + const content::FrameNavigateParams& params) { |
| + if (attached() && ZoomPropagatesFromEmbedderToGuest()) |
| + SetGuestZoomLevelToMatchEmbedder(); |
| - // Completing attachment will resume suspended resource loads and then send |
| - // queued events. |
| - SignalWhenReady(callback); |
| + // TODO(lazyboy): This breaks guest visibility in --site-per-process because |
| + // we do not take the widget's visibility into account. We need to also |
| + // stay hidden during "visibility:none" state. |
| + if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| + web_contents()->WasShown(); |
| + } |
| } |
| void GuestViewBase::SignalWhenReady(const base::Closure& callback) { |
| @@ -531,6 +514,14 @@ bool GuestViewBase::ShouldHandleFindRequestsForEmbedder() const { |
| return false; |
| } |
| +void GuestViewBase::LoadURLWithParams( |
| + const content::NavigationController::LoadURLParams& load_params) { |
| + int guest_proxy_routing_id = host()->LoadURLWithParams(load_params); |
| + DCHECK(guest_proxy_routing_id_ == MSG_ROUTING_NONE || |
| + guest_proxy_routing_id == guest_proxy_routing_id_); |
| + guest_proxy_routing_id_ = guest_proxy_routing_id; |
| +} |
| + |
| int GuestViewBase::LogicalPixelsToPhysicalPixels(double logical_pixels) const { |
| DCHECK(logical_pixels >= 0); |
| double zoom_factor = GetEmbedderZoomFactor(); |
| @@ -543,42 +534,59 @@ double GuestViewBase::PhysicalPixelsToLogicalPixels(int physical_pixels) const { |
| return physical_pixels / zoom_factor; |
| } |
| -void GuestViewBase::DidStopLoading() { |
| - content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| +void GuestViewBase::SetGuestZoomLevelToMatchEmbedder() { |
| + auto embedder_zoom_controller = |
| + ui_zoom::ZoomController::FromWebContents(owner_web_contents()); |
| + if (!embedder_zoom_controller) |
| + return; |
| - if (IsPreferredSizeModeEnabled()) |
| - rvh->EnablePreferredSizeMode(); |
| - GuestViewDidStopLoading(); |
| + ui_zoom::ZoomController::FromWebContents(web_contents()) |
| + ->SetZoomLevel(embedder_zoom_controller->GetZoomLevel()); |
| } |
| -void GuestViewBase::RenderViewReady() { |
| - GuestReady(); |
| +WebContents* GuestViewBase::CreateNewGuestWindow( |
| + const WebContents::CreateParams& create_params) { |
| + auto guest_manager = GuestViewManager::FromBrowserContext(browser_context()); |
| + return guest_manager->CreateGuestWithWebContentsParams( |
| + GetViewType(), owner_web_contents(), create_params); |
| } |
| -void GuestViewBase::WebContentsDestroyed() { |
| - // Let the derived class know that its WebContents is in the process of |
| - // being destroyed. web_contents() is still valid at this point. |
| - // TODO(fsamuel): This allows for reentrant code into WebContents during |
| - // destruction. This could potentially lead to bugs. Perhaps we should get rid |
| - // of this? |
| - GuestDestroyed(); |
| - |
| - // Self-destruct. |
| - delete this; |
| +void GuestViewBase::DidDetach() { |
| + GuestViewManager::FromBrowserContext(browser_context_)->DetachGuest(this); |
| + StopTrackingEmbedderZoomLevel(); |
| + owner_web_contents()->Send( |
| + new GuestViewMsg_GuestDetached(element_instance_id_)); |
| + element_instance_id_ = kInstanceIDNone; |
| } |
| -void GuestViewBase::DidNavigateMainFrame( |
| - const content::LoadCommittedDetails& details, |
| - const content::FrameNavigateParams& params) { |
| - if (attached() && ZoomPropagatesFromEmbedderToGuest()) |
| - SetGuestZoomLevelToMatchEmbedder(); |
| +bool GuestViewBase::Find(int request_id, |
| + const base::string16& search_text, |
| + const blink::WebFindOptions& options) { |
| + if (ShouldHandleFindRequestsForEmbedder()) { |
| + web_contents()->Find(request_id, search_text, options); |
| + return true; |
| + } |
| + return false; |
| +} |
| - // TODO(lazyboy): This breaks guest visibility in --site-per-process because |
| - // we do not take the widget's visibility into account. We need to also |
| - // stay hidden during "visibility:none" state. |
| - if (content::BrowserPluginGuestMode::UseCrossProcessFramesForGuests()) { |
| - web_contents()->WasShown(); |
| +bool GuestViewBase::StopFinding(content::StopFindAction action) { |
| + if (ShouldHandleFindRequestsForEmbedder()) { |
| + web_contents()->StopFinding(action); |
| + return true; |
| } |
| + return false; |
| +} |
| + |
| +WebContents* GuestViewBase::GetOwnerWebContents() const { |
| + return owner_web_contents_; |
| +} |
| + |
| +void GuestViewBase::GuestSizeChanged(const gfx::Size& new_size) { |
| + UpdateGuestSize(new_size, auto_size_enabled_); |
| +} |
| + |
| +void GuestViewBase::SetGuestHost(content::GuestHost* guest_host) { |
| + guest_host_ = guest_host; |
| } |
| void GuestViewBase::ActivateContents(WebContents* web_contents) { |
| @@ -613,17 +621,6 @@ void GuestViewBase::ContentsZoomChange(bool zoom_in) { |
| zoom_in ? content::PAGE_ZOOM_IN : content::PAGE_ZOOM_OUT); |
| } |
| -void GuestViewBase::HandleKeyboardEvent( |
| - WebContents* source, |
| - const content::NativeWebKeyboardEvent& event) { |
| - if (!attached()) |
| - return; |
| - |
| - // Send the keyboard events back to the embedder to reprocess them. |
| - embedder_web_contents()->GetDelegate()-> |
| - HandleKeyboardEvent(embedder_web_contents(), event); |
| -} |
| - |
| void GuestViewBase::LoadingStateChanged(WebContents* source, |
| bool to_different_document) { |
| if (!attached() || !embedder_web_contents()->GetDelegate()) |
| @@ -662,13 +659,6 @@ bool GuestViewBase::ShouldFocusPageAfterCrash() { |
| return false; |
| } |
| -bool GuestViewBase::PreHandleGestureEvent(WebContents* source, |
| - const blink::WebGestureEvent& event) { |
| - return event.type == blink::WebGestureEvent::GesturePinchBegin || |
| - event.type == blink::WebGestureEvent::GesturePinchUpdate || |
| - event.type == blink::WebGestureEvent::GesturePinchEnd; |
| -} |
| - |
| void GuestViewBase::UpdatePreferredSize(WebContents* target_web_contents, |
| const gfx::Size& pref_size) { |
| // In theory it's not necessary to check IsPreferredSizeModeEnabled() because |
| @@ -692,24 +682,28 @@ bool GuestViewBase::ShouldResumeRequestsForCreatedWindow() { |
| return false; |
| } |
| -void GuestViewBase::FindReply(WebContents* source, |
| - int request_id, |
| - int number_of_matches, |
| - const gfx::Rect& selection_rect, |
| - int active_match_ordinal, |
| - bool final_update) { |
| - if (ShouldHandleFindRequestsForEmbedder() && |
| - attached() && embedder_web_contents()->GetDelegate()) { |
| - embedder_web_contents()->GetDelegate()->FindReply(embedder_web_contents(), |
| - request_id, |
| - number_of_matches, |
| - selection_rect, |
| - active_match_ordinal, |
| - final_update); |
| - } |
| +void GuestViewBase::DidStopLoading() { |
| + content::RenderViewHost* rvh = web_contents()->GetRenderViewHost(); |
| + |
| + if (IsPreferredSizeModeEnabled()) |
| + rvh->EnablePreferredSizeMode(); |
| + GuestViewDidStopLoading(); |
| } |
| -GuestViewBase::~GuestViewBase() { |
| +void GuestViewBase::RenderViewReady() { |
| + GuestReady(); |
| +} |
| + |
| +void GuestViewBase::WebContentsDestroyed() { |
| + // Let the derived class know that its WebContents is in the process of |
| + // being destroyed. web_contents() is still valid at this point. |
| + // TODO(fsamuel): This allows for reentrant code into WebContents during |
| + // destruction. This could potentially lead to bugs. Perhaps we should get rid |
| + // of this? |
| + GuestDestroyed(); |
| + |
| + // Self-destruct. |
| + delete this; |
| } |
| void GuestViewBase::OnZoomChanged( |
| @@ -725,8 +719,6 @@ void GuestViewBase::OnZoomChanged( |
| // When the embedder's zoom level doesn't match the guest's, then update the |
| // guest's zoom level to match. |
| guest_zoom_controller->SetZoomLevel(data.new_zoom_level); |
| - |
| - EmbedderZoomChanged(data.old_zoom_level, data.new_zoom_level); |
|
Fady Samuel
2015/10/10 10:58:01
Why was this deleted?
paulmeyer
2015/10/16 21:13:03
Because it does nothing and is never overridden.
Fady Samuel
2015/10/16 21:17:28
Acknowledged.
|
| return; |
| } |
| @@ -736,20 +728,6 @@ void GuestViewBase::OnZoomChanged( |
| } |
| } |
| -void GuestViewBase::DispatchEventToGuestProxy(GuestViewEvent* event) { |
| - event->Dispatch(this, guest_instance_id_); |
| -} |
| - |
| -void GuestViewBase::DispatchEventToView(GuestViewEvent* event) { |
| - if (!attached() && |
| - (!CanRunInDetachedState() || !can_owner_receive_events())) { |
| - pending_events_.push_back(linked_ptr<GuestViewEvent>(event)); |
| - return; |
| - } |
| - |
| - event->Dispatch(this, view_instance_id_); |
| -} |
| - |
| void GuestViewBase::SendQueuedEvents() { |
| if (!attached()) |
| return; |
| @@ -775,6 +753,31 @@ void GuestViewBase::CompleteInit( |
| callback.Run(guest_web_contents); |
| } |
| +void GuestViewBase::DispatchOnResizeEvent(const gfx::Size& old_size, |
| + const gfx::Size& new_size) { |
| + if (new_size == old_size) |
| + return; |
| + |
| + // Dispatch the onResize event. |
| + scoped_ptr<base::DictionaryValue> args(new base::DictionaryValue()); |
| + args->SetInteger(kOldWidth, old_size.width()); |
| + args->SetInteger(kOldHeight, old_size.height()); |
| + args->SetInteger(kNewWidth, new_size.width()); |
| + args->SetInteger(kNewHeight, new_size.height()); |
| + DispatchEventToGuestProxy(new GuestViewEvent(kEventResize, args.Pass())); |
| +} |
| + |
| +gfx::Size GuestViewBase::GetDefaultSize() const { |
| + if (is_full_page_plugin()) { |
| + // Full page plugins default to the size of the owner's viewport. |
| + return owner_web_contents() |
| + ->GetRenderWidgetHostView() |
| + ->GetVisibleViewportSize(); |
| + } else { |
| + return gfx::Size(kDefaultWidth, kDefaultHeight); |
| + } |
| +} |
| + |
| double GuestViewBase::GetEmbedderZoomFactor() const { |
| if (!embedder_web_contents()) |
| return 1.0; |
| @@ -832,16 +835,6 @@ void GuestViewBase::SetUpSizing(const base::DictionaryValue& params) { |
| SetSize(set_size_params); |
| } |
| -void GuestViewBase::SetGuestZoomLevelToMatchEmbedder() { |
| - auto embedder_zoom_controller = |
| - ui_zoom::ZoomController::FromWebContents(owner_web_contents()); |
| - if (!embedder_zoom_controller) |
| - return; |
| - |
| - ui_zoom::ZoomController::FromWebContents(web_contents()) |
| - ->SetZoomLevel(embedder_zoom_controller->GetZoomLevel()); |
| -} |
| - |
| void GuestViewBase::StartTrackingEmbedderZoomLevel() { |
| if (!ZoomPropagatesFromEmbedderToGuest()) |
| return; |