Fixes chrome_page_zoom::Zoom(). First, correctly retrieves the default zoom...

Fixes chrome_page_zoom::Zoom(). First, correctly retrieves the default zoom level from the user Profile instead of from RendererPreferences. Second, correctly sets the default zoom level when content::PAGE_ZOOM_RESET is passed as the zoom parameter (previously, it just set the zoom to 100% no matter what the default zoom level was).

BUG=
TBR=jhawkins

Review URL: https://chromiumcodereview.appspot.com/10826136

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@149964 0039d316-1c4b-4281-b951-d872f2087c98
parent a37465e6
......@@ -8,6 +8,9 @@
#include <cmath>
#include "chrome/browser/chrome_page_zoom_constants.h"
#include "chrome/browser/prefs/pref_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/pref_names.h"
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/user_metrics.h"
#include "content/public/browser/web_contents.h"
......@@ -63,16 +66,17 @@ std::vector<double> PresetZoomLevels(double custom_level) {
void Zoom(content::WebContents* web_contents, content::PageZoom zoom) {
content::RenderViewHost* host = web_contents->GetRenderViewHost();
double current_zoom_level = web_contents->GetZoomLevel();
double default_zoom_level =
Profile::FromBrowserContext(web_contents->GetBrowserContext())->
GetPrefs()->GetDouble(prefs::kDefaultZoomLevel);
if (zoom == content::PAGE_ZOOM_RESET) {
host->SetZoomLevel(0);
host->SetZoomLevel(default_zoom_level);
content::RecordAction(UserMetricsAction("ZoomNormal"));
return;
}
double current_zoom_level = web_contents->GetZoomLevel();
double default_zoom_level =
web_contents->GetMutableRendererPrefs()->default_zoom_level;
// Generate a vector of zoom levels from an array of known presets along with
// the default level added if necessary.
std::vector<double> zoom_levels = PresetZoomLevels(default_zoom_level);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment