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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
72 const std::string& host); | 72 const std::string& host); |
73 | 73 |
74 // Returns the temporary zoom level that's only valid for the lifetime of | 74 // Returns the temporary zoom level that's only valid for the lifetime of |
75 // the given WebContents (i.e. isn't saved and doesn't affect other | 75 // the given WebContents (i.e. isn't saved and doesn't affect other |
76 // WebContentses) if it exists, the default zoom level otherwise. | 76 // WebContentses) if it exists, the default zoom level otherwise. |
77 // | 77 // |
78 // This may be called on any thread. | 78 // This may be called on any thread. |
79 double GetTemporaryZoomLevel(int render_process_id, | 79 double GetTemporaryZoomLevel(int render_process_id, |
80 int render_view_id) const; | 80 int render_view_id) const; |
81 | 81 |
82 // Returns the zoom level regardless of whether it's temporary, host-keyed or | |
83 // scheme+host-keyed. | |
84 // | |
85 // This may be called on any thread. | |
86 double GetZoomLevelForView(const GURL& url, | |
87 int render_process_id, | |
88 int render_view_id) const; | |
89 | |
82 // NotificationObserver implementation. | 90 // NotificationObserver implementation. |
83 void Observe(int type, | 91 void Observe(int type, |
84 const NotificationSource& source, | 92 const NotificationSource& source, |
85 const NotificationDetails& details) override; | 93 const NotificationDetails& details) override; |
86 | 94 |
87 void SendErrorPageZoomLevelRefresh(); | 95 void SendErrorPageZoomLevelRefresh(); |
88 | 96 |
89 private: | 97 private: |
90 typedef std::map<std::string, double> HostZoomLevels; | 98 typedef std::map<std::string, double> HostZoomLevels; |
91 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; | 99 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; |
92 | 100 |
93 struct RenderViewKey { | 101 struct RenderViewKey { |
94 int render_process_id; | 102 int render_process_id; |
95 int render_view_id; | 103 int render_view_id; |
96 RenderViewKey(int render_process_id, int render_view_id) | 104 RenderViewKey(int render_process_id, int render_view_id) |
97 : render_process_id(render_process_id), | 105 : render_process_id(render_process_id), |
98 render_view_id(render_view_id) {} | 106 render_view_id(render_view_id) {} |
99 bool operator<(const RenderViewKey& other) const { | 107 bool operator<(const RenderViewKey& other) const { |
100 return render_process_id < other.render_process_id || | 108 return render_process_id < other.render_process_id || |
101 ((render_process_id == other.render_process_id) && | 109 ((render_process_id == other.render_process_id) && |
102 (render_view_id < other.render_view_id)); | 110 (render_view_id < other.render_view_id)); |
103 } | 111 } |
104 }; | 112 }; |
105 | 113 |
106 typedef std::map<RenderViewKey, double> TemporaryZoomLevels; | 114 typedef std::map<RenderViewKey, double> TemporaryZoomLevels; |
107 | 115 |
108 double GetZoomLevelForHost(const std::string& host) const; | 116 double GetZoomLevelForHost(const std::string& host) const; |
109 | 117 |
118 // Non-locked version for internal use. This should only be called within | |
119 // a scope where a lock has been acquired. | |
Charlie Reis
2015/02/12 21:51:41
nit: versions
nit: These
wjmaclean
2015/02/13 15:57:53
Done.
| |
120 double GetZoomLevelForHostInternal(const std::string& host) const; | |
121 double GetZoomLevelForHostAndSchemeInternal(const std::string& scheme, | |
122 const std::string& host) const; | |
123 | |
110 // Notifies the renderers from this browser context to change the zoom level | 124 // Notifies the renderers from this browser context to change the zoom level |
111 // for the specified host and scheme. | 125 // for the specified host and scheme. |
112 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 | 126 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 |
113 void SendZoomLevelChange(const std::string& scheme, | 127 void SendZoomLevelChange(const std::string& scheme, |
114 const std::string& host, | 128 const std::string& host, |
115 double level); | 129 double level); |
116 | 130 |
117 // Callbacks called when zoom level changes. | 131 // Callbacks called when zoom level changes. |
118 base::CallbackList<void(const ZoomLevelChange&)> | 132 base::CallbackList<void(const ZoomLevelChange&)> |
119 zoom_level_changed_callbacks_; | 133 zoom_level_changed_callbacks_; |
(...skipping 12 matching lines...) Expand all Loading... | |
132 mutable base::Lock lock_; | 146 mutable base::Lock lock_; |
133 | 147 |
134 NotificationRegistrar registrar_; | 148 NotificationRegistrar registrar_; |
135 | 149 |
136 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 150 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
137 }; | 151 }; |
138 | 152 |
139 } // namespace content | 153 } // namespace content |
140 | 154 |
141 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 155 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
OLD | NEW |