OLD | NEW |
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 Loading... |
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 GetZoomLevel(const std::string& scheme, |
34 virtual void SetZoomLevel(const std::string& host, double level) OVERRIDE; | 34 const std::string& host) const OVERRIDE; |
| 35 virtual void SetZoomLevel(const std::string& scheme, |
| 36 const std::string& host, |
| 37 double level) OVERRIDE; |
35 virtual double GetDefaultZoomLevel() const OVERRIDE; | 38 virtual double GetDefaultZoomLevel() const OVERRIDE; |
36 virtual void SetDefaultZoomLevel(double level) OVERRIDE; | 39 virtual void SetDefaultZoomLevel(double level) OVERRIDE; |
37 | 40 |
38 // Returns the temporary zoom level that's only valid for the lifetime of | 41 // Returns the temporary zoom level that's only valid for the lifetime of |
39 // the given WebContents (i.e. isn't saved and doesn't affect other | 42 // the given WebContents (i.e. isn't saved and doesn't affect other |
40 // WebContentses) if it exists, the default zoom level otherwise. | 43 // WebContentses) if it exists, the default zoom level otherwise. |
41 // | 44 // |
42 // This may be called on any thread. | 45 // This may be called on any thread. |
43 double GetTemporaryZoomLevel(int render_process_id, | 46 double GetTemporaryZoomLevel(int render_process_id, |
44 int render_view_id) const; | 47 int render_view_id) const; |
45 | 48 |
46 // Sets the temporary zoom level that's only valid for the lifetime of this | 49 // Sets the temporary zoom level that's only valid for the lifetime of this |
47 // WebContents. | 50 // WebContents. |
48 // | 51 // |
49 // This should only be called on the UI thread. | 52 // This should only be called on the UI thread. |
50 void SetTemporaryZoomLevel(int render_process_id, | 53 void SetTemporaryZoomLevel(int render_process_id, |
51 int render_view_id, | 54 int render_view_id, |
52 double level); | 55 double level); |
53 | 56 |
54 // NotificationObserver implementation. | 57 // NotificationObserver implementation. |
55 virtual void Observe(int type, | 58 virtual void Observe(int type, |
56 const NotificationSource& source, | 59 const NotificationSource& source, |
57 const NotificationDetails& details) OVERRIDE; | 60 const NotificationDetails& details) OVERRIDE; |
58 | 61 |
59 private: | 62 private: |
60 typedef std::map<std::string, double> HostZoomLevels; | 63 typedef std::map<std::string, double> HostZoomLevels; |
| 64 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; |
61 | 65 |
62 // Copy of the pref data, so that we can read it on the IO thread. | 66 // Copy of the pref data, so that we can read it on the IO thread. |
63 HostZoomLevels host_zoom_levels_; | 67 HostZoomLevels host_zoom_levels_; |
| 68 SchemeHostZoomLevels scheme_host_zoom_levels_; |
64 double default_zoom_level_; | 69 double default_zoom_level_; |
65 | 70 |
66 struct TemporaryZoomLevel { | 71 struct TemporaryZoomLevel { |
67 int render_process_id; | 72 int render_process_id; |
68 int render_view_id; | 73 int render_view_id; |
69 double zoom_level; | 74 double zoom_level; |
70 }; | 75 }; |
71 | 76 |
72 // Don't expect more than a couple of tabs that are using a temporary zoom | 77 // Don't expect more than a couple of tabs that are using a temporary zoom |
73 // level, so vector is fine for now. | 78 // level, so vector is fine for now. |
74 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; | 79 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; |
75 | 80 |
76 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and | 81 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and |
77 // |temporary_zoom_levels_| to guarantee thread safety. | 82 // |temporary_zoom_levels_| to guarantee thread safety. |
78 mutable base::Lock lock_; | 83 mutable base::Lock lock_; |
79 | 84 |
80 NotificationRegistrar registrar_; | 85 NotificationRegistrar registrar_; |
81 | 86 |
82 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 87 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
83 }; | 88 }; |
84 | 89 |
85 } // namespace content | 90 } // namespace content |
86 | 91 |
87 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 92 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
OLD | NEW |