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

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

Powered by Google App Engine
This is Rietveld 408576698