OLD | NEW |
---|---|
(Empty) | |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | |
sky
2014/10/10 19:43:59
nit: style guide says don't use the (c) for new fi
wjmaclean
2014/10/10 20:23:02
Done.
| |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ | |
6 #define CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ | |
7 | |
8 #include "base/callback.h" | |
9 #include "base/files/file_path.h" | |
10 #include "base/macros.h" | |
11 #include "base/memory/ref_counted.h" | |
12 #include "base/observer_list.h" | |
13 #include "base/prefs/json_pref_store.h" | |
14 #include "base/prefs/pref_change_registrar.h" | |
15 #include "base/prefs/pref_service.h" | |
16 #include "base/prefs/pref_store.h" | |
17 #include "content/public/browser/host_zoom_map.h" | |
18 | |
19 namespace base { | |
20 class DictionaryValue; | |
21 } | |
22 | |
23 namespace chrome { | |
24 | |
25 // A class to manage per-partition default and per-host zoom levels in Chrome's | |
26 // preference system. It implements an interface between the content/ zoom | |
27 // levels in HostZoomMap and Chrome's preference persistence system. All changes | |
sky
2014/10/10 19:43:59
nit: preferences imply persistence. I don't think
wjmaclean
2014/10/10 20:23:02
Done.
| |
28 // to the per-partition default zoom levels from chrome/ flow through this | |
29 // class. Any changes to per-host levels are updated when HostZoomMap calls | |
30 // OnZoomLevelChanged. | |
31 class ChromeZoomLevelPrefs { | |
sky
2014/10/10 19:43:59
Is there a reason you don't have a unit test for t
wjmaclean
2014/10/10 20:23:02
Yes, through HostZoomMap browser tests, and any ot
| |
32 public: | |
33 typedef base::CallbackList<void(void)>::Subscription | |
34 DefaultZoomLevelSubscription; | |
35 | |
36 // Exposed as static function for testing. | |
37 static std::string GetHash(const base::FilePath& relative_path); | |
sky
2014/10/10 19:43:59
GetHasForTesting.
sky
2014/10/10 19:43:59
nit: constructor/destructor before any other funct
wjmaclean
2014/10/10 20:23:02
Done. But it's also used internally in the class,
wjmaclean
2014/10/10 20:23:02
Done.
Sorry, I thought static functions went firs
| |
38 | |
39 // Initialize the pref_service and the profile_path via the constructor, | |
40 // as these concepts won't be available in the content base class | |
41 // (to be added later) which will define the InitPrefsAndCopyToHostZoomMap | |
42 // interface. |pref_service_| must outlive this class. | |
43 ChromeZoomLevelPrefs(PrefService* pref_service, | |
44 const base::FilePath& profile_path); | |
45 virtual ~ChromeZoomLevelPrefs(); | |
46 | |
47 virtual void InitPrefsAndCopyToHostZoomMap( | |
48 const base::FilePath& partition_path, | |
49 content::HostZoomMap* host_zoom_map); | |
50 | |
51 void SetDefaultZoomLevelPref(double level); | |
52 double GetDefaultZoomLevelPref() const; | |
53 scoped_ptr<DefaultZoomLevelSubscription> RegisterDefaultZoomLevelCallback( | |
54 const base::Closure& callback); | |
55 | |
56 void ExtractPerHostZoomLevels( | |
57 const base::DictionaryValue* host_zoom_dictionary); | |
58 | |
59 private: | |
60 // This is a callback function that receives notifications from HostZoomMap | |
61 // when per-host zoom levels change. It is used to update the per-host | |
62 // zoom levels (if any) managed by this class (for its associated partition). | |
63 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | |
64 | |
65 PrefService* pref_service_; | |
66 base::FilePath profile_path_; | |
sky
2014/10/10 19:43:59
nit: const.
wjmaclean
2014/10/10 20:23:02
Done.
| |
67 content::HostZoomMap* host_zoom_map_; | |
68 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_; | |
69 std::string partition_key_; | |
70 base::CallbackList<void(void)> default_zoom_changed_callbacks_; | |
71 | |
72 DISALLOW_COPY_AND_ASSIGN(ChromeZoomLevelPrefs); | |
73 }; | |
74 | |
75 } // namespace chrome | |
76 | |
77 #endif // CHROME_BROWSER_UI_ZOOM_CHROME_ZOOM_LEVEL_PREFS_H_ | |
OLD | NEW |