Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(24)

Side by Side Diff: content/public/browser/host_zoom_map.h

Issue 11866004: Add scheme to HostZoomMap (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Add namespace Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « content/common/view_messages.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 "content/common/content_export.h" 14 #include "content/common/content_export.h"
15 15
16 namespace content { 16 namespace content {
17 17
18 class BrowserContext; 18 class BrowserContext;
19 class ResourceContext; 19 class ResourceContext;
20 20
21 // Maps hostnames to custom zoom levels. Written on the UI thread and read on 21 // Maps hostnames to custom zoom levels. Written on the UI thread and read on
22 // any thread. One instance per browser context. Must be created on the UI 22 // any thread. One instance per browser context. Must be created on the UI
23 // thread, and it'll delete itself on the UI thread as well. 23 // thread, and it'll delete itself on the UI thread as well.
24 // Zoom can be defined at three levels: default zoom, zoom for host, and zoom
25 // for host with specific scheme. Setting any of the levels leaves settings
26 // for other settings intact. Getting the zoom level starts at the most
27 // specific setting and progresses to the less specific: first the zoom for the
28 // host and scheme pair is checked, secondly the zoom for the host only and
29 // lastly default zoom.
30
24 class HostZoomMap { 31 class HostZoomMap {
25 public: 32 public:
33 // Enum that indicates what was the scope of zoom level change.
34 enum ZoomLevelChangeMode {
35 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host.
36 ZOOM_CHANGED_FOR_SCHEME_AND_HOST, // Zoom level changed for scheme/host
37 // pair.
38 ZOOM_CHANGED_TEMPORARY_ZOOM, // Temporary zoom change for specific
39 // renderer, no scheme/host is specified.
40 };
41
42 // Structure used to notify about zoom changes. Host and/or scheme are empty
43 // if not applicable to |mode|.
44 struct ZoomLevelChange {
45 ZoomLevelChangeMode mode;
46 std::string host;
47 std::string scheme;
48 double zoom_level;
49 };
50
26 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( 51 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext(
27 BrowserContext* browser_context); 52 BrowserContext* browser_context);
28 53
29 // Copy the zoom levels from the given map. Can only be called on the UI 54 // Copy the zoom levels from the given map. Can only be called on the UI
30 // thread. 55 // thread.
31 virtual void CopyFrom(HostZoomMap* copy) = 0; 56 virtual void CopyFrom(HostZoomMap* copy) = 0;
32 57
33 // Returns the zoom level for the host or spec for a given url. The zoom 58 // Here |host| is the host portion of URL, or (in the absence of a host)
34 // level is determined by the host portion of the URL, or (in the absence of 59 // the complete spec of the URL.
35 // a host) the complete spec of the URL. In most cases, there is no custom 60 // Returns the zoom for the specified |scheme| and |host|. See class
36 // zoom level, and this returns the user's default zoom level. Otherwise, 61 // description for details.
37 // returns the saved zoom level, which may be positive (to zoom in) or
38 // negative (to zoom out).
39 // 62 //
40 // This may be called on any thread. 63 // This may be called on any thread.
41 virtual double GetZoomLevel(const std::string& host) const = 0; 64 virtual double GetZoomLevelForHostAndScheme(
65 const std::string& scheme,
66 const std::string& host) const = 0;
42 67
43 // Sets the zoom level for the host or spec for a given url to |level|. If 68 // Here |host| is the host portion of URL, or (in the absence of a host)
44 // the level matches the current default zoom level, the host is erased 69 // the complete spec of the URL.
45 // from the saved preferences; otherwise the new value is written out. 70 // Sets the zoom level for the |host| to |level|. If the level matches the
71 // current default zoom level, the host is erased from the saved preferences;
72 // otherwise the new value is written out.
73 // Zoom levels specified for both scheme and host are not affected.
46 // 74 //
47 // This should only be called on the UI thread. 75 // This should only be called on the UI thread.
48 virtual void SetZoomLevel(const std::string& host, double level) = 0; 76 virtual void SetZoomLevelForHost(const std::string& host, double level) = 0;
77
78 // Here |host| is the host portion of URL, or (in the absence of a host)
79 // the complete spec of the URL.
80 // Sets the zoom level for the |scheme|/|host| pair to |level|. No values
81 // will be erased during this operation, and this value will not be stored in
82 // the preferences.
83 //
84 // This should only be called on the UI thread.
85 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme,
86 const std::string& host,
87 double level) = 0;
49 88
50 // Get/Set the default zoom level for pages that don't override it. 89 // Get/Set the default zoom level for pages that don't override it.
51 virtual double GetDefaultZoomLevel() const = 0; 90 virtual double GetDefaultZoomLevel() const = 0;
52 virtual void SetDefaultZoomLevel(double level) = 0;; 91 virtual void SetDefaultZoomLevel(double level) = 0;;
53 92
54 typedef base::Callback<void(const std::string&)> ZoomLevelChangedCallback; 93 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback;
55 94
56 // Add and remove zoom level changed callbacks. 95 // Add and remove zoom level changed callbacks.
57 virtual void AddZoomLevelChangedCallback( 96 virtual void AddZoomLevelChangedCallback(
58 const ZoomLevelChangedCallback& callback) = 0; 97 const ZoomLevelChangedCallback& callback) = 0;
59 virtual void RemoveZoomLevelChangedCallback( 98 virtual void RemoveZoomLevelChangedCallback(
60 const ZoomLevelChangedCallback& callback) = 0; 99 const ZoomLevelChangedCallback& callback) = 0;
61 100
62 protected: 101 protected:
63 virtual ~HostZoomMap() {} 102 virtual ~HostZoomMap() {}
64 }; 103 };
65 104
66 } // namespace content 105 } // namespace content
67 106
68 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 107 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_
OLDNEW
« no previous file with comments | « content/common/view_messages.h ('k') | content/renderer/render_thread_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698