OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
7 | 7 |
8 #include <map> | 8 #include <map> |
9 #include <string> | 9 #include <string> |
10 #include <vector> | 10 #include <vector> |
(...skipping 16 matching lines...) Expand all Loading... |
27 public: | 27 public: |
28 HostZoomMapImpl(); | 28 HostZoomMapImpl(); |
29 virtual ~HostZoomMapImpl(); | 29 virtual ~HostZoomMapImpl(); |
30 | 30 |
31 // HostZoomMap implementation: | 31 // HostZoomMap implementation: |
32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; | 32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; |
33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE; | 33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE; |
34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE; | 34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE; |
35 virtual double GetDefaultZoomLevel() const OVERRIDE; | 35 virtual double GetDefaultZoomLevel() const OVERRIDE; |
36 virtual void SetDefaultZoomLevel(double level) OVERRIDE; | 36 virtual void SetDefaultZoomLevel(double level) OVERRIDE; |
| 37 virtual void AddZoomLevelChangedCallback( |
| 38 ZoomLevelChangedCallback callback) OVERRIDE; |
| 39 virtual void RemoveZoomLevelChangedCallback( |
| 40 ZoomLevelChangedCallback callback) OVERRIDE; |
37 | 41 |
38 // Returns the temporary zoom level that's only valid for the lifetime of | 42 // Returns the temporary zoom level that's only valid for the lifetime of |
39 // the given WebContents (i.e. isn't saved and doesn't affect other | 43 // the given WebContents (i.e. isn't saved and doesn't affect other |
40 // WebContentses) if it exists, the default zoom level otherwise. | 44 // WebContentses) if it exists, the default zoom level otherwise. |
41 // | 45 // |
42 // This may be called on any thread. | 46 // This may be called on any thread. |
43 double GetTemporaryZoomLevel(int render_process_id, | 47 double GetTemporaryZoomLevel(int render_process_id, |
44 int render_view_id) const; | 48 int render_view_id) const; |
45 | 49 |
46 // Sets the temporary zoom level that's only valid for the lifetime of this | 50 // Sets the temporary zoom level that's only valid for the lifetime of this |
47 // WebContents. | 51 // WebContents. |
48 // | 52 // |
49 // This should only be called on the UI thread. | 53 // This should only be called on the UI thread. |
50 void SetTemporaryZoomLevel(int render_process_id, | 54 void SetTemporaryZoomLevel(int render_process_id, |
51 int render_view_id, | 55 int render_view_id, |
52 double level); | 56 double level); |
53 | 57 |
54 // NotificationObserver implementation. | 58 // NotificationObserver implementation. |
55 virtual void Observe(int type, | 59 virtual void Observe(int type, |
56 const NotificationSource& source, | 60 const NotificationSource& source, |
57 const NotificationDetails& details) OVERRIDE; | 61 const NotificationDetails& details) OVERRIDE; |
58 | 62 |
59 private: | 63 private: |
60 typedef std::map<std::string, double> HostZoomLevels; | 64 typedef std::map<std::string, double> HostZoomLevels; |
61 | 65 |
| 66 // Callbacks called when zoom level changes. |
| 67 std::vector<ZoomLevelChangedCallback> zoom_level_changed_callbacks_; |
| 68 |
62 // Copy of the pref data, so that we can read it on the IO thread. | 69 // Copy of the pref data, so that we can read it on the IO thread. |
63 HostZoomLevels host_zoom_levels_; | 70 HostZoomLevels host_zoom_levels_; |
64 double default_zoom_level_; | 71 double default_zoom_level_; |
65 | 72 |
66 struct TemporaryZoomLevel { | 73 struct TemporaryZoomLevel { |
67 int render_process_id; | 74 int render_process_id; |
68 int render_view_id; | 75 int render_view_id; |
69 double zoom_level; | 76 double zoom_level; |
70 }; | 77 }; |
71 | 78 |
72 // Don't expect more than a couple of tabs that are using a temporary zoom | 79 // Don't expect more than a couple of tabs that are using a temporary zoom |
73 // level, so vector is fine for now. | 80 // level, so vector is fine for now. |
74 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; | 81 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; |
75 | 82 |
76 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and | 83 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and |
77 // |temporary_zoom_levels_| to guarantee thread safety. | 84 // |temporary_zoom_levels_| to guarantee thread safety. |
78 mutable base::Lock lock_; | 85 mutable base::Lock lock_; |
79 | 86 |
80 NotificationRegistrar registrar_; | 87 NotificationRegistrar registrar_; |
81 | 88 |
82 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 89 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
83 }; | 90 }; |
84 | 91 |
85 } // namespace content | 92 } // namespace content |
86 | 93 |
87 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 94 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
OLD | NEW |