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

Side by Side Diff: content/browser/host_zoom_map_impl.h

Issue 287093002: Remove ViewMsg_SetZoomLevel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Revised as per comments. Created 6 years, 6 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 | Annotate | Revision Log
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_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 5 #ifndef CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 6 #define CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_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/compiler_specific.h" 12 #include "base/compiler_specific.h"
13 #include "base/sequenced_task_runner_helpers.h" 13 #include "base/sequenced_task_runner_helpers.h"
14 #include "base/supports_user_data.h" 14 #include "base/supports_user_data.h"
15 #include "base/synchronization/lock.h" 15 #include "base/synchronization/lock.h"
16 #include "content/public/browser/host_zoom_map.h" 16 #include "content/public/browser/host_zoom_map.h"
17 #include "content/public/browser/notification_observer.h" 17 #include "content/public/browser/notification_observer.h"
18 #include "content/public/browser/notification_registrar.h" 18 #include "content/public/browser/notification_registrar.h"
19 19
20 namespace content { 20 namespace content {
21 21
22 class WebContentsImpl;
23
22 // HostZoomMap needs to be deleted on the UI thread because it listens 24 // HostZoomMap needs to be deleted on the UI thread because it listens
23 // to notifications on there (and holds a NotificationRegistrar). 25 // to notifications on there (and holds a NotificationRegistrar).
24 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap), 26 class CONTENT_EXPORT HostZoomMapImpl : public NON_EXPORTED_BASE(HostZoomMap),
25 public NotificationObserver, 27 public NotificationObserver,
26 public base::SupportsUserData::Data { 28 public base::SupportsUserData::Data {
27 public: 29 public:
28 HostZoomMapImpl(); 30 HostZoomMapImpl();
29 virtual ~HostZoomMapImpl(); 31 virtual ~HostZoomMapImpl();
30 32
31 // HostZoomMap implementation: 33 // HostZoomMap implementation:
32 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE; 34 virtual void CopyFrom(HostZoomMap* copy) OVERRIDE;
33 virtual double GetZoomLevelForHostAndScheme( 35 virtual double GetZoomLevelForHostAndScheme(
34 const std::string& scheme, 36 const std::string& scheme,
35 const std::string& host) const OVERRIDE; 37 const std::string& host) const OVERRIDE;
36 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE; 38 virtual ZoomLevelVector GetAllZoomLevels() const OVERRIDE;
37 virtual void SetZoomLevelForHost( 39 virtual void SetZoomLevelForHost(
38 const std::string& host, 40 const std::string& host,
39 double level) OVERRIDE; 41 double level) OVERRIDE;
40 virtual void SetZoomLevelForHostAndScheme( 42 virtual void SetZoomLevelForHostAndScheme(
41 const std::string& scheme, 43 const std::string& scheme,
42 const std::string& host, 44 const std::string& host,
43 double level) OVERRIDE; 45 double level) OVERRIDE;
44 virtual double GetDefaultZoomLevel() const OVERRIDE; 46 virtual double GetDefaultZoomLevel() const OVERRIDE;
45 virtual void SetDefaultZoomLevel(double level) OVERRIDE; 47 virtual void SetDefaultZoomLevel(double level) OVERRIDE;
46 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback( 48 virtual scoped_ptr<Subscription> AddZoomLevelChangedCallback(
47 const ZoomLevelChangedCallback& callback) OVERRIDE; 49 const ZoomLevelChangedCallback& callback) OVERRIDE;
48 50
51 // Returns the current zoom level for the specified WebContents. This may
52 // be a temporary zoom level, depending on UsesTemporaryZoomLevel().
53 double GetZoomLevelForWebContents(
54 const WebContentsImpl& web_contents_impl) const;
55
56 // Sets the zoom level for this WebContents. If this WebContents is using
57 // a temporary zoom level, then level is only applied to this WebContents.
58 // Otherwise, the level will be applied on a host level.
59 void SetZoomLevelForWebContents(const WebContentsImpl& web_contents_impl,
60 double level);
61
62 // Sets the zoom level for the specified view. The level may be set for only
63 // this view, or for the host, depending on UsesTemporaryZoomLevel().
64 void SetZoomLevelForView(int render_process_id,
65 int render_view_id,
66 double level,
67 const std::string& host);
68
69 // Returns whether the view manages its zoom level independently of other tabs
70 // displaying content from the same host.
71 bool UsesTemporaryZoomLevel(int render_process_id, int render_view_id) const;
72
73 // Sets whether the view manages its zoom level independently of other tabs
74 // displaying content from the same host, based on whether
75 // |uses_temporary_zoom_level| is true.
76 void SetUsesTemporaryZoomLevel(int render_process_id,
77 int render_view_id,
78 bool uses_temporary_zoom_level);
79
49 // Returns the temporary zoom level that's only valid for the lifetime of 80 // Returns the temporary zoom level that's only valid for the lifetime of
50 // the given WebContents (i.e. isn't saved and doesn't affect other 81 // the given WebContents (i.e. isn't saved and doesn't affect other
51 // WebContentses) if it exists, the default zoom level otherwise. 82 // WebContentses) if it exists, the default zoom level otherwise.
52 // 83 //
53 // This may be called on any thread. 84 // This may be called on any thread.
54 double GetTemporaryZoomLevel(int render_process_id, 85 double GetTemporaryZoomLevel(int render_process_id,
55 int render_view_id) const; 86 int render_view_id) const;
56 87
57 // Sets the temporary zoom level that's only valid for the lifetime of this 88 // Sets the temporary zoom level that's only valid for the lifetime of this
58 // WebContents. 89 // WebContents.
(...skipping 17 matching lines...) Expand all
76 // Callbacks called when zoom level changes. 107 // Callbacks called when zoom level changes.
77 base::CallbackList<void(const ZoomLevelChange&)> 108 base::CallbackList<void(const ZoomLevelChange&)>
78 zoom_level_changed_callbacks_; 109 zoom_level_changed_callbacks_;
79 110
80 // Copy of the pref data, so that we can read it on the IO thread. 111 // Copy of the pref data, so that we can read it on the IO thread.
81 HostZoomLevels host_zoom_levels_; 112 HostZoomLevels host_zoom_levels_;
82 SchemeHostZoomLevels scheme_host_zoom_levels_; 113 SchemeHostZoomLevels scheme_host_zoom_levels_;
83 double default_zoom_level_; 114 double default_zoom_level_;
84 115
85 struct TemporaryZoomLevel { 116 struct TemporaryZoomLevel {
117 TemporaryZoomLevel(int process_id, int view_id, double level);
118 TemporaryZoomLevel(int process_id, int view_id);
119 bool operator==(const TemporaryZoomLevel& other) const;
120
86 int render_process_id; 121 int render_process_id;
87 int render_view_id; 122 int render_view_id;
88 double zoom_level; 123 double zoom_level;
89 }; 124 };
90 125
91 // Don't expect more than a couple of tabs that are using a temporary zoom 126 // Don't expect more than a couple of tabs that are using a temporary zoom
92 // level, so vector is fine for now. 127 // level, so vector is fine for now.
93 std::vector<TemporaryZoomLevel> temporary_zoom_levels_; 128 typedef std::vector<TemporaryZoomLevel> TemporaryZoomLevels;
Peter Kasting 2014/05/29 18:16:08 Nit: Style guide says typedefs and enums go at the
wjmaclean 2014/05/29 20:14:19 Done.
129 TemporaryZoomLevels temporary_zoom_levels_;
94 130
95 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and 131 // Used around accesses to |host_zoom_levels_|, |default_zoom_level_| and
96 // |temporary_zoom_levels_| to guarantee thread safety. 132 // |temporary_zoom_levels_| to guarantee thread safety.
97 mutable base::Lock lock_; 133 mutable base::Lock lock_;
98 134
99 NotificationRegistrar registrar_; 135 NotificationRegistrar registrar_;
100 136
101 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl); 137 DISALLOW_COPY_AND_ASSIGN(HostZoomMapImpl);
102 }; 138 };
103 139
104 } // namespace content 140 } // namespace content
105 141
106 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_ 142 #endif // CONTENT_BROWSER_HOST_ZOOM_MAP_IMPL_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698