OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #include "chrome/browser/accessibility/font_size_prefs.h" | |
6 | |
7 #include "base/observer_list.h" | |
8 #include "base/prefs/pref_change_registrar.h" | |
9 #include "base/prefs/pref_service.h" | |
10 #include "base/values.h" | |
11 #include "chrome/browser/profiles/profile.h" | |
12 #include "chrome/common/pref_names.h" | |
13 | |
14 FontSizePrefs::FontSizePrefs(Profile* profile) { | |
15 pref_service_ = profile->GetPrefs(); | |
16 pref_change_registrar_.reset(new PrefChangeRegistrar); | |
17 pref_change_registrar_->Init(pref_service_); | |
18 pref_change_registrar_->Add( | |
19 prefs::kWebKitFontScaleFactor, | |
20 base::Bind(&FontSizePrefs::OnFontScaleFactorPrefsChanged, | |
21 base::Unretained(this))); | |
22 pref_change_registrar_->Add( | |
23 prefs::kWebKitForceEnableZoom, | |
24 base::Bind(&FontSizePrefs::OnForceEnableZoomPrefsChanged, | |
25 base::Unretained(this))); | |
26 } | |
27 | |
28 FontSizePrefs::~FontSizePrefs() { | |
29 } | |
30 | |
31 void FontSizePrefs::Destroy() { | |
32 delete this; | |
33 } | |
34 | |
35 void FontSizePrefs::SetFontScaleFactor(float font) { | |
36 pref_service_->SetDouble(prefs::kWebKitFontScaleFactor, | |
37 static_cast<double>(font)); | |
38 } | |
39 | |
40 float FontSizePrefs::GetFontScaleFactor() { | |
41 return pref_service_->GetDouble(prefs::kWebKitFontScaleFactor); | |
42 } | |
43 | |
44 void FontSizePrefs::OnFontScaleFactorPrefsChanged() { | |
robliao
2014/07/25 23:49:34
Follow same order as header file.
sunangel
2014/07/28 21:17:20
Done.
| |
45 FOR_EACH_OBSERVER( | |
46 Observer, observers_, OnChangeFontSize(GetFontScaleFactor())); | |
47 } | |
48 | |
49 void FontSizePrefs::AddObserver(Observer* obs) { | |
50 observers_.AddObserver(obs); | |
51 } | |
52 | |
53 void FontSizePrefs::RemoveObserver(Observer* obs) { | |
54 observers_.RemoveObserver(obs); | |
55 } | |
56 | |
57 void FontSizePrefs::SetForceEnableZoom(bool enabled) { | |
58 pref_service_->SetBoolean(prefs::kWebKitForceEnableZoom, enabled); | |
59 } | |
60 | |
61 bool FontSizePrefs::GetForceEnableZoom() { | |
62 return pref_service_->GetBoolean(prefs::kWebKitForceEnableZoom); | |
63 } | |
64 | |
65 void FontSizePrefs::OnForceEnableZoomPrefsChanged() { | |
66 FOR_EACH_OBSERVER( | |
67 Observer, observers_, OnChangeForceEnableZoom(GetForceEnableZoom())); | |
68 } | |
OLD | NEW |