Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "content/browser/host_zoom_map_observer.h" | |
| 6 | |
| 7 #include "content/browser/frame_host/render_frame_host_impl.h" | |
| 8 #include "content/browser/host_zoom_map_impl.h" | |
| 9 #include "content/public/browser/navigation_handle.h" | |
| 10 #include "content/public/browser/render_view_host.h" | |
| 11 #include "content/public/browser/storage_partition.h" | |
| 12 #include "content/public/common/associated_interface_provider.h" | |
| 13 | |
| 14 namespace content { | |
| 15 | |
| 16 HostZoomMapObserver::HostZoomMapObserver(WebContents* web_contents) | |
| 17 : WebContentsObserver(web_contents) {} | |
| 18 | |
| 19 HostZoomMapObserver::~HostZoomMapObserver() {} | |
| 20 | |
| 21 void HostZoomMapObserver::ReadyToCommitNavigation( | |
| 22 NavigationHandle* navigation_handle) { | |
| 23 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.
| |
| 24 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
| |
| 25 RenderFrameHost* render_frame_host = | |
| 26 navigation_handle->GetRenderFrameHost(); | |
| 27 RenderProcessHost* render_process_host = render_frame_host->GetProcess(); | |
| 28 HostZoomMapImpl* host_zoom_map = static_cast<HostZoomMapImpl*>( | |
| 29 render_process_host->GetStoragePartition()->GetHostZoomMap()); | |
| 30 double zoom_level = host_zoom_map->GetZoomLevelForView( | |
| 31 navigation_handle->GetURL(), render_process_host->GetID(), | |
| 32 render_frame_host->GetRenderViewHost()->GetRoutingID()); | |
| 33 host_zoom_->SetHostZoomLevel(navigation_handle->GetURL(), zoom_level); | |
| 34 } | |
| 35 } | |
| 36 } | |
| 37 | |
| 38 void HostZoomMapObserver::RenderFrameCreated(RenderFrameHost* rfh) { | |
| 39 rfh->GetRemoteAssociatedInterfaces()->GetInterface(&host_zoom_); | |
| 40 } | |
| 41 | |
| 42 } // namespace content | |
| OLD | NEW |