OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" | 5 #include "chrome/browser/extensions/api/tabs/tabs_api.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 #include <limits> | 8 #include <limits> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 1836 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1847 WebContents* web_contents = GetWebContents(tab_id); | 1847 WebContents* web_contents = GetWebContents(tab_id); |
1848 if (!web_contents) | 1848 if (!web_contents) |
1849 return false; | 1849 return false; |
1850 | 1850 |
1851 GURL url(web_contents->GetVisibleURL()); | 1851 GURL url(web_contents->GetVisibleURL()); |
1852 if (PermissionsData::IsRestrictedUrl(url, url, extension(), &error_)) | 1852 if (PermissionsData::IsRestrictedUrl(url, url, extension(), &error_)) |
1853 return false; | 1853 return false; |
1854 | 1854 |
1855 ZoomController* zoom_controller = | 1855 ZoomController* zoom_controller = |
1856 ZoomController::FromWebContents(web_contents); | 1856 ZoomController::FromWebContents(web_contents); |
1857 double zoom_level = content::ZoomFactorToZoomLevel(params->zoom_factor); | 1857 double zoom_level = params->zoom_factor > 0 |
1858 ? content::ZoomFactorToZoomLevel(params->zoom_factor) | |
1859 : zoom_controller->GetDefaultZoomLevel(); | |
1858 | 1860 |
1859 scoped_refptr<ExtensionZoomRequestClient> client( | 1861 scoped_refptr<ExtensionZoomRequestClient> client( |
1860 new ExtensionZoomRequestClient(extension())); | 1862 new ExtensionZoomRequestClient(extension())); |
1861 if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) { | 1863 if (!zoom_controller->SetZoomLevelByClient(zoom_level, client)) { |
1862 // Tried to zoom a tab in disabled mode. | 1864 // Tried to zoom a tab in disabled mode. |
1863 error_ = keys::kCannotZoomDisabledTabError; | 1865 error_ = keys::kCannotZoomDisabledTabError; |
1864 return false; | 1866 return false; |
1865 } | 1867 } |
1866 | 1868 |
1867 SendResponse(true); | 1869 SendResponse(true); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1946 int tab_id = params->tab_id ? *params->tab_id : -1; | 1948 int tab_id = params->tab_id ? *params->tab_id : -1; |
1947 WebContents* web_contents = GetWebContents(tab_id); | 1949 WebContents* web_contents = GetWebContents(tab_id); |
1948 if (!web_contents) | 1950 if (!web_contents) |
1949 return false; | 1951 return false; |
1950 ZoomController* zoom_controller = | 1952 ZoomController* zoom_controller = |
1951 ZoomController::FromWebContents(web_contents); | 1953 ZoomController::FromWebContents(web_contents); |
1952 | 1954 |
1953 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); | 1955 ZoomController::ZoomMode zoom_mode = zoom_controller->zoom_mode(); |
1954 api::tabs::ZoomSettings zoom_settings; | 1956 api::tabs::ZoomSettings zoom_settings; |
1955 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); | 1957 ZoomModeToZoomSettings(zoom_mode, &zoom_settings); |
1958 zoom_settings.default_zoom_factor.reset(new double); | |
1959 *zoom_settings.default_zoom_factor = | |
1960 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel()); | |
not at google - send to devlin
2015/04/01 20:34:07
Simpler to write this as just 1 statement:
zoom_s
wjmaclean
2015/04/01 21:23:24
Done.
| |
1956 | 1961 |
1957 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); | 1962 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); |
1958 SendResponse(true); | 1963 SendResponse(true); |
1959 return true; | 1964 return true; |
1960 } | 1965 } |
1961 | 1966 |
1962 } // namespace extensions | 1967 } // namespace extensions |
OLD | NEW |