Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Side by Side Diff: content/browser/host_zoom_map_impl.h

Issue 809223006: Check temporary zoom status when sending zoom level in navigation. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revise as per comments. Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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
116 // Non-locked version for internal use. This should only be called within
117 // a scope where a lock has been acquired.
118 double GetZoomLevelForHostAndSchemeInternal(const std::string& scheme,
Charlie Reis 2015/02/11 20:56:34 nit: This should be declared in the same order in
wjmaclean 2015/02/12 15:59:36 Done.
119 const std::string& host) const;
108 double GetZoomLevelForHost(const std::string& host) const; 120 double GetZoomLevelForHost(const std::string& host) const;
Charlie Reis 2015/02/11 20:56:34 nit: Put a blank line before this to clarify that
wjmaclean 2015/02/12 15:59:36 Done.
109 121
122 // Non-locked version for internal use. This should only be called within
123 // a scope where a lock has been acquired.
124 double GetZoomLevelForHostInternal(const std::string& host) const;
125
110 // Notifies the renderers from this browser context to change the zoom level 126 // Notifies the renderers from this browser context to change the zoom level
111 // for the specified host and scheme. 127 // for the specified host and scheme.
112 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 128 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486
113 void SendZoomLevelChange(const std::string& scheme, 129 void SendZoomLevelChange(const std::string& scheme,
114 const std::string& host, 130 const std::string& host,
115 double level); 131 double level);
116 132
117 // Callbacks called when zoom level changes. 133 // Callbacks called when zoom level changes.
118 base::CallbackList<void(const ZoomLevelChange&)> 134 base::CallbackList<void(const ZoomLevelChange&)>
119 zoom_level_changed_callbacks_; 135 zoom_level_changed_callbacks_;
(...skipping 12 matching lines...) Expand all
132 mutable base::Lock lock_; 148 mutable base::Lock lock_;
133 149
134 NotificationRegistrar registrar_; 150 NotificationRegistrar registrar_;
135 151
136 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 152 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
137 }; 153 };
138 154
139 } // namespace content 155 } // namespace content
140 156
141 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 157 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW
« no previous file with comments | « no previous file | content/browser/host_zoom_map_impl.cc » ('j') | content/browser/loader/async_resource_handler.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698