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 19 matching lines...) Expand all Loading... |
30 // for host with specific scheme. Setting any of the levels leaves settings | 30 // for host with specific scheme. Setting any of the levels leaves settings |
31 // for other settings intact. Getting the zoom level starts at the most | 31 // for other settings intact. Getting the zoom level starts at the most |
32 // specific setting and progresses to the less specific: first the zoom for the | 32 // specific setting and progresses to the less specific: first the zoom for the |
33 // host and scheme pair is checked, secondly the zoom for the host only and | 33 // host and scheme pair is checked, secondly the zoom for the host only and |
34 // lastly default zoom. | 34 // lastly default zoom. |
35 | 35 |
36 class HostZoomMap { | 36 class HostZoomMap { |
37 public: | 37 public: |
38 // Enum that indicates what was the scope of zoom level change. | 38 // Enum that indicates what was the scope of zoom level change. |
39 enum ZoomLevelChangeMode { | 39 enum ZoomLevelChangeMode { |
40 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host. | 40 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host. |
41 ZOOM_CHANGED_FOR_SCHEME_AND_HOST, // Zoom level changed for scheme/host | 41 ZOOM_CHANGED_FOR_SCHEME_AND_HOST, // Zoom level changed for scheme/host |
42 // pair. | 42 // pair. |
43 ZOOM_CHANGED_TEMPORARY_ZOOM, // Temporary zoom change for specific | 43 ZOOM_CHANGED_TEMPORARY_ZOOM, // Temporary zoom change for specific |
44 // renderer, no scheme/host is specified. | 44 // renderer, no scheme/host is specified. |
| 45 PAGE_SCALE_IS_ONE_CHANGED, // Page scale factor equal to one changed |
| 46 // for a host. |
45 }; | 47 }; |
46 | 48 |
47 // Structure used to notify about zoom changes. Host and/or scheme are empty | 49 // Structure used to notify about zoom changes. Host and/or scheme are empty |
48 // if not applicable to |mode|. | 50 // if not applicable to |mode|. |
49 struct ZoomLevelChange { | 51 struct ZoomLevelChange { |
50 ZoomLevelChangeMode mode; | 52 ZoomLevelChangeMode mode; |
51 std::string host; | 53 std::string host; |
52 std::string scheme; | 54 std::string scheme; |
53 double zoom_level; | 55 double zoom_level; |
54 }; | 56 }; |
(...skipping 15 matching lines...) Expand all Loading... |
70 // Returns the HostZoomMap associated with this WebContent's main frame. If | 72 // Returns the HostZoomMap associated with this WebContent's main frame. If |
71 // multiple WebContents share the same SiteInstance, then they share a single | 73 // multiple WebContents share the same SiteInstance, then they share a single |
72 // HostZoomMap. | 74 // HostZoomMap. |
73 CONTENT_EXPORT static HostZoomMap* GetForWebContents( | 75 CONTENT_EXPORT static HostZoomMap* GetForWebContents( |
74 const WebContents* contents); | 76 const WebContents* contents); |
75 | 77 |
76 // Returns the current zoom level for the specified WebContents. May be | 78 // Returns the current zoom level for the specified WebContents. May be |
77 // temporary or host-specific. | 79 // temporary or host-specific. |
78 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); | 80 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); |
79 | 81 |
| 82 // Returns true if the page scale factor for the WebContents is one. |
| 83 CONTENT_EXPORT static bool PageScaleFactorIsOne( |
| 84 const WebContents* web_contents); |
| 85 |
80 // Sets the current zoom level for the specified WebContents. The level may | 86 // Sets the current zoom level for the specified WebContents. The level may |
81 // be temporary or host-specific depending on the particular WebContents. | 87 // be temporary or host-specific depending on the particular WebContents. |
82 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, | 88 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, |
83 double level); | 89 double level); |
84 | 90 |
85 // Send an IPC to refresh any displayed error page's zoom levels. Needs to | 91 // Send an IPC to refresh any displayed error page's zoom levels. Needs to |
86 // be called since error pages don't get loaded via the normal channel. | 92 // be called since error pages don't get loaded via the normal channel. |
87 CONTENT_EXPORT static void SendErrorPageZoomLevelRefresh( | 93 CONTENT_EXPORT static void SendErrorPageZoomLevelRefresh( |
88 const WebContents* web_contents); | 94 const WebContents* web_contents); |
89 | 95 |
| 96 // Set or clear whether or not the page scale factor for a view is one. |
| 97 virtual void SetPageScaleFactorIsOneForView( |
| 98 int render_process_id, int render_view_id, bool is_one) = 0; |
| 99 virtual void ClearPageScaleFactorIsOneForView( |
| 100 int render_process_id, int render_view_id) = 0; |
| 101 |
90 // Copy the zoom levels from the given map. Can only be called on the UI | 102 // Copy the zoom levels from the given map. Can only be called on the UI |
91 // thread. | 103 // thread. |
92 virtual void CopyFrom(HostZoomMap* copy) = 0; | 104 virtual void CopyFrom(HostZoomMap* copy) = 0; |
93 | 105 |
94 // Here |host| is the host portion of URL, or (in the absence of a host) | 106 // Here |host| is the host portion of URL, or (in the absence of a host) |
95 // the complete spec of the URL. | 107 // the complete spec of the URL. |
96 // Returns the zoom for the specified |scheme| and |host|. See class | 108 // Returns the zoom for the specified |scheme| and |host|. See class |
97 // description for details. | 109 // description for details. |
98 // | 110 // |
99 // This may be called on any thread. | 111 // This may be called on any thread. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 174 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
163 const ZoomLevelChangedCallback& callback) = 0; | 175 const ZoomLevelChangedCallback& callback) = 0; |
164 | 176 |
165 protected: | 177 protected: |
166 virtual ~HostZoomMap() {} | 178 virtual ~HostZoomMap() {} |
167 }; | 179 }; |
168 | 180 |
169 } // namespace content | 181 } // namespace content |
170 | 182 |
171 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 183 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |