Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(603)

Side by Side Diff: chrome/browser/extensions/api/tabs/tabs_api.cc

Issue 1051013002: Add default zoom functionality to chrome.tabs Zoom API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments. Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
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 content::ZoomLevelToZoomFactor(zoom_controller->GetDefaultZoomLevel())));
1956 1960
1957 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings); 1961 results_ = api::tabs::GetZoomSettings::Results::Create(zoom_settings);
1958 SendResponse(true); 1962 SendResponse(true);
1959 return true; 1963 return true;
1960 } 1964 }
1961 1965
1962 } // namespace extensions 1966 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/tabs/tabs_test.cc » ('j') | chrome/browser/extensions/api/tabs/tabs_test.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698