OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ |
6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ | 6 #define COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ |
7 | 7 |
8 #include "base/macros.h" | 8 #include "base/macros.h" |
9 #include "base/memory/weak_ptr.h" | 9 #include "base/memory/weak_ptr.h" |
10 #include "base/observer_list.h" | 10 #include "base/observer_list.h" |
11 | 11 |
12 class PrefService; | 12 class PrefService; |
13 | 13 |
14 namespace user_prefs { | 14 namespace user_prefs { |
15 class PrefRegistrySyncable; | 15 class PrefRegistrySyncable; |
16 } | 16 } |
17 | 17 |
18 namespace dom_distiller { | 18 namespace dom_distiller { |
19 | 19 |
20 // Interface for preferences used for distilled page. | 20 // Interface for preferences used for distilled page. |
21 class DistilledPagePrefs { | 21 class DistilledPagePrefs { |
22 public: | 22 public: |
| 23 // Possible font families for distilled page. |
| 24 enum FontFamily { |
| 25 #define DEFINE_FONT_FAMILY(name, value) name = value, |
| 26 #include "components/dom_distiller/core/font_family_list.h" |
| 27 #undef DEFINE_FONT_FAMILY |
| 28 }; |
| 29 |
23 // Possible themes for distilled page. | 30 // Possible themes for distilled page. |
24 enum Theme { | 31 enum Theme { |
25 #define DEFINE_THEME(name, value) name = value, | 32 #define DEFINE_THEME(name, value) name = value, |
26 #include "components/dom_distiller/core/theme_list.h" | 33 #include "components/dom_distiller/core/theme_list.h" |
27 #undef DEFINE_THEME | 34 #undef DEFINE_THEME |
28 }; | 35 }; |
29 | 36 |
30 class Observer { | 37 class Observer { |
31 public: | 38 public: |
| 39 virtual void OnChangeFontFamily(FontFamily font) = 0; |
32 virtual void OnChangeTheme(Theme theme) = 0; | 40 virtual void OnChangeTheme(Theme theme) = 0; |
33 }; | 41 }; |
34 | 42 |
35 explicit DistilledPagePrefs(PrefService* pref_service); | 43 explicit DistilledPagePrefs(PrefService* pref_service); |
36 ~DistilledPagePrefs(); | 44 ~DistilledPagePrefs(); |
37 | 45 |
38 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); | 46 static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry); |
39 | 47 |
| 48 // Sets the user's preference for the font family of distilled pages. |
| 49 void SetFontFamily(FontFamily new_font); |
| 50 // Returns the user's preference for the font family of distilled pages. |
| 51 FontFamily GetFontFamily(); |
| 52 |
40 // Sets the user's preference for the theme of distilled pages. | 53 // Sets the user's preference for the theme of distilled pages. |
41 void SetTheme(Theme new_theme); | 54 void SetTheme(Theme new_theme); |
42 // Returns the user's preference for the theme of distilled pages. | 55 // Returns the user's preference for the theme of distilled pages. |
43 Theme GetTheme(); | 56 Theme GetTheme(); |
44 | 57 |
45 void AddObserver(Observer* obs); | 58 void AddObserver(Observer* obs); |
46 void RemoveObserver(Observer* obs); | 59 void RemoveObserver(Observer* obs); |
47 | 60 |
48 private: | 61 private: |
| 62 // Notifies all Observers of new font family. |
| 63 void NotifyOnChangeFontFamily(FontFamily font_family); |
49 // Notifies all Observers of new theme. | 64 // Notifies all Observers of new theme. |
50 void NotifyOnChangeTheme(Theme theme); | 65 void NotifyOnChangeTheme(Theme theme); |
51 | 66 |
52 PrefService* pref_service_; | 67 PrefService* pref_service_; |
53 ObserverList<Observer> observers_; | 68 ObserverList<Observer> observers_; |
54 | 69 |
55 base::WeakPtrFactory<DistilledPagePrefs> weak_ptr_factory_; | 70 base::WeakPtrFactory<DistilledPagePrefs> weak_ptr_factory_; |
56 | 71 |
57 DISALLOW_COPY_AND_ASSIGN(DistilledPagePrefs); | 72 DISALLOW_COPY_AND_ASSIGN(DistilledPagePrefs); |
58 }; | 73 }; |
59 | 74 |
60 } // namespace dom_distiller | 75 } // namespace dom_distiller |
61 | 76 |
62 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ | 77 #endif // COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_ |
OLD | NEW |