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 "content/common/content_export.h" | 14 #include "content/common/content_export.h" |
14 | 15 |
15 namespace content { | 16 namespace content { |
16 | 17 |
17 class BrowserContext; | 18 class BrowserContext; |
19 class HostZoomMapImpl; | |
jam
2013/01/30 17:50:44
nit: not needed anymore
| |
18 class ResourceContext; | 20 class ResourceContext; |
19 | 21 |
20 // Maps hostnames to custom zoom levels. Written on the UI thread and read on | 22 // Maps hostnames to custom zoom levels. Written on the UI thread and read on |
21 // any thread. One instance per browser context. Must be created on the UI | 23 // any thread. One instance per browser context. Must be created on the UI |
22 // thread, and it'll delete itself on the UI thread as well. | 24 // thread, and it'll delete itself on the UI thread as well. |
23 class HostZoomMap { | 25 class HostZoomMap { |
24 public: | 26 public: |
27 typedef base::Callback<void(const std::string&)> ZoomLevelChangedCallback; | |
jam
2013/01/30 17:50:44
nit: the convention in the content api is to decla
| |
28 | |
25 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( | 29 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( |
26 BrowserContext* browser_context); | 30 BrowserContext* browser_context); |
27 | 31 |
28 // Copy the zoom levels from the given map. Can only be called on the UI | 32 // Copy the zoom levels from the given map. Can only be called on the UI |
29 // thread. | 33 // thread. |
30 virtual void CopyFrom(HostZoomMap* copy) = 0; | 34 virtual void CopyFrom(HostZoomMap* copy) = 0; |
31 | 35 |
32 // Returns the zoom level for the host or spec for a given url. The zoom | 36 // Returns the zoom level for the host or spec for a given url. The zoom |
33 // level is determined by the host portion of the URL, or (in the absence of | 37 // level is determined by the host portion of the URL, or (in the absence of |
34 // a host) the complete spec of the URL. In most cases, there is no custom | 38 // a host) the complete spec of the URL. In most cases, there is no custom |
35 // zoom level, and this returns the user's default zoom level. Otherwise, | 39 // zoom level, and this returns the user's default zoom level. Otherwise, |
36 // returns the saved zoom level, which may be positive (to zoom in) or | 40 // returns the saved zoom level, which may be positive (to zoom in) or |
37 // negative (to zoom out). | 41 // negative (to zoom out). |
38 // | 42 // |
39 // This may be called on any thread. | 43 // This may be called on any thread. |
40 virtual double GetZoomLevel(const std::string& host) const = 0; | 44 virtual double GetZoomLevel(const std::string& host) const = 0; |
41 | 45 |
42 // Sets the zoom level for the host or spec for a given url to |level|. If | 46 // Sets the zoom level for the host or spec for a given url to |level|. If |
43 // the level matches the current default zoom level, the host is erased | 47 // the level matches the current default zoom level, the host is erased |
44 // from the saved preferences; otherwise the new value is written out. | 48 // from the saved preferences; otherwise the new value is written out. |
45 // | 49 // |
46 // This should only be called on the UI thread. | 50 // This should only be called on the UI thread. |
47 virtual void SetZoomLevel(const std::string& host, double level) = 0; | 51 virtual void SetZoomLevel(const std::string& host, double level) = 0; |
48 | 52 |
49 // Get/Set the default zoom level for pages that don't override it. | 53 // Get/Set the default zoom level for pages that don't override it. |
50 virtual double GetDefaultZoomLevel() const = 0; | 54 virtual double GetDefaultZoomLevel() const = 0; |
51 virtual void SetDefaultZoomLevel(double level) = 0;; | 55 virtual void SetDefaultZoomLevel(double level) = 0;; |
52 | 56 |
57 // Add and remove zoom level changed callbacks. | |
58 virtual void AddZoomLevelChangedCallback( | |
59 ZoomLevelChangedCallback callback) = 0; | |
jam
2013/01/30 17:50:44
nit: callbacks, like other complex types, are pass
| |
60 virtual void RemoveZoomLevelChangedCallback( | |
61 ZoomLevelChangedCallback callback) = 0; | |
62 | |
53 protected: | 63 protected: |
54 virtual ~HostZoomMap() {} | 64 virtual ~HostZoomMap() {} |
55 }; | 65 }; |
56 | 66 |
57 } // namespace content | 67 } // namespace content |
58 | 68 |
59 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ | 69 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ |
OLD | NEW |