Chromium Code Reviews| 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 |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..642b52f4ea80fa63f5731199eace3dae3228a304 |
| --- /dev/null |
| +++ b/content/browser/host_zoom_map_observer.cc |
| @@ -0,0 +1,42 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "content/browser/host_zoom_map_observer.h" |
| + |
| +#include "content/browser/frame_host/render_frame_host_impl.h" |
| +#include "content/browser/host_zoom_map_impl.h" |
| +#include "content/public/browser/navigation_handle.h" |
| +#include "content/public/browser/render_view_host.h" |
| +#include "content/public/browser/storage_partition.h" |
| +#include "content/public/common/associated_interface_provider.h" |
| + |
| +namespace content { |
| + |
| +HostZoomMapObserver::HostZoomMapObserver(WebContents* web_contents) |
| + : WebContentsObserver(web_contents) {} |
| + |
| +HostZoomMapObserver::~HostZoomMapObserver() {} |
| + |
| +void HostZoomMapObserver::ReadyToCommitNavigation( |
| + NavigationHandle* navigation_handle) { |
| + if (navigation_handle->IsInMainFrame()) { |
|
nasko
2016/10/25 23:17:07
minor nit: Early returns make the code easier to r
scottmg
2016/10/25 23:30:00
Done x2.
|
| + if (host_zoom_.is_bound()) { |
|
nasko
2016/10/25 23:17:07
nit: Should this ever not be bound? If not, maybe
scottmg
2016/10/25 23:30:00
Added a DCHECK for tryruns. I think I might have a
scottmg
2016/10/26 00:23:02
It looks like there's "only" 2 content_unittests t
nasko
2016/10/27 14:01:28
Awesome! Thanks for fixing those to keep the DCHEC
|
| + RenderFrameHost* render_frame_host = |
| + navigation_handle->GetRenderFrameHost(); |
| + 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); |
| + } |
| + } |
| +} |
| + |
| +void HostZoomMapObserver::RenderFrameCreated(RenderFrameHost* rfh) { |
| + rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom_); |
| +} |
| + |
| +} // namespace content |