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> |
11 | 11 |
12 #include "base/basictypes.h" | 12 #include "base/basictypes.h" |
13 #include "base/callback.h" | 13 #include "base/callback.h" |
14 #include "base/callback_list.h" | 14 #include "base/callback_list.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
| 16 #include "url/gurl.h" |
16 | 17 |
17 namespace content { | 18 namespace content { |
18 | 19 |
| 20 class NavigationEntry; |
19 class BrowserContext; | 21 class BrowserContext; |
20 class ResourceContext; | 22 class ResourceContext; |
21 class WebContents; | 23 class WebContents; |
22 | 24 |
23 // Maps hostnames to custom zoom levels. Written on the UI thread and read on | 25 // 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 | 26 // 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. | 27 // 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 | 28 // 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 | 29 // 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 | 30 // for other settings intact. Getting the zoom level starts at the most |
(...skipping 16 matching lines...) Expand all Loading... |
45 // if not applicable to |mode|. | 47 // if not applicable to |mode|. |
46 struct ZoomLevelChange { | 48 struct ZoomLevelChange { |
47 ZoomLevelChangeMode mode; | 49 ZoomLevelChangeMode mode; |
48 std::string host; | 50 std::string host; |
49 std::string scheme; | 51 std::string scheme; |
50 double zoom_level; | 52 double zoom_level; |
51 }; | 53 }; |
52 | 54 |
53 typedef std::vector<ZoomLevelChange> ZoomLevelVector; | 55 typedef std::vector<ZoomLevelChange> ZoomLevelVector; |
54 | 56 |
| 57 // Extracts the URL from NavigationEntry, substituting the error page |
| 58 // URL in the event that the error page is showing. |
| 59 CONTENT_EXPORT static GURL GetURLFromEntry(const NavigationEntry* entry); |
| 60 |
55 CONTENT_EXPORT static HostZoomMap* GetDefaultForBrowserContext( | 61 CONTENT_EXPORT static HostZoomMap* GetDefaultForBrowserContext( |
56 BrowserContext* browser_context); | 62 BrowserContext* browser_context); |
57 | 63 |
58 // Returns the current zoom level for the specified WebContents. May be | 64 // Returns the current zoom level for the specified WebContents. May be |
59 // temporary or host-specific. | 65 // temporary or host-specific. |
60 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); | 66 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); |
61 | 67 |
62 // Sets the current zoom level for the specified WebContents. The level may | 68 // Sets the current zoom level for the specified WebContents. The level may |
63 // be temporary or host-specific depending on the particular WebContents. | 69 // be temporary or host-specific depending on the particular WebContents. |
64 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, | 70 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, |
65 double level); | 71 double level); |
66 | 72 |
| 73 // Send an IPC to refresh any displayed error page's zoom levels. Needs to |
| 74 // be called since error pages don't get loaded via the normal channel. |
| 75 CONTENT_EXPORT static void SendErrorPageZoomLevelRefresh( |
| 76 const WebContents* web_contents); |
| 77 |
67 // Copy the zoom levels from the given map. Can only be called on the UI | 78 // Copy the zoom levels from the given map. Can only be called on the UI |
68 // thread. | 79 // thread. |
69 virtual void CopyFrom(HostZoomMap* copy) = 0; | 80 virtual void CopyFrom(HostZoomMap* copy) = 0; |
70 | 81 |
71 // Here |host| is the host portion of URL, or (in the absence of a host) | 82 // Here |host| is the host portion of URL, or (in the absence of a host) |
72 // the complete spec of the URL. | 83 // the complete spec of the URL. |
73 // Returns the zoom for the specified |scheme| and |host|. See class | 84 // Returns the zoom for the specified |scheme| and |host|. See class |
74 // description for details. | 85 // description for details. |
75 // | 86 // |
76 // This may be called on any thread. | 87 // This may be called on any thread. |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 150 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
140 const ZoomLevelChangedCallback& callback) = 0; | 151 const ZoomLevelChangedCallback& callback) = 0; |
141 | 152 |
142 protected: | 153 protected: |
143 virtual ~HostZoomMap() {} | 154 virtual ~HostZoomMap() {} |
144 }; | 155 }; |
145 | 156 |
146 } // namespace content | 157 } // namespace content |
147 | 158 |
148 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 159 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |