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 |
19 class BrowserContext; | 20 class BrowserContext; |
20 class ResourceContext; | 21 class ResourceContext; |
| 22 class SiteInstance; |
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 |
29 // specific setting and progresses to the less specific: first the zoom for the | 31 // 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 | 32 // host and scheme pair is checked, secondly the zoom for the host only and |
(...skipping 17 matching lines...) Expand all Loading... |
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 |
55 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( | 57 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( |
56 BrowserContext* browser_context); | 58 BrowserContext* browser_context); |
57 | 59 |
| 60 CONTENT_EXPORT static HostZoomMap* GetForSite(SiteInstance* instance); |
| 61 |
| 62 CONTENT_EXPORT static HostZoomMap* GetForWebContents( |
| 63 const WebContents* contents); |
| 64 |
58 // Returns the current zoom level for the specified WebContents. May be | 65 // Returns the current zoom level for the specified WebContents. May be |
59 // temporary or host-specific. | 66 // temporary or host-specific. |
60 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); | 67 CONTENT_EXPORT static double GetZoomLevel(const WebContents* web_contents); |
61 | 68 |
62 // Sets the current zoom level for the specified WebContents. The level may | 69 // Sets the current zoom level for the specified WebContents. The level may |
63 // be temporary or host-specific depending on the particular WebContents. | 70 // be temporary or host-specific depending on the particular WebContents. |
64 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, | 71 CONTENT_EXPORT static void SetZoomLevel(const WebContents* web_contents, |
65 double level); | 72 double level); |
66 | 73 |
67 // Copy the zoom levels from the given map. Can only be called on the UI | 74 // Copy the zoom levels from the given map. Can only be called on the UI |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( | 146 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( |
140 const ZoomLevelChangedCallback& callback) = 0; | 147 const ZoomLevelChangedCallback& callback) = 0; |
141 | 148 |
142 protected: | 149 protected: |
143 virtual ~HostZoomMap() {} | 150 virtual ~HostZoomMap() {} |
144 }; | 151 }; |
145 | 152 |
146 } // namespace content | 153 } // namespace content |
147 | 154 |
148 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 155 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |