Chromium Code Reviews| Index: components/ui/zoom/zoom_controller.h |
| diff --git a/chrome/browser/ui/zoom/zoom_controller.h b/components/ui/zoom/zoom_controller.h |
| similarity index 85% |
| rename from chrome/browser/ui/zoom/zoom_controller.h |
| rename to components/ui/zoom/zoom_controller.h |
| index 7dad4ad35ec9f9b6e3336d02920f231fdbc01442..f8d1dc3715f9beefefde8179bb20339a884fd0bd 100644 |
| --- a/chrome/browser/ui/zoom/zoom_controller.h |
| +++ b/components/ui/zoom/zoom_controller.h |
| @@ -2,11 +2,12 @@ |
| // Use of this source code is governed by a BSD-style license that can be |
| // found in the LICENSE file. |
| -#ifndef CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| -#define CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| +#ifndef COMPONENTS_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| +#define COMPONENTS_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| #include "base/basictypes.h" |
| #include "base/compiler_specific.h" |
| +#include "base/memory/ref_counted.h" |
| #include "base/memory/scoped_ptr.h" |
| #include "base/observer_list.h" |
| #include "base/prefs/pref_member.h" |
| @@ -14,15 +15,27 @@ |
| #include "content/public/browser/web_contents_observer.h" |
| #include "content/public/browser/web_contents_user_data.h" |
| -class ZoomObserver; |
| +class ZoomControllerTest; |
| namespace content { |
| class WebContents; |
| } |
| -namespace extensions { |
| -class Extension; |
| -} // namespace extensions |
| +namespace components { |
| +class ZoomObserver; |
| + |
| +class ZoomRequestClient : public base::RefCounted<ZoomRequestClient> { |
| + public: |
| + ZoomRequestClient() {} |
| + |
| + protected: |
| + virtual ~ZoomRequestClient() {} |
| + |
| + private: |
| + friend class base::RefCounted<ZoomRequestClient>; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ZoomRequestClient); |
| +}; |
| // Per-tab class to manage zoom changes and the Omnibox zoom icon. |
| class ZoomController : public content::WebContentsObserver, |
| @@ -48,6 +61,12 @@ class ZoomController : public content::WebContentsObserver, |
| ZOOM_MODE_DISABLED, |
| }; |
| + enum RelativeZoom { |
| + ZOOM_BELOW_DEFAULT_ZOOM, |
| + ZOOM_AT_DEFAULT_ZOOM, |
| + ZOOM_ABOVE_DEFAULT_ZOOM |
| + }; |
| + |
| struct ZoomChangedEventData { |
| ZoomChangedEventData(content::WebContents* web_contents, |
| double old_zoom_level, |
| @@ -81,10 +100,10 @@ class ZoomController : public content::WebContentsObserver, |
| bool IsAtDefaultZoom() const; |
| // Returns which image should be loaded for the current zoom level. |
| - int GetResourceForZoomLevel() const; |
| + RelativeZoom GetZoomRelativeToDefault() const; |
| - const extensions::Extension* last_extension() const { |
| - return last_extension_.get(); |
| + const ZoomRequestClient* last_client() const { |
| + return last_client_.get(); |
| } |
| void AddObserver(ZoomObserver* observer); |
| @@ -111,9 +130,9 @@ class ZoomController : public content::WebContentsObserver, |
| // Sets the zoom level via HostZoomMap (or stores it locally if in manual zoom |
| // mode), and attributes the zoom to |extension|. Returns true on success. |
| - bool SetZoomLevelByExtension( |
| + bool SetZoomLevelByClient( |
| double zoom_level, |
| - const scoped_refptr<const extensions::Extension>& extension); |
| + const scoped_refptr<const ZoomRequestClient>& extension); |
|
Ken Rockot(use gerrit already)
2014/12/03 21:42:48
nit: client -> extension
wjmaclean
2014/12/04 15:04:30
Done.
|
| // Sets the zoom mode, which defines zoom behavior (see enum ZoomMode). |
| void SetZoomMode(ZoomMode zoom_mode); |
| @@ -130,7 +149,7 @@ class ZoomController : public content::WebContentsObserver, |
| private: |
| friend class content::WebContentsUserData<ZoomController>; |
| - friend class ZoomControllerTest; |
| + friend class ::ZoomControllerTest; |
| void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change); |
| @@ -153,7 +172,7 @@ class ZoomController : public content::WebContentsObserver, |
| // Keeps track of the extension (if any) that initiated the last zoom change |
| // that took effect. |
| - scoped_refptr<const extensions::Extension> last_extension_; |
| + scoped_refptr<const ZoomRequestClient> last_client_; |
| // Observer receiving notifications on state changes. |
| ObserverList<ZoomObserver> observers_; |
| @@ -165,4 +184,6 @@ class ZoomController : public content::WebContentsObserver, |
| DISALLOW_COPY_AND_ASSIGN(ZoomController); |
| }; |
| -#endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| +} // namespace extensions |
| + |
| +#endif // COMPONENTS_UI_ZOOM_ZOOM_CONTROLLER_H_ |