| 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 10 matching lines...) Expand all Loading... |
| 21 | 21 |
| 22 class WebContentsImpl; | 22 class WebContentsImpl; |
| 23 | 23 |
| 24 // HostZoomMap needs to be deleted on the UI thread because it listens | 24 // HostZoomMap needs to be deleted on the UI thread because it listens |
| 25 // to notifications on there (and holds a NotificationRegistrar). | 25 // to notifications on there (and holds a NotificationRegistrar). |
| 26 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), | 26 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), |
| 27 public NotificationObserver, | 27 public NotificationObserver, |
| 28 public base::SupportsUserData::Data { | 28 public base::SupportsUserData::Data { |
| 29 public: | 29 public: |
| 30 HostZoomMapImpl(); | 30 HostZoomMapImpl(); |
| 31 virtual ~HostZoomMapImpl(); | 31 ~HostZoomMapImpl() override; |
| 32 | 32 |
| 33 // HostZoomMap implementation: | 33 // HostZoomMap implementation: |
| 34 virtual void CopyFrom(HostZoomMap* copy) override; | 34 void CopyFrom(HostZoomMap* copy) override; |
| 35 virtual double GetZoomLevelForHostAndScheme( | 35 double GetZoomLevelForHostAndScheme(const std::string& scheme, |
| 36 const std::string& scheme, | 36 const std::string& host) const override; |
| 37 const std::string& host) const override; | |
| 38 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 | 37 // TODO(wjmaclean) Should we use a GURL here? crbug.com/384486 |
| 39 virtual bool HasZoomLevel(const std::string& scheme, | 38 bool HasZoomLevel(const std::string& scheme, |
| 40 const std::string& host) const override; | 39 const std::string& host) const override; |
| 41 virtual ZoomLevelVector GetAllZoomLevels() const override; | 40 ZoomLevelVector GetAllZoomLevels() const override; |
| 42 virtual void SetZoomLevelForHost( | 41 void SetZoomLevelForHost(const std::string& host, double level) override; |
| 43 const std::string& host, | 42 void SetZoomLevelForHostAndScheme(const std::string& scheme, |
| 44 double level) override; | 43 const std::string& host, |
| 45 virtual void SetZoomLevelForHostAndScheme( | 44 double level) override; |
| 46 const std::string& scheme, | 45 bool UsesTemporaryZoomLevel(int render_process_id, |
| 47 const std::string& host, | 46 int render_view_id) const override; |
| 48 double level) override; | 47 void SetTemporaryZoomLevel(int render_process_id, |
| 49 virtual bool UsesTemporaryZoomLevel(int render_process_id, | 48 int render_view_id, |
| 50 int render_view_id) const override; | 49 double level) override; |
| 51 virtual void SetTemporaryZoomLevel(int render_process_id, | |
| 52 int render_view_id, | |
| 53 double level) override; | |
| 54 | 50 |
| 55 virtual void ClearTemporaryZoomLevel(int render_process_id, | 51 void ClearTemporaryZoomLevel(int render_process_id, |
| 56 int render_view_id) override; | 52 int render_view_id) override; |
| 57 virtual double GetDefaultZoomLevel() const override; | 53 double GetDefaultZoomLevel() const override; |
| 58 virtual void SetDefaultZoomLevel(double level) override; | 54 void SetDefaultZoomLevel(double level) override; |
| 59 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 55 scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
| 60 const ZoomLevelChangedCallback& callback) override; | 56 const ZoomLevelChangedCallback& callback) override; |
| 61 | 57 |
| 62 // Returns the current zoom level for the specified WebContents. This may | 58 // Returns the current zoom level for the specified WebContents. This may |
| 63 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). | 59 // be a temporary zoom level, depending on UsesTemporaryZoomLevel(). |
| 64 double GetZoomLevelForWebContents( | 60 double GetZoomLevelForWebContents( |
| 65 const WebContentsImpl& web_contents_impl) const; | 61 const WebContentsImpl& web_contents_impl) const; |
| 66 | 62 |
| 67 // Sets the zoom level for this WebContents. If this WebContents is using | 63 // Sets the zoom level for this WebContents. If this WebContents is using |
| 68 // a temporary zoom level, then level is only applied to this WebContents. | 64 // a temporary zoom level, then level is only applied to this WebContents. |
| 69 // Otherwise, the level will be applied on a host level. | 65 // Otherwise, the level will be applied on a host level. |
| 70 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, | 66 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl, |
| 71 double level); | 67 double level); |
| 72 | 68 |
| 73 // Sets the zoom level for the specified view. The level may be set for only | 69 // Sets the zoom level for the specified view. The level may be set for only |
| 74 // this view, or for the host, depending on UsesTemporaryZoomLevel(). | 70 // this view, or for the host, depending on UsesTemporaryZoomLevel(). |
| 75 void SetZoomLevelForView(int render_process_id, | 71 void SetZoomLevelForView(int render_process_id, |
| 76 int render_view_id, | 72 int render_view_id, |
| 77 double level, | 73 double level, |
| 78 const std::string& host); | 74 const std::string& host); |
| 79 | 75 |
| 80 // Returns the temporary zoom level that's only valid for the lifetime of | 76 // 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 | 77 // the given WebContents (i.e. isn't saved and doesn't affect other |
| 82 // WebContentses) if it exists, the default zoom level otherwise. | 78 // WebContentses) if it exists, the default zoom level otherwise. |
| 83 // | 79 // |
| 84 // This may be called on any thread. | 80 // This may be called on any thread. |
| 85 double GetTemporaryZoomLevel(int render_process_id, | 81 double GetTemporaryZoomLevel(int render_process_id, |
| 86 int render_view_id) const; | 82 int render_view_id) const; |
| 87 | 83 |
| 88 // NotificationObserver implementation. | 84 // NotificationObserver implementation. |
| 89 virtual void Observe(int type, | 85 void Observe(int type, |
| 90 const NotificationSource& source, | 86 const NotificationSource& source, |
| 91 const NotificationDetails& details) override; | 87 const NotificationDetails& details) override; |
| 92 | 88 |
| 93 private: | 89 private: |
| 94 typedef std::map<std::string, double> HostZoomLevels; | 90 typedef std::map<std::string, double> HostZoomLevels; |
| 95 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; | 91 typedef std::map<std::string, HostZoomLevels> SchemeHostZoomLevels; |
| 96 | 92 |
| 97 struct RenderViewKey { | 93 struct RenderViewKey { |
| 98 int render_process_id; | 94 int render_process_id; |
| 99 int render_view_id; | 95 int render_view_id; |
| 100 RenderViewKey(int render_process_id, int render_view_id) | 96 RenderViewKey(int render_process_id, int render_view_id) |
| 101 : render_process_id(render_process_id), | 97 : render_process_id(render_process_id), |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 mutable base::Lock lock_; | 132 mutable base::Lock lock_; |
| 137 | 133 |
| 138 NotificationRegistrar registrar_; | 134 NotificationRegistrar registrar_; |
| 139 | 135 |
| 140 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); | 136 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); |
| 141 }; | 137 }; |
| 142 | 138 |
| 143 } // namespace content | 139 } // namespace content |
| 144 | 140 |
| 145 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ | 141 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ |
| OLD | NEW |