Update HostZoomMap event subscription when RenderViewHost changes.
Each ZoomController is associated with a WebContents and a HostZoomMap.
However, it is possible that a WebContents can, as it navigates, change
its StoragePartition, and therefore its HostZoomMap. This CL monitors
WebContentsObserver for changes in RenderViewHost, and updates the
HostZoomMap subscription if the HostZoomMap changes.
BUG=438979
Review URL: https://codereview.chromium.org/767293006
Cr-Commit-Position: refs/heads/master@{#308585}
diff --git a/components/ui/zoom/zoom_controller.h b/components/ui/zoom/zoom_controller.h
index 5814345..f661ba4 100644
--- a/components/ui/zoom/zoom_controller.h
+++ b/components/ui/zoom/zoom_controller.h
@@ -140,6 +140,8 @@
const content::LoadCommittedDetails& details,
const content::FrameNavigateParams& params) override;
void WebContentsDestroyed() override;
+ void RenderFrameHostChanged(content::RenderFrameHost* old_host,
+ content::RenderFrameHost* new_host) override;
protected:
// Protected for testing.
@@ -176,6 +178,8 @@
ObserverList<ZoomObserver> observers_;
content::BrowserContext* browser_context_;
+ // Keep track of the HostZoomMap we're currently subscribed to.
+ content::HostZoomMap* host_zoom_map_;
scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;