1116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Copyright 2014 The Chromium Authors. All rights reserved.
2116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Use of this source code is governed by a BSD-style license that can be
3116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// found in the LICENSE file.
4116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
5116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#ifndef COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_
6116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_
7116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
8116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/macros.h"
9116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/memory/weak_ptr.h"
10116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "base/observer_list.h"
11116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
12116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PrefService;
13116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
14116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace user_prefs {
15116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass PrefRegistrySyncable;
16116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}
17116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
18116680a4aac90f2aa7413d9095a592090648e557Ben Murdochnamespace dom_distiller {
19116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
20116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch// Interface for preferences used for distilled page.
21116680a4aac90f2aa7413d9095a592090648e557Ben Murdochclass DistilledPagePrefs {
22116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch public:
236e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Possible font families for distilled page.
246e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  enum FontFamily {
256e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#define DEFINE_FONT_FAMILY(name, value) name = value,
266e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#include "components/dom_distiller/core/font_family_list.h"
276e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)#undef DEFINE_FONT_FAMILY
286e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  };
296e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
30116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Possible themes for distilled page.
31116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  enum Theme {
32116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#define DEFINE_THEME(name, value) name = value,
33116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#include "components/dom_distiller/core/theme_list.h"
34116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#undef DEFINE_THEME
35116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  };
36116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
37116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  class Observer {
38116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch   public:
396e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)    virtual void OnChangeFontFamily(FontFamily font) = 0;
40116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch    virtual void OnChangeTheme(Theme theme) = 0;
41116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  };
42116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
43116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  explicit DistilledPagePrefs(PrefService* pref_service);
44116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  ~DistilledPagePrefs();
45116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
46116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  static void RegisterProfilePrefs(user_prefs::PrefRegistrySyncable* registry);
47116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
486e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Sets the user's preference for the font family of distilled pages.
496e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void SetFontFamily(FontFamily new_font);
506e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Returns the user's preference for the font family of distilled pages.
516e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  FontFamily GetFontFamily();
526e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)
53116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Sets the user's preference for the theme of distilled pages.
54116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void SetTheme(Theme new_theme);
55116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Returns the user's preference for the theme of distilled pages.
56116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  Theme GetTheme();
57116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
58116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void AddObserver(Observer* obs);
59116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void RemoveObserver(Observer* obs);
60116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
61116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch private:
626e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  // Notifies all Observers of new font family.
636e8cce623b6e4fe0c9e4af605d675dd9d0338c38Torne (Richard Coles)  void NotifyOnChangeFontFamily(FontFamily font_family);
64116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  // Notifies all Observers of new theme.
65116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  void NotifyOnChangeTheme(Theme theme);
66116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
67116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  PrefService* pref_service_;
68116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  ObserverList<Observer> observers_;
69116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
70116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  base::WeakPtrFactory<DistilledPagePrefs> weak_ptr_factory_;
71116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
72116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch  DISALLOW_COPY_AND_ASSIGN(DistilledPagePrefs);
73116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch};
74116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
75116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch}  // namespace dom_distiller
76116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch
77116680a4aac90f2aa7413d9095a592090648e557Ben Murdoch#endif  // COMPONENTS_DOM_DISTILLER_CORE_DISTILLED_PAGE_PREFS_H_
78