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

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

Issue 11866004: Add scheme to HostZoomMap (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Fix alignment, add comment Created 7 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 12 matching lines...) Expand all
23 // to notifications on there (and holds a NotificationRegistrar). 23 // to notifications on there (and holds a NotificationRegistrar).
24 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), 24 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap),
25 public NotificationObserver, 25 public NotificationObserver,
26 public base::SupportsUserData::Data { 26 public base::SupportsUserData::Data {
27 public: 27 public:
28 HostZoomMapImpl(); 28 HostZoomMapImpl();
29 virtual ~HostZoomMapImpl(); 29 virtual ~HostZoomMapImpl();
30 30
31 // HostZoomMap implementation: 31 // HostZoomMap implementation:
32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; 32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE;
33 virtual double GetZoomLevel(const std::string& host) const OVERRIDE; 33 virtual double GetZoomLevelForHost(const std::string& host) const OVERRIDE;
34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE; 34 virtual double GetZoomLevelForHostAndScheme(
35 const std::string& scheme,
36 const std::string& host) const OVERRIDE;
37 virtual void SetZoomLevelForHost(
38 const std::string& host,
39 double level) OVERRIDE;
40 virtual void SetZoomLevelForHostAndScheme(
41 const std::string& scheme,
42 const std::string& host,
43 double level) OVERRIDE;
35 virtual double GetDefaultZoomLevel() const OVERRIDE; 44 virtual double GetDefaultZoomLevel() const OVERRIDE;
36 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 45 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
37 virtual void AddZoomLevelChangedCallback( 46 virtual void AddZoomLevelChangedCallback(
38 const ZoomLevelChangedCallback& callback) OVERRIDE; 47 const ZoomLevelChangedCallback& callback) OVERRIDE;
39 virtual void RemoveZoomLevelChangedCallback( 48 virtual void RemoveZoomLevelChangedCallback(
40 const ZoomLevelChangedCallback& callback) OVERRIDE; 49 const ZoomLevelChangedCallback& callback) OVERRIDE;
41 50
42 // Returns the temporary zoom level that's only valid for the lifetime of 51 // Returns the temporary zoom level that's only valid for the lifetime of
43 // the given WebContents (i.e. isn't saved and doesn't affect other 52 // the given WebContents (i.e. isn't saved and doesn't affect other
44 // WebContentses) if it exists, the default zoom level otherwise. 53 // WebContentses) if it exists, the default zoom level otherwise.
(...skipping 10 matching lines...) Expand all
55 int render_view_id, 64 int render_view_id,
56 double level); 65 double level);
57 66
58 // NotificationObserver implementation. 67 // NotificationObserver implementation.
59 virtual void Observe(int type, 68 virtual void Observe(int type,
60 const NotificationSource& source, 69 const NotificationSource& source,
61 const NotificationDetails& details) OVERRIDE; 70 const NotificationDetails& details) OVERRIDE;
62 71
63 private: 72 private:
64 typedef std::map<std::string, double> HostZoomLevels; 73 typedef std::map<std::string, double> HostZoomLevels;
74 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels;
65 75
66 // Callbacks called when zoom level changes. 76 // Callbacks called when zoom level changes.
67 std::vector<ZoomLevelChangedCallback> zoom_level_changed_callbacks_; 77 std::vector<ZoomLevelChangedCallback> zoom_level_changed_callbacks_;
68 78
69 // 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.
70 HostZoomLevels host_zoom_levels_; 80 HostZoomLevels host_zoom_levels_;
81 SchemeHostZoomLevels scheme_host_zoom_levels_;
71 double default_zoom_level_; 82 double default_zoom_level_;
72 83
73 struct TemporaryZoomLevel { 84 struct TemporaryZoomLevel {
74 int render_process_id; 85 int render_process_id;
75 int render_view_id; 86 int render_view_id;
76 double zoom_level; 87 double zoom_level;
77 }; 88 };
78 89
79 // 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
80 // level, so vector is fine for now. 91 // level, so vector is fine for now.
81 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 92 std::vector<TemporaryZoomLevel> temporary_zoom_levels_;
82 93
83 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 94 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
84 // |temporary_zoom_levels_| to guarantee thread safety. 95 // |temporary_zoom_levels_| to guarantee thread safety.
85 mutable base::Lock lock_; 96 mutable base::Lock lock_;
86 97
87 NotificationRegistrar registrar_; 98 NotificationRegistrar registrar_;
88 99
89 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 100 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
90 }; 101 };
91 102
92 } // namespace content 103 } // namespace content
93 104
94 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 105 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698