diff options
author | wjmaclean <wjmaclean@chromium.org> | 2015-03-31 09:07:59 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-03-31 16:08:39 +0000 |
commit | bd73117907c7f1d317f1b71a61e98dc686d0b0fc (patch) | |
tree | 615d887ba2e24e3a0eb4c05cbc86615f56c47b13 /components/ui/zoom/zoom_controller.cc | |
parent | 4297182e07d0cdf72b3d3255e6e473c6094ff7d2 (diff) | |
download | chromium_src-bd73117907c7f1d317f1b71a61e98dc686d0b0fc.zip chromium_src-bd73117907c7f1d317f1b71a61e98dc686d0b0fc.tar.gz chromium_src-bd73117907c7f1d317f1b71a61e98dc686d0b0fc.tar.bz2 |
Provide simple, safe & reliable way to get zoom level for WebContents*.
Not all WebContents have zoom controllers, and the possessor of a
WebContents* should be able to simply and reliably find the current
zoom level for it.
BUG=471241
Review URL: https://codereview.chromium.org/1048123002
Cr-Commit-Position: refs/heads/master@{#323048}
Diffstat (limited to 'components/ui/zoom/zoom_controller.cc')
-rw-r--r-- | components/ui/zoom/zoom_controller.cc | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/components/ui/zoom/zoom_controller.cc b/components/ui/zoom/zoom_controller.cc index a56aaa9..14a5700 100644 --- a/components/ui/zoom/zoom_controller.cc +++ b/components/ui/zoom/zoom_controller.cc @@ -20,6 +20,18 @@ DEFINE_WEB_CONTENTS_USER_DATA_KEY(ui_zoom::ZoomController); namespace ui_zoom { +double ZoomController::GetZoomLevelForWebContents( + const content::WebContents* web_contents) { + if (!web_contents) + return 0.0; + + auto zoom_controller = FromWebContents(web_contents); + if (zoom_controller) + return zoom_controller->GetZoomLevel(); + + return content::HostZoomMap::GetZoomLevel(web_contents); +} + ZoomController::ZoomController(content::WebContents* web_contents) : content::WebContentsObserver(web_contents), can_show_bubble_(true), |