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 CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | 5 #ifndef CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
6 #define CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | 6 #define CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Returns which image should be loaded for the current zoom level. | 76 // Returns which image should be loaded for the current zoom level. |
77 int GetResourceForZoomLevel() const; | 77 int GetResourceForZoomLevel() const; |
78 | 78 |
79 const extensions::Extension* last_extension() const { | 79 const extensions::Extension* last_extension() const { |
80 return last_extension_.get(); | 80 return last_extension_.get(); |
81 } | 81 } |
82 | 82 |
83 void AddObserver(ZoomObserver* observer); | 83 void AddObserver(ZoomObserver* observer); |
84 void RemoveObserver(ZoomObserver* observer); | 84 void RemoveObserver(ZoomObserver* observer); |
85 | 85 |
| 86 // Used to set whether the zoom notification bubble can be shown when the |
| 87 // zoom level is changed for this controller. Default behavior is to show |
| 88 // the bubble. |
| 89 void SetShowsNotificationBubble(bool can_show_bubble) { |
| 90 can_show_bubble_ = can_show_bubble; |
| 91 } |
| 92 |
86 // Gets the current zoom level by querying HostZoomMap (if not in manual zoom | 93 // Gets the current zoom level by querying HostZoomMap (if not in manual zoom |
87 // mode) or from the ZoomController local value otherwise. | 94 // mode) or from the ZoomController local value otherwise. |
88 double GetZoomLevel() const; | 95 double GetZoomLevel() const; |
89 // Calls GetZoomLevel() then converts the returned value to a percentage | 96 // Calls GetZoomLevel() then converts the returned value to a percentage |
90 // zoom factor. | 97 // zoom factor. |
91 int GetZoomPercent() const; | 98 int GetZoomPercent() const; |
92 | 99 |
93 // Sets the zoom level through HostZoomMap. | 100 // Sets the zoom level through HostZoomMap. |
94 // Returns true on success. | 101 // Returns true on success. |
95 bool SetZoomLevel(double zoom_level); | 102 bool SetZoomLevel(double zoom_level); |
(...skipping 18 matching lines...) Expand all Loading... |
114 friend class ZoomControllerTest; | 121 friend class ZoomControllerTest; |
115 | 122 |
116 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); | 123 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); |
117 | 124 |
118 // Updates the zoom icon and zoom percentage based on current values and | 125 // Updates the zoom icon and zoom percentage based on current values and |
119 // notifies the observer if changes have occurred. |host| may be empty, | 126 // notifies the observer if changes have occurred. |host| may be empty, |
120 // meaning the change should apply to ~all sites. If it is not empty, the | 127 // meaning the change should apply to ~all sites. If it is not empty, the |
121 // change only affects sites with the given host. | 128 // change only affects sites with the given host. |
122 void UpdateState(const std::string& host); | 129 void UpdateState(const std::string& host); |
123 | 130 |
| 131 // True if changes to zoom level can trigger the zoom notification bubble. |
| 132 bool can_show_bubble_; |
| 133 |
124 // The current zoom mode. | 134 // The current zoom mode. |
125 ZoomMode zoom_mode_; | 135 ZoomMode zoom_mode_; |
126 | 136 |
127 // Current zoom level. | 137 // Current zoom level. |
128 double zoom_level_; | 138 double zoom_level_; |
129 | 139 |
130 // Used to access the default zoom level preference. | 140 // Used to access the default zoom level preference. |
131 DoublePrefMember default_zoom_level_; | 141 DoublePrefMember default_zoom_level_; |
132 | 142 |
133 scoped_ptr<ZoomChangedEventData> event_data_; | 143 scoped_ptr<ZoomChangedEventData> event_data_; |
134 | 144 |
135 // Keeps track of the extension (if any) that initiated the last zoom change | 145 // Keeps track of the extension (if any) that initiated the last zoom change |
136 // that took effect. | 146 // that took effect. |
137 scoped_refptr<const extensions::Extension> last_extension_; | 147 scoped_refptr<const extensions::Extension> last_extension_; |
138 | 148 |
139 // Observer receiving notifications on state changes. | 149 // Observer receiving notifications on state changes. |
140 ObserverList<ZoomObserver> observers_; | 150 ObserverList<ZoomObserver> observers_; |
141 | 151 |
142 content::BrowserContext* browser_context_; | 152 content::BrowserContext* browser_context_; |
143 | 153 |
144 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_; | 154 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_; |
145 | 155 |
146 DISALLOW_COPY_AND_ASSIGN(ZoomController); | 156 DISALLOW_COPY_AND_ASSIGN(ZoomController); |
147 }; | 157 }; |
148 | 158 |
149 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | 159 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
OLD | NEW |