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

Side by Side Diff: chrome/browser/extensions/api/settings_private/settings_private_delegate.cc

Issue 2409753003: MD Settings: chrome.settingsPrivate, fix rounding error. (Closed)
Patch Set: No diff Created 4 years, 2 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/settings_private/settings_private_delega te.h" 5 #include "chrome/browser/extensions/api/settings_private/settings_private_delega te.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/values.h" 9 #include "base/values.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 } 54 }
55 55
56 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetPref( 56 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetPref(
57 const std::string& pref_name, const base::Value* value) { 57 const std::string& pref_name, const base::Value* value) {
58 return prefs_util_->SetPref(pref_name, value); 58 return prefs_util_->SetPref(pref_name, value);
59 } 59 }
60 60
61 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetDefaultZoomPercent() { 61 std::unique_ptr<base::Value> SettingsPrivateDelegate::GetDefaultZoomPercent() {
62 double zoom = content::ZoomLevelToZoomFactor( 62 double zoom = content::ZoomLevelToZoomFactor(
63 profile_->GetZoomLevelPrefs()->GetDefaultZoomLevelPref()) * 100; 63 profile_->GetZoomLevelPrefs()->GetDefaultZoomLevelPref()) * 100;
64 std::unique_ptr<base::Value> value(new base::FundamentalValue(zoom)); 64 std::unique_ptr<base::Value> value(
65 new base::FundamentalValue(std::round(zoom)));
Dan Beam 2016/10/11 01:38:52 does this work well with 33.33%?
65 return value; 66 return value;
66 } 67 }
67 68
68 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoomPercent( 69 PrefsUtil::SetPrefResult SettingsPrivateDelegate::SetDefaultZoomPercent(
69 int percent) { 70 int percent) {
70 double zoom_factor = content::ZoomFactorToZoomLevel(percent * 0.01); 71 double zoom_factor = content::ZoomFactorToZoomLevel(percent * 0.01);
71 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor); 72 profile_->GetZoomLevelPrefs()->SetDefaultZoomLevelPref(zoom_factor);
72 return PrefsUtil::SetPrefResult::SUCCESS; 73 return PrefsUtil::SetPrefResult::SUCCESS;
73 } 74 }
74 75
75 } // namespace extensions 76 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698