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

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

Issue 23851016: Convert zoom callbacks to use CallbackRegistry (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Pure merge Created 7 years, 2 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
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 24 matching lines...) Expand all
35 const std::string& host) const OVERRIDE; 35 const std::string& host) const OVERRIDE;
36 virtual void SetZoomLevelForHost( 36 virtual void SetZoomLevelForHost(
37 const std::string& host, 37 const std::string& host,
38 double level) OVERRIDE; 38 double level) OVERRIDE;
39 virtual void SetZoomLevelForHostAndScheme( 39 virtual void SetZoomLevelForHostAndScheme(
40 const std::string& scheme, 40 const std::string& scheme,
41 const std::string& host, 41 const std::string& host,
42 double level) OVERRIDE; 42 double level) OVERRIDE;
43 virtual double GetDefaultZoomLevel() const OVERRIDE; 43 virtual double GetDefaultZoomLevel() const OVERRIDE;
44 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 44 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
45 virtual void AddZoomLevelChangedCallback( 45 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback(
46 const ZoomLevelChangedCallback& callback) OVERRIDE;
47 virtual void RemoveZoomLevelChangedCallback(
48 const ZoomLevelChangedCallback& callback) OVERRIDE; 46 const ZoomLevelChangedCallback& callback) OVERRIDE;
49 47
50 // Returns the temporary zoom level that's only valid for the lifetime of 48 // Returns the temporary zoom level that's only valid for the lifetime of
51 // the given WebContents (i.e. isn't saved and doesn't affect other 49 // the given WebContents (i.e. isn't saved and doesn't affect other
52 // WebContentses) if it exists, the default zoom level otherwise. 50 // WebContentses) if it exists, the default zoom level otherwise.
53 // 51 //
54 // This may be called on any thread. 52 // This may be called on any thread.
55 double GetTemporaryZoomLevel(int render_process_id, 53 double GetTemporaryZoomLevel(int render_process_id,
56 int render_view_id) const; 54 int render_view_id) const;
57 55
(...skipping 10 matching lines...) Expand all
68 const NotificationSource& source, 66 const NotificationSource& source,
69 const NotificationDetails& details) OVERRIDE; 67 const NotificationDetails& details) OVERRIDE;
70 68
71 private: 69 private:
72 double GetZoomLevelForHost(const std::string& host) const; 70 double GetZoomLevelForHost(const std::string& host) const;
73 71
74 typedef std::map<std::string, double> HostZoomLevels; 72 typedef std::map<std::string, double> HostZoomLevels;
75 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; 73 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels;
76 74
77 // Callbacks called when zoom level changes. 75 // Callbacks called when zoom level changes.
78 std::vector<ZoomLevelChangedCallback> zoom_level_changed_callbacks_; 76 base::CallbackList<void(const ZoomLevelChange&)>
77 zoom_level_changed_callbacks_;
79 78
80 // Copy of the pref data, so that we can read it on the IO thread. 79 // Copy of the pref data, so that we can read it on the IO thread.
81 HostZoomLevels host_zoom_levels_; 80 HostZoomLevels host_zoom_levels_;
82 SchemeHostZoomLevels scheme_host_zoom_levels_; 81 SchemeHostZoomLevels scheme_host_zoom_levels_;
83 double default_zoom_level_; 82 double default_zoom_level_;
84 83
85 struct TemporaryZoomLevel { 84 struct TemporaryZoomLevel {
86 int render_process_id; 85 int render_process_id;
87 int render_view_id; 86 int render_view_id;
88 double zoom_level; 87 double zoom_level;
89 }; 88 };
90 89
91 // Don't expect more than a couple of tabs that are using a temporary zoom 90 // Don't expect more than a couple of tabs that are using a temporary zoom
92 // level, so vector is fine for now. 91 // level, so vector is fine for now.
93 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 92 std::vector<TemporaryZoomLevel> temporary_zoom_levels_;
94 93
95 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 94 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
96 // |temporary_zoom_levels_| to guarantee thread safety. 95 // |temporary_zoom_levels_| to guarantee thread safety.
97 mutable base::Lock lock_; 96 mutable base::Lock lock_;
98 97
99 NotificationRegistrar registrar_; 98 NotificationRegistrar registrar_;
100 99
101 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 100 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
102 }; 101 };
103 102
104 } // namespace content 103 } // namespace content
105 104
106 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 105 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW
« no previous file with comments | « chrome/browser/ui/zoom/zoom_controller.cc ('k') | content/browser/host_zoom_map_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698