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

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

Issue 287093002: Remove ViewMsg_SetZoomLevel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Re-order functions, add comments and DCHECK(). Created 6 years, 7 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 | Annotate | Revision Log
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 28 matching lines...) Expand all
39 double level) OVERRIDE; 39 double level) OVERRIDE;
40 virtual void SetZoomLevelForHostAndScheme( 40 virtual void SetZoomLevelForHostAndScheme(
41 const std::string& scheme, 41 const std::string& scheme,
42 const std::string& host, 42 const std::string& host,
43 double level) OVERRIDE; 43 double level) OVERRIDE;
44 virtual double GetDefaultZoomLevel() const OVERRIDE; 44 virtual double GetDefaultZoomLevel() const OVERRIDE;
45 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 45 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
46 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( 46 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback(
47 const ZoomLevelChangedCallback& callback) OVERRIDE; 47 const ZoomLevelChangedCallback& callback) OVERRIDE;
48 48
49 // Returns the current zoom level for the specified WebContents. This may
50 // be a temporary zoom level, depending on UsesTemporarySoomLevel().
Peter Kasting 2014/05/28 22:49:58 Nit: Soom -> Zoom
wjmaclean 2014/05/29 14:49:45 Done.
51 double GetZoomLevelForWebContents(
52 const WebContents& web_contents) const;
53
54 // Sets the zoom level for this WebContents. If this WebContents is using
55 // a temporary zoom level, then level is only applied to this WebContents.
56 // Otherwise, the level will be applied on a host level.
57 void SetZoomLevelForWebContents(const WebContents& web_contents,
58 double level);
59
60 // Sets the zoom level for the specified view. The level may be set for only
61 // this view, or for the host, depending on UsesTemporaryZoomLevel().
62 void SetZoomLevelForView(int render_process_id,
63 int render_view_id,
64 double level,
65 const std::string& host);
66
67 // Returns true if the view specified has its zoom level managed separately
68 // from the host specification.
Peter Kasting 2014/05/28 22:49:58 Nit: How about: Returns whether the view manages
wjmaclean 2014/05/29 14:49:45 Sure, sounds good.
69 bool UsesTemporaryZoomLevel(int render_process_id, int render_view_id) const;
70
71 // Causes the view specified to have its zoom level set independently of other
72 // tabs displaying content from the same host, if uses_temporary_zoom_settings
73 // is true.
Peter Kasting 2014/05/28 22:49:58 Nit: How about: Sets whether the view manages its
wjmaclean 2014/05/29 14:49:45 Sure, good wording!
74 void SetUsesTemporaryZoomLevel(int render_process_id,
75 int render_view_id,
76 bool uses_temporary_zoom_settings);
Peter Kasting 2014/05/28 22:49:58 Nit: I'd call this arg "...level" and not "...sett
wjmaclean 2014/05/29 14:49:45 Done.
77
49 // Returns the temporary zoom level that's only valid for the lifetime of 78 // Returns the temporary zoom level that's only valid for the lifetime of
50 // the given WebContents (i.e. isn't saved and doesn't affect other 79 // the given WebContents (i.e. isn't saved and doesn't affect other
51 // WebContentses) if it exists, the default zoom level otherwise. 80 // WebContentses) if it exists, the default zoom level otherwise.
52 // 81 //
53 // This may be called on any thread. 82 // This may be called on any thread.
54 double GetTemporaryZoomLevel(int render_process_id, 83 double GetTemporaryZoomLevel(int render_process_id,
55 int render_view_id) const; 84 int render_view_id) const;
56 85
57 // Sets the temporary zoom level that's only valid for the lifetime of this 86 // Sets the temporary zoom level that's only valid for the lifetime of this
58 // WebContents. 87 // WebContents.
(...skipping 17 matching lines...) Expand all
76 // Callbacks called when zoom level changes. 105 // Callbacks called when zoom level changes.
77 base::CallbackList<void(const ZoomLevelChange&)> 106 base::CallbackList<void(const ZoomLevelChange&)>
78 zoom_level_changed_callbacks_; 107 zoom_level_changed_callbacks_;
79 108
80 // Copy of the pref data, so that we can read it on the IO thread. 109 // Copy of the pref data, so that we can read it on the IO thread.
81 HostZoomLevels host_zoom_levels_; 110 HostZoomLevels host_zoom_levels_;
82 SchemeHostZoomLevels scheme_host_zoom_levels_; 111 SchemeHostZoomLevels scheme_host_zoom_levels_;
83 double default_zoom_level_; 112 double default_zoom_level_;
84 113
85 struct TemporaryZoomLevel { 114 struct TemporaryZoomLevel {
86 int render_process_id; 115 int render_process_id;
Peter Kasting 2014/05/28 22:49:58 Nit: Members below functions
wjmaclean 2014/05/29 14:49:45 Done.
87 int render_view_id; 116 int render_view_id;
88 double zoom_level; 117 double zoom_level;
118
119 TemporaryZoomLevel(int process_id, int view_id, double level)
120 : render_process_id(process_id),
121 render_view_id(view_id),
122 zoom_level(level) {}
Peter Kasting 2014/05/28 22:49:58 Nit: Since you have a .cc file anyway, I'd just mo
wjmaclean 2014/05/29 14:49:45 Done.
123
124 TemporaryZoomLevel(int process_id, int view_id)
125 : render_process_id(process_id),
126 render_view_id(view_id),
127 zoom_level(0.0) {}
128
129 bool operator==(const TemporaryZoomLevel& other) const {
130 return other.render_process_id == render_process_id &&
131 other.render_view_id == render_view_id;
132 }
89 }; 133 };
90 134
91 // Don't expect more than a couple of tabs that are using a temporary zoom 135 // Don't expect more than a couple of tabs that are using a temporary zoom
92 // level, so vector is fine for now. 136 // level, so vector is fine for now.
93 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 137 typedef std::vector<TemporaryZoomLevel> TemporaryZoomLevelList;
Peter Kasting 2014/05/28 22:49:58 Don't put "list" in the name, especially when the
wjmaclean 2014/05/29 14:49:45 Done.
138 TemporaryZoomLevelList temporary_zoom_levels_;
94 139
95 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 140 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
96 // |temporary_zoom_levels_| to guarantee thread safety. 141 // |temporary_zoom_levels_| to guarantee thread safety.
97 mutable base::Lock lock_; 142 mutable base::Lock lock_;
98 143
99 NotificationRegistrar registrar_; 144 NotificationRegistrar registrar_;
100 145
101 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 146 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
102 }; 147 };
103 148
104 } // namespace content 149 } // namespace content
105 150
106 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 151 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698