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/frame_service_impl.h" |
| 6 |
| 7 #include "content/browser/host_zoom_map_impl.h" |
| 8 #include "content/public/browser/render_process_host.h" |
| 9 #include "content/public/browser/storage_partition.h" |
| 10 #include "mojo/public/cpp/bindings/binding.h" |
| 11 #include "mojo/public/cpp/bindings/interface_request.h" |
| 12 |
| 13 namespace content { |
| 14 |
| 15 FrameServiceImpl::FrameServiceImpl(int render_process_id, |
| 16 int routing_id, |
| 17 mojom::FrameServiceRequest request) |
| 18 : binding_(this, std::move(request)), |
| 19 render_process_id_(render_process_id), |
| 20 routing_id_(routing_id) {} |
| 21 |
| 22 FrameServiceImpl::~FrameServiceImpl() {} |
| 23 |
| 24 // static |
| 25 void FrameServiceImpl::Create(int render_process_id, |
| 26 int routing_id, |
| 27 mojom::FrameServiceRequest request) { |
| 28 new FrameServiceImpl(render_process_id, routing_id, std::move(request)); |
| 29 } |
| 30 |
| 31 void FrameServiceImpl::GetHostZoomLevel( |
| 32 const GURL& url, |
| 33 const GetHostZoomLevelCallback& callback) { |
| 34 RenderProcessHost* render_process_host = |
| 35 RenderProcessHost::FromID(render_process_id_); |
| 36 double zoom_level = 0.0; |
| 37 if (render_process_host) { |
| 38 const HostZoomMapImpl* host_zoom_map = static_cast<const HostZoomMapImpl*>( |
| 39 render_process_host->GetStoragePartition()->GetHostZoomMap()); |
| 40 zoom_level = host_zoom_map->GetZoomLevelForView(url, render_process_id_, |
| 41 routing_id_); |
| 42 } |
| 43 callback.Run(std::move(url), zoom_level); |
| 44 } |
| 45 |
| 46 } // namespace content |
OLD | NEW |