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

Side by Side Diff: chrome/browser/ui/zoom/zoom_controller.h

Issue 10736028: Refactor browser window zoom handling and enable zoom icon on all platforms. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 4 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 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 "chrome/browser/prefs/pref_member.h" 10 #include "chrome/browser/prefs/pref_member.h"
11 #include "content/public/browser/notification_observer.h" 11 #include "content/public/browser/notification_observer.h"
12 #include "content/public/browser/notification_registrar.h" 12 #include "content/public/browser/notification_registrar.h"
13 #include "content/public/browser/web_contents_observer.h" 13 #include "content/public/browser/web_contents_observer.h"
14 14
15 class TabContents; 15 class TabContents;
16 class ZoomObserver; 16 class ZoomObserver;
17 17
18 // Per-tab class to manage the Omnibox zoom icon. 18 // Per-tab class to manage the Omnibox zoom icon.
19 class ZoomController : public content::NotificationObserver, 19 class ZoomController : public content::NotificationObserver,
20 public content::WebContentsObserver { 20 public content::WebContentsObserver {
21 public: 21 public:
22 enum ZoomIconState {
23 NONE = 0,
24 ZOOM_PLUS_ICON,
25 ZOOM_MINUS_ICON,
26 };
27
28 explicit ZoomController(TabContents* tab_contents); 22 explicit ZoomController(TabContents* tab_contents);
29 virtual ~ZoomController(); 23 virtual ~ZoomController();
30 24
31 ZoomIconState zoom_icon_state() const { return zoom_icon_state_; }
32 int zoom_percent() const { return zoom_percent_; } 25 int zoom_percent() const { return zoom_percent_; }
33 26
27 // Convenience method to quickly check if the tab's at default zoom.
28 bool IsAtDefaultZoom() const;
29
30 // Returns which image should be loaded for the current zoom level.
31 int GetResourceForZoomLevel() const;
32
34 void set_observer(ZoomObserver* observer) { observer_ = observer; } 33 void set_observer(ZoomObserver* observer) { observer_ = observer; }
35 34
36 private: 35 private:
37 // content::WebContentsObserver overrides: 36 // content::WebContentsObserver overrides:
38 virtual void DidNavigateMainFrame( 37 virtual void DidNavigateMainFrame(
39 const content::LoadCommittedDetails& details, 38 const content::LoadCommittedDetails& details,
40 const content::FrameNavigateParams& params) OVERRIDE; 39 const content::FrameNavigateParams& params) OVERRIDE;
41 40
42 // content::NotificationObserver overrides: 41 // content::NotificationObserver overrides:
43 virtual void Observe(int type, 42 virtual void Observe(int type,
44 const content::NotificationSource& source, 43 const content::NotificationSource& source,
45 const content::NotificationDetails& details) OVERRIDE; 44 const content::NotificationDetails& details) OVERRIDE;
46 45
47 // Updates the zoom icon and zoom percentage based on current values and 46 // Updates the zoom icon and zoom percentage based on current values and
48 // notifies the observer if changes have occurred. |can_show_bubble| will be 47 // notifies the observer if changes have occurred. |can_show_bubble| will be
49 // true only if the active window changes the zoom on the current page (i.e., 48 // true only if the active window changes the zoom on the current page (i.e.,
50 // inactive window zoom changes, creating a new tab/window, or shifting 49 // inactive window zoom changes, creating a new tab/window, or shifting
51 // between tabs/windows, although they may involve a change in the zoom, will 50 // between tabs/windows, although they may involve a change in the zoom,
52 // not trigger the bubble to be shown). 51 // should not trigger showing a bubble).
53 void UpdateState(bool can_show_bubble); 52 void UpdateState(bool can_show_bubble);
54 53
55 // The current zoom icon state.
56 ZoomIconState zoom_icon_state_;
57
58 // The current zoom percentage. 54 // The current zoom percentage.
59 int zoom_percent_; 55 int zoom_percent_;
60 56
61 content::NotificationRegistrar registrar_; 57 content::NotificationRegistrar registrar_;
62 58
63 // Used to access the default zoom level preference. 59 // Used to access the default zoom level preference.
64 DoublePrefMember default_zoom_level_; 60 DoublePrefMember default_zoom_level_;
65 61
66 // TabContents that owns this instance. 62 // TabContents that owns this instance.
67 TabContents* tab_contents_; 63 TabContents* tab_contents_;
68 64
69 // Observer receiving notifications on state changes. 65 // Observer receiving notifications on state changes.
70 ZoomObserver* observer_; 66 ZoomObserver* observer_;
71 67
72 DISALLOW_COPY_AND_ASSIGN(ZoomController); 68 DISALLOW_COPY_AND_ASSIGN(ZoomController);
73 }; 69 };
74 70
75 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ 71 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698