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