Chromium Code Reviews| Index: chrome/browser/accessibility/font_size_prefs.cc |
| diff --git a/chrome/browser/accessibility/font_size_prefs.cc b/chrome/browser/accessibility/font_size_prefs.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..fac26f62ab1e24756ca86fc0b60bdd6c6018df84 |
| --- /dev/null |
| +++ b/chrome/browser/accessibility/font_size_prefs.cc |
| @@ -0,0 +1,68 @@ |
| +// Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/accessibility/font_size_prefs.h" |
| + |
| +#include "base/observer_list.h" |
| +#include "base/prefs/pref_change_registrar.h" |
| +#include "base/prefs/pref_service.h" |
| +#include "base/values.h" |
| +#include "chrome/browser/profiles/profile.h" |
| +#include "chrome/common/pref_names.h" |
| + |
| +FontSizePrefs::FontSizePrefs(Profile* profile) { |
| + pref_service_ = profile->GetPrefs(); |
| + pref_change_registrar_.reset(new PrefChangeRegistrar); |
| + pref_change_registrar_->Init(pref_service_); |
| + pref_change_registrar_->Add( |
| + prefs::kWebKitFontScaleFactor, |
| + base::Bind(&FontSizePrefs::OnFontScaleFactorPrefsChanged, |
| + base::Unretained(this))); |
| + pref_change_registrar_->Add( |
| + prefs::kWebKitForceEnableZoom, |
| + base::Bind(&FontSizePrefs::OnForceEnableZoomPrefsChanged, |
| + base::Unretained(this))); |
| +} |
| + |
| +FontSizePrefs::~FontSizePrefs() { |
| +} |
| + |
| +void FontSizePrefs::Destroy() { |
| + delete this; |
| +} |
| + |
| +void FontSizePrefs::SetFontScaleFactor(float font) { |
| + pref_service_->SetDouble(prefs::kWebKitFontScaleFactor, |
| + static_cast<double>(font)); |
| +} |
| + |
| +float FontSizePrefs::GetFontScaleFactor() { |
| + return pref_service_->GetDouble(prefs::kWebKitFontScaleFactor); |
| +} |
| + |
| +void FontSizePrefs::OnFontScaleFactorPrefsChanged() { |
|
robliao
2014/07/25 23:49:34
Follow same order as header file.
sunangel
2014/07/28 21:17:20
Done.
|
| + FOR_EACH_OBSERVER( |
| + Observer, observers_, OnChangeFontSize(GetFontScaleFactor())); |
| +} |
| + |
| +void FontSizePrefs::AddObserver(Observer* obs) { |
| + observers_.AddObserver(obs); |
| +} |
| + |
| +void FontSizePrefs::RemoveObserver(Observer* obs) { |
| + observers_.RemoveObserver(obs); |
| +} |
| + |
| +void FontSizePrefs::SetForceEnableZoom(bool enabled) { |
| + pref_service_->SetBoolean(prefs::kWebKitForceEnableZoom, enabled); |
| +} |
| + |
| +bool FontSizePrefs::GetForceEnableZoom() { |
| + return pref_service_->GetBoolean(prefs::kWebKitForceEnableZoom); |
| +} |
| + |
| +void FontSizePrefs::OnForceEnableZoomPrefsChanged() { |
| + FOR_EACH_OBSERVER( |
| + Observer, observers_, OnChangeForceEnableZoom(GetForceEnableZoom())); |
| +} |