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

Unified Diff: components/ui/zoom/zoom_controller.h

Issue 769593003: Move ZoomObserver, ZoomController and ZoomEventManager to components/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete defines in build files. Created 6 years 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/ui/zoom/OWNERS ('k') | components/ui/zoom/zoom_controller.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 84%
rename from chrome/browser/ui/zoom/zoom_controller.h
rename to components/ui/zoom/zoom_controller.h
index 7dad4ad35ec9f9b6e3336d02920f231fdbc01442..58143452d18ca569e41138cc68942e969b9f4e40 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 ui_zoom {
+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,11 +100,9 @@ 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);
void RemoveObserver(ZoomObserver* observer);
@@ -110,10 +127,10 @@ class ZoomController : public content::WebContentsObserver,
bool SetZoomLevel(double zoom_level);
// 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(
+ // mode), and attributes the zoom to |client|. Returns true on success.
+ bool SetZoomLevelByClient(
double zoom_level,
- const scoped_refptr<const extensions::Extension>& extension);
+ const scoped_refptr<const ZoomRequestClient>& client);
// Sets the zoom mode, which defines zoom behavior (see enum ZoomMode).
void SetZoomMode(ZoomMode zoom_mode);
@@ -130,7 +147,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 +170,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 +182,6 @@ class ZoomController : public content::WebContentsObserver,
DISALLOW_COPY_AND_ASSIGN(ZoomController);
};
-#endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_
+} // namespace ui_zoom
+
+#endif // COMPONENTS_UI_ZOOM_ZOOM_CONTROLLER_H_
« no previous file with comments | « components/ui/zoom/OWNERS ('k') | components/ui/zoom/zoom_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698