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

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

Issue 302603012: Zoom Extension API (content changes) (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove exceptions from IPC. Created 6 years, 6 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 17 matching lines...) Expand all
28 public base::SupportsUserData::Data { 28 public base::SupportsUserData::Data {
29 public: 29 public:
30 HostZoomMapImpl(); 30 HostZoomMapImpl();
31 virtual ~HostZoomMapImpl(); 31 virtual ~HostZoomMapImpl();
32 32
33 // HostZoomMap implementation: 33 // HostZoomMap implementation:
34 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; 34 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE;
35 virtual double GetZoomLevelForHostAndScheme( 35 virtual double GetZoomLevelForHostAndScheme(
36 const std::string& scheme, 36 const std::string& scheme,
37 const std::string& host) const OVERRIDE; 37 const std::string& host) const OVERRIDE;
38 virtual bool HasZoomLevel(const std::string& scheme,
39 const std::string& host) const OVERRIDE;
38 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE; 40 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE;
39 virtual void SetZoomLevelForHost( 41 virtual void SetZoomLevelForHost(
40 const std::string& host, 42 const std::string& host,
41 double level) OVERRIDE; 43 double level) OVERRIDE;
42 virtual void SetZoomLevelForHostAndScheme( 44 virtual void SetZoomLevelForHostAndScheme(
43 const std::string& scheme, 45 const std::string& scheme,
44 const std::string& host, 46 const std::string& host,
45 double level) OVERRIDE; 47 double level) OVERRIDE;
48 virtual bool UsesTemporaryZoomLevel(int render_process_id,
49 int render_view_id) const OVERRIDE;
50 virtual void SetTemporaryZoomLevel(int render_process_id,
Fady Samuel 2014/06/10 20:05:13 Alphabetize.
wjmaclean 2014/06/10 20:18:54 Everything, or just the newly added stuff?
51 int render_view_id,
52 double level) OVERRIDE;
53 virtual void SendTemporaryZoomLevelChange(int render_process_id,
54 int render_view_id) const OVERRIDE;
55
56 virtual void ClearTemporaryZoomLevel(int render_process_id,
57 int render_view_id) OVERRIDE;
46 virtual double GetDefaultZoomLevel() const OVERRIDE; 58 virtual double GetDefaultZoomLevel() const OVERRIDE;
47 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 59 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
48 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( 60 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback(
49 const ZoomLevelChangedCallback& callback) OVERRIDE; 61 const ZoomLevelChangedCallback& callback) OVERRIDE;
50 62
51 // Returns the current zoom level for the specified WebContents. This may 63 // Returns the current zoom level for the specified WebContents. This may
52 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). 64 // be a temporary zoom level, depending on UsesTemporaryZoomLevel().
53 double GetZoomLevelForWebContents( 65 double GetZoomLevelForWebContents(
54 const WebContentsImpl& web_contents_impl) const; 66 const WebContentsImpl& web_contents_impl) const;
55 67
56 // Sets the zoom level for this WebContents. If this WebContents is using 68 // Sets the zoom level for this WebContents. If this WebContents is using
57 // a temporary zoom level, then level is only applied to this WebContents. 69 // a temporary zoom level, then level is only applied to this WebContents.
58 // Otherwise, the level will be applied on a host level. 70 // Otherwise, the level will be applied on a host level.
59 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, 71 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl,
60 double level); 72 double level);
61 73
62 // Sets the zoom level for the specified view. The level may be set for only 74 // Sets the zoom level for the specified view. The level may be set for only
63 // this view, or for the host, depending on UsesTemporaryZoomLevel(). 75 // this view, or for the host, depending on UsesTemporaryZoomLevel().
64 void SetZoomLevelForView(int render_process_id, 76 void SetZoomLevelForView(int render_process_id,
65 int render_view_id, 77 int render_view_id,
66 double level, 78 double level,
67 const std::string& host); 79 const std::string& host);
68 80
69 // Returns whether the view manages its zoom level independently of other tabs
70 // displaying content from the same host.
71 bool UsesTemporaryZoomLevel(int render_process_id, int render_view_id) const;
72 81
73 // Sets whether the view manages its zoom level independently of other tabs 82 // Sets whether the view manages its zoom level independently of other tabs
74 // displaying content from the same host, based on whether 83 // displaying content from the same host, based on whether
75 // |uses_temporary_zoom_level| is true. 84 // |uses_temporary_zoom_level| is true.
76 void SetUsesTemporaryZoomLevel(int render_process_id, 85 void SetUsesTemporaryZoomLevel(int render_process_id,
77 int render_view_id, 86 int render_view_id,
78 bool uses_temporary_zoom_level); 87 bool uses_temporary_zoom_level);
79 88
80 // Returns the temporary zoom level that's only valid for the lifetime of 89 // Returns the temporary zoom level that's only valid for the lifetime of
81 // the given WebContents (i.e. isn't saved and doesn't affect other 90 // the given WebContents (i.e. isn't saved and doesn't affect other
82 // WebContentses) if it exists, the default zoom level otherwise. 91 // WebContentses) if it exists, the default zoom level otherwise.
83 // 92 //
84 // This may be called on any thread. 93 // This may be called on any thread.
85 double GetTemporaryZoomLevel(int render_process_id, 94 double GetTemporaryZoomLevel(int render_process_id,
86 int render_view_id) const; 95 int render_view_id) const;
87 96
88 // Sets the temporary zoom level that's only valid for the lifetime of this
89 // WebContents.
90 //
91 // This should only be called on the UI thread.
92 void SetTemporaryZoomLevel(int render_process_id,
93 int render_view_id,
94 double level);
95
96 // NotificationObserver implementation. 97 // NotificationObserver implementation.
97 virtual void Observe(int type, 98 virtual void Observe(int type,
98 const NotificationSource& source, 99 const NotificationSource& source,
99 const NotificationDetails& details) OVERRIDE; 100 const NotificationDetails& details) OVERRIDE;
100 101
101 private: 102 private:
102 typedef std::map<std::string, double> HostZoomLevels; 103 typedef std::map<std::string, double> HostZoomLevels;
103 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; 104 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels;
104 105
105 struct TemporaryZoomLevel { 106 struct TemporaryZoomLevel {
106 TemporaryZoomLevel(int process_id, int view_id, double level); 107 TemporaryZoomLevel(int process_id, int view_id, double level);
107 TemporaryZoomLevel(int process_id, int view_id); 108 TemporaryZoomLevel(int process_id, int view_id);
108 bool operator==(const TemporaryZoomLevel& other) const; 109 bool operator==(const TemporaryZoomLevel& other) const;
109 110
110 int render_process_id; 111 int render_process_id;
111 int render_view_id; 112 int render_view_id;
112 double zoom_level; 113 double zoom_level;
113 }; 114 };
114 115
115 typedef std::vector<TemporaryZoomLevel> TemporaryZoomLevels; 116 typedef std::vector<TemporaryZoomLevel> TemporaryZoomLevels;
116 117
117 double GetZoomLevelForHost(const std::string& host) const; 118 double GetZoomLevelForHost(const std::string& host) const;
118 119
120 // Notifies the renderers from this browser context to change the zoom level
121 // for the specified host and scheme.
122 void SendZoomLevelChange(const std::string& scheme,
123 const std::string& host,
124 double level);
125
119 // Callbacks called when zoom level changes. 126 // Callbacks called when zoom level changes.
120 base::CallbackList<void(const ZoomLevelChange&)> 127 base::CallbackList<void(const ZoomLevelChange&)>
121 zoom_level_changed_callbacks_; 128 zoom_level_changed_callbacks_;
122 129
123 // Copy of the pref data, so that we can read it on the IO thread. 130 // Copy of the pref data, so that we can read it on the IO thread.
124 HostZoomLevels host_zoom_levels_; 131 HostZoomLevels host_zoom_levels_;
125 SchemeHostZoomLevels scheme_host_zoom_levels_; 132 SchemeHostZoomLevels scheme_host_zoom_levels_;
126 double default_zoom_level_; 133 double default_zoom_level_;
127 134
128 // 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
129 // level, so vector is fine for now. 136 // level, so vector is fine for now.
130 TemporaryZoomLevels temporary_zoom_levels_; 137 TemporaryZoomLevels temporary_zoom_levels_;
Fady Samuel 2014/06/10 20:05:13 This is a pretty bad data structure to use as we'r
wjmaclean 2014/06/10 20:18:54 Done.
131 138
132 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 139 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
133 // |temporary_zoom_levels_| to guarantee thread safety. 140 // |temporary_zoom_levels_| to guarantee thread safety.
134 mutable base::Lock lock_; 141 mutable base::Lock lock_;
135 142
136 NotificationRegistrar registrar_; 143 NotificationRegistrar registrar_;
137 144
138 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 145 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
139 }; 146 };
140 147
141 } // namespace content 148 } // namespace content
142 149
143 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 150 #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/host_zoom_map_impl.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698