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_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 5 #ifndef CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 6 #define CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_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 // Maps hostnames to custom zoom levels. Written on the UI thread and read on | 23 // Maps hostnames to custom zoom levels. Written on the UI thread and read on |
| 24 // any thread. One instance per browser context. Must be created on the UI | 24 // any thread. One instance per browser context. Must be created on the UI |
| 25 // thread, and it'll delete itself on the UI thread as well. | 25 // thread, and it'll delete itself on the UI thread as well. |
| 26 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom | 26 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom |
| 27 // for host with specific scheme. Setting any of the levels leaves settings | 27 // for host with specific scheme. Setting any of the levels leaves settings |
| 28 // for other settings intact. Getting the zoom level starts at the most | 28 // for other settings intact. Getting the zoom level starts at the most |
| 29 // specific setting and progresses to the less specific: first the zoom for the | 29 // specific setting and progresses to the less specific: first the zoom for the |
| 30 // host and scheme pair is checked, secondly the zoom for the host only and | 30 // host and scheme pair is checked, secondly the zoom for the host only and |
| 31 // lastly default zoom. | 31 // lastly default zoom. |
| 32 | 32 |
| 33 class HostZoomMap { | 33 class HostZoomMap { |
|
Fady Samuel
2014/06/09 15:43:21
I find this name really confusing, especially with
wjmaclean
2014/06/09 17:23:29
I'm OK with that. But, we should then consider the
| |
| 34 public: | 34 public: |
| 35 // Enum that indicates what was the scope of zoom level change. | 35 // Enum that indicates what was the scope of zoom level change. |
| 36 enum ZoomLevelChangeMode { | 36 enum ZoomLevelChangeMode { |
| 37 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host. | 37 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host. |
| 38 ZOOM_CHANGED_FOR_SCHEME_AND_HOST, // Zoom level changed for scheme/host | 38 ZOOM_CHANGED_FOR_SCHEME_AND_HOST, // Zoom level changed for scheme/host |
| 39 // pair. | 39 // pair. |
| 40 ZOOM_CHANGED_TEMPORARY_ZOOM, // Temporary zoom change for specific | 40 ZOOM_CHANGED_TEMPORARY_ZOOM, // Temporary zoom change for specific |
| 41 // renderer, no scheme/host is specified. | 41 // renderer, no scheme/host is specified. |
| 42 }; | 42 }; |
| 43 | 43 |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 71 // Here |host| is the host portion of URL, or (in the absence of a host) | 71 // Here |host| is the host portion of URL, or (in the absence of a host) |
| 72 // the complete spec of the URL. | 72 // the complete spec of the URL. |
| 73 // Returns the zoom for the specified |scheme| and |host|. See class | 73 // Returns the zoom for the specified |scheme| and |host|. See class |
| 74 // description for details. | 74 // description for details. |
| 75 // | 75 // |
| 76 // This may be called on any thread. | 76 // This may be called on any thread. |
| 77 virtual double GetZoomLevelForHostAndScheme( | 77 virtual double GetZoomLevelForHostAndScheme( |
| 78 const std::string& scheme, | 78 const std::string& scheme, |
| 79 const std::string& host) const = 0; | 79 const std::string& host) const = 0; |
| 80 | 80 |
| 81 // Returns true if the specified |scheme| and/or |host| has a zoom level | |
| 82 // currently set. | |
| 83 // | |
| 84 // This may be called on any thread. | |
| 85 virtual bool HasZoomLevelInMap(const std::string& scheme, | |
|
Fady Samuel
2014/06/09 15:43:21
I'm not a fan of calling this thing a map at all a
wjmaclean
2014/06/09 17:23:29
Done.
| |
| 86 const std::string& host) const = 0; | |
| 87 | |
| 81 // Returns all non-temporary zoom levels. Can only be called on any thread. | 88 // Returns all non-temporary zoom levels. Can only be called on any thread. |
| 82 virtual ZoomLevelVector GetAllZoomLevels() const = 0; | 89 virtual ZoomLevelVector GetAllZoomLevels() const = 0; |
| 83 | 90 |
| 84 // Here |host| is the host portion of URL, or (in the absence of a host) | 91 // Here |host| is the host portion of URL, or (in the absence of a host) |
| 85 // the complete spec of the URL. | 92 // the complete spec of the URL. |
| 86 // Sets the zoom level for the |host| to |level|. If the level matches the | 93 // Sets the zoom level for the |host| to |level|. If the level matches the |
| 87 // current default zoom level, the host is erased from the saved preferences; | 94 // current default zoom level, the host is erased from the saved preferences; |
| 88 // otherwise the new value is written out. | 95 // otherwise the new value is written out. |
| 89 // Zoom levels specified for both scheme and host are not affected. | 96 // Zoom levels specified for both scheme and host are not affected. |
| 90 // | 97 // |
| 91 // This should only be called on the UI thread. | 98 // This should only be called on the UI thread. |
| 92 virtual void SetZoomLevelForHost(const std::string& host, double level) = 0; | 99 virtual void SetZoomLevelForHost(const std::string& host, double level) = 0; |
| 93 | 100 |
| 94 // Here |host| is the host portion of URL, or (in the absence of a host) | 101 // Here |host| is the host portion of URL, or (in the absence of a host) |
| 95 // the complete spec of the URL. | 102 // the complete spec of the URL. |
| 96 // Sets the zoom level for the |scheme|/|host| pair to |level|. No values | 103 // Sets the zoom level for the |scheme|/|host| pair to |level|. No values |
| 97 // will be erased during this operation, and this value will not be stored in | 104 // will be erased during this operation, and this value will not be stored in |
| 98 // the preferences. | 105 // the preferences. |
| 99 // | 106 // |
| 100 // This should only be called on the UI thread. | 107 // This should only be called on the UI thread. |
| 101 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme, | 108 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme, |
| 102 const std::string& host, | 109 const std::string& host, |
| 103 double level) = 0; | 110 double level) = 0; |
| 104 | 111 |
| 112 // Sets the temporary zoom level that's only valid for the lifetime of this | |
| 113 // WebContents. | |
| 114 // | |
| 115 // This should only be called on the UI thread. | |
| 116 virtual void SetTemporaryZoomLevel(int render_process_id, | |
| 117 int render_view_id, | |
| 118 const std::string& host, | |
| 119 double level, | |
| 120 bool send_level_to_view) =0; | |
|
Fady Samuel
2014/06/09 15:43:21
This last parameter is really confusing at an API
wjmaclean
2014/06/09 17:23:29
Ok, I can look into separating this.
One consider
wjmaclean
2014/06/10 13:20:09
Done.
| |
| 121 | |
| 122 // Erases the temporary zoom level stored for this WebContents. | |
| 123 // | |
| 124 // This should only be called on the UI thread. | |
| 125 virtual void EraseTemporaryZoomLevel(int render_process_id, | |
|
Fady Samuel
2014/06/09 15:43:21
name: ClearTemporaryZoomLevel
wjmaclean
2014/06/09 17:23:29
Done.
| |
| 126 int render_view_id) = 0; | |
| 127 | |
| 105 // Get/Set the default zoom level for pages that don't override it. | 128 // Get/Set the default zoom level for pages that don't override it. |
| 106 virtual double GetDefaultZoomLevel() const = 0; | 129 virtual double GetDefaultZoomLevel() const = 0; |
| 107 virtual void SetDefaultZoomLevel(double level) = 0;; | 130 virtual void SetDefaultZoomLevel(double level) = 0;; |
| 108 | 131 |
| 109 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback; | 132 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback; |
| 110 typedef base::CallbackList<void(const ZoomLevelChange&)>::Subscription | 133 typedef base::CallbackList<void(const ZoomLevelChange&)>::Subscription |
| 111 Subscription; | 134 Subscription; |
| 112 // Add and remove zoom level changed callbacks. | 135 // Add and remove zoom level changed callbacks. |
| 113 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 136 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
| 114 const ZoomLevelChangedCallback& callback) = 0; | 137 const ZoomLevelChangedCallback& callback) = 0; |
| 115 | 138 |
| 116 protected: | 139 protected: |
| 117 virtual ~HostZoomMap() {} | 140 virtual ~HostZoomMap() {} |
| 118 }; | 141 }; |
| 119 | 142 |
| 120 } // namespace content | 143 } // namespace content |
| 121 | 144 |
| 122 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 145 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
| OLD | NEW |