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

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: 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.
26
24 class HostZoomMap { 27 class HostZoomMap {
25 public: 28 public:
29 // Enum that indicates how
Jói 2013/03/06 20:43:17 trailing sentence
Denis Kuznetsov (DE-MUC) 2013/03/07 15:16:59 Done.
30 enum ZoomLevelChangeMode {
31 ZOOM_CHANGED_FOR_HOST, // Zoom level changed for host.
32 ZOOM_CHANGED_FOR_SCHEME_AND_HOST // Zoom level changed for scheme/host pair.
33 ZOOM_CHANGED_GENERIC, // Some zoom level change happened,
sky 2013/03/06 22:21:11 It is totally unclear what this is, and because of
Denis Kuznetsov (DE-MUC) 2013/03/07 15:16:59 Done.
34 // nothing else is known.
35 };
36
37 // Structure used to notify about zoom changes. Host and Scheme part can be
38 // empty if they do not make sense for particular mode.
39 struct ZoomLevelChange {
40 ZoomLevelChangeMode mode;
41 std::string host;
42 std::string scheme;
43 double zoom_level;
44 };
45
26 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext( 46 CONTENT_EXPORT static HostZoomMap* GetForBrowserContext(
27 BrowserContext* browser_context); 47 BrowserContext* browser_context);
28 48
29 // Copy the zoom levels from the given map. Can only be called on the UI 49 // Copy the zoom levels from the given map. Can only be called on the UI
30 // thread. 50 // thread.
31 virtual void CopyFrom(HostZoomMap* copy) = 0; 51 virtual void CopyFrom(HostZoomMap* copy) = 0;
32 52
33 // Returns the zoom level for the host or spec for a given url. The zoom 53 // Returns the zoom level for the host or spec for a given url, taking
54 // |scheme| in account. If there is specific zoom level specified for given
55 // |scheme| and |host| pair, it will be returned. In other cases the zoom
34 // level is determined by the host portion of the URL, or (in the absence of 56 // level is determined by the host portion of the URL, or (in the absence of
Jói 2013/03/06 20:43:17 "in the absence of a host" seems a bit unclear to
Denis Kuznetsov (DE-MUC) 2013/03/07 15:16:59 Done.
35 // a host) the complete spec of the URL. In most cases, there is no custom 57 // a host) the complete spec of the URL. In most cases, there is no custom
36 // zoom level, and this returns the user's default zoom level. Otherwise, 58 // zoom level, and this returns the user's default zoom level. Otherwise,
37 // returns the saved zoom level, which may be positive (to zoom in) or 59 // returns the saved zoom level, which may be positive (to zoom in) or
38 // negative (to zoom out). 60 // negative (to zoom out).
39 // 61 //
40 // This may be called on any thread. 62 // This may be called on any thread.
41 virtual double GetZoomLevel(const std::string& host) const = 0; 63 virtual double GetZoomLevelForHostAndScheme(
64 const std::string& scheme,
65 const std::string& host) const = 0;
42 66
43 // Sets the zoom level for the host or spec for a given url to |level|. If 67 // Sets the zoom level for the host or spec for a given url to |level|. If
44 // the level matches the current default zoom level, the host is erased 68 // the level matches the current default zoom level, the host is erased
45 // from the saved preferences; otherwise the new value is written out. 69 // from the saved preferences; otherwise the new value is written out.
46 // 70 //
47 // This should only be called on the UI thread. 71 // This should only be called on the UI thread.
48 virtual void SetZoomLevel(const std::string& host, double level) = 0; 72 virtual void SetZoomLevelForHost(const std::string& host, double level) = 0;
sky 2013/03/06 22:21:11 Can you document at the class level what the prece
Denis Kuznetsov (DE-MUC) 2013/03/07 15:16:59 Done.
73
74 // Sets the zoom level for the |scheme|/|host| pair to |level|.
Jói 2013/03/06 20:43:17 One point you might clarify in the documentation f
Denis Kuznetsov (DE-MUC) 2013/03/07 15:16:59 Done.
75 //
76 // This should only be called on the UI thread.
77 virtual void SetZoomLevelForHostAndScheme(const std::string& scheme,
78 const std::string& host,
79 double level) = 0;
49 80
50 // Get/Set the default zoom level for pages that don't override it. 81 // Get/Set the default zoom level for pages that don't override it.
51 virtual double GetDefaultZoomLevel() const = 0; 82 virtual double GetDefaultZoomLevel() const = 0;
52 virtual void SetDefaultZoomLevel(double level) = 0;; 83 virtual void SetDefaultZoomLevel(double level) = 0;;
53 84
54 typedef base::Callback<void(const std::string&)> ZoomLevelChangedCallback; 85 typedef base::Callback<void(const ZoomLevelChange&)> ZoomLevelChangedCallback;
55 86
56 // Add and remove zoom level changed callbacks. 87 // Add and remove zoom level changed callbacks.
57 virtual void AddZoomLevelChangedCallback( 88 virtual void AddZoomLevelChangedCallback(
58 const ZoomLevelChangedCallback& callback) = 0; 89 const ZoomLevelChangedCallback& callback) = 0;
59 virtual void RemoveZoomLevelChangedCallback( 90 virtual void RemoveZoomLevelChangedCallback(
60 const ZoomLevelChangedCallback& callback) = 0; 91 const ZoomLevelChangedCallback& callback) = 0;
61 92
62 protected: 93 protected:
63 virtual ~HostZoomMap() {} 94 virtual ~HostZoomMap() {}
64 }; 95 };
65 96
66 } // namespace content 97 } // namespace content
67 98
68 #endif // CONTENT_PUBLIC_BROWSER_HOST_ZOOM_MAP_H_ 99 #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