Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(701)

Unified Diff: content/browser/host_zoom_map_observer.cc

Issue 2581143002: Maintain HostZoom connection per-frame on browser side (Closed)
Patch Set: Rebase Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/browser/host_zoom_map_observer.h ('k') | content/browser/iframe_zoom_browsertest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/browser/host_zoom_map_observer.cc
diff --git a/content/browser/host_zoom_map_observer.cc b/content/browser/host_zoom_map_observer.cc
index 88d42dfb6b825f27965b4206b8cf3f5e40ddb139..90f2695a32d3c0e3f35bff94b270ba9d30278401 100644
--- a/content/browser/host_zoom_map_observer.cc
+++ b/content/browser/host_zoom_map_observer.cc
@@ -23,23 +23,36 @@ void HostZoomMapObserver::ReadyToCommitNavigation(
if (!navigation_handle->IsInMainFrame())
return;
- DCHECK(host_zoom_.is_bound());
- if (!host_zoom_.is_bound())
- return;
-
RenderFrameHost* render_frame_host =
navigation_handle->GetRenderFrameHost();
+ const auto& entry = host_zoom_ptrs_.find(render_frame_host);
+ if (entry == host_zoom_ptrs_.end())
+ return;
+
+ const mojom::HostZoomAssociatedPtr& host_zoom = entry->second;
+ DCHECK(host_zoom.is_bound());
+ if (host_zoom.encountered_error())
+ return;
+
RenderProcessHost* render_process_host = render_frame_host->GetProcess();
HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>(
render_process_host->GetStoragePartition()->GetHostZoomMap());
double zoom_level = host_zoom_map->GetZoomLevelForView(
navigation_handle->GetURL(), render_process_host->GetID(),
render_frame_host->GetRenderViewHost()->GetRoutingID());
- host_zoom_->SetHostZoomLevel(navigation_handle->GetURL(), zoom_level);
+ host_zoom->SetHostZoomLevel(navigation_handle->GetURL(), zoom_level);
}
void HostZoomMapObserver::RenderFrameCreated(RenderFrameHost* rfh) {
- rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom_);
+ mojom::HostZoomAssociatedPtr host_zoom;
+ rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom);
+ host_zoom_ptrs_[rfh] = std::move(host_zoom);
+}
+
+void HostZoomMapObserver::RenderFrameDeleted(RenderFrameHost* rfh) {
+ const auto& entry = host_zoom_ptrs_.find(rfh);
+ DCHECK(entry != host_zoom_ptrs_.end());
+ host_zoom_ptrs_.erase(entry);
}
} // namespace content
« no previous file with comments | « content/browser/host_zoom_map_observer.h ('k') | content/browser/iframe_zoom_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698