Skip to content

Commit

Permalink
Reset embedder_zoom_controller_ before assigning new one
Browse files Browse the repository at this point in the history
  • Loading branch information
alespergl committed Dec 1, 2017
1 parent fd7af5c commit dadfbd3
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
16 changes: 12 additions & 4 deletions atom/browser/web_view_guest_delegate.cc
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,7 @@ void WebViewGuestDelegate::Initialize(api::WebContents* api_web_contents) {

void WebViewGuestDelegate::Destroy() {
// Give the content module an opportunity to perform some cleanup.
if (embedder_zoom_controller_) {
embedder_zoom_controller_->RemoveObserver(this);
embedder_zoom_controller_ = nullptr;
}
ResetZoomController();
guest_host_->WillDestroy();
guest_host_ = nullptr;
}
Expand Down Expand Up @@ -113,11 +110,15 @@ void WebViewGuestDelegate::DidFinishNavigation(

void WebViewGuestDelegate::DidDetach() {
attached_ = false;
ResetZoomController();
}

void WebViewGuestDelegate::DidAttach(int guest_proxy_routing_id) {
attached_ = true;
api_web_contents_->Emit("did-attach");

ResetZoomController();

embedder_zoom_controller_ =
WebContentsZoomController::FromWebContents(embedder_web_contents_);
auto zoom_controller = api_web_contents_->GetZoomController();
Expand Down Expand Up @@ -183,6 +184,13 @@ gfx::Size WebViewGuestDelegate::GetDefaultSize() const {
}
}

void WebViewGuestDelegate::ResetZoomController() {
if (embedder_zoom_controller_) {
embedder_zoom_controller_->RemoveObserver(this);
embedder_zoom_controller_ = nullptr;
}
}

bool WebViewGuestDelegate::CanBeEmbeddedInsideCrossProcessFrames() {
return true;
}
Expand Down
2 changes: 2 additions & 0 deletions atom/browser/web_view_guest_delegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@ class WebViewGuestDelegate : public content::BrowserPluginGuestDelegate,
// Returns the default size of the guestview.
gfx::Size GetDefaultSize() const;

void ResetZoomController();

// The WebContents that attaches this guest view.
content::WebContents* embedder_web_contents_ = nullptr;

Expand Down

0 comments on commit dadfbd3

Please sign in to comment.