Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | |
| 6 #define CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/basictypes.h" | |
| 10 #include "base/compiler_specific.h" | |
| 11 #include "chrome/browser/prefs/pref_member.h" | |
| 12 #include "content/public/browser/notification_observer.h" | |
| 13 #include "content/public/browser/notification_registrar.h" | |
| 14 #include "content/public/browser/web_contents_observer.h" | |
| 15 | |
| 16 class TabContentsWrapper; | |
| 17 class ZoomObserver; | |
| 18 | |
| 19 // Per-tab class to manage the Omnibox zoom icon. | |
| 20 class ZoomController : public content::NotificationObserver, | |
| 21 public content::WebContentsObserver { | |
| 22 public: | |
| 23 enum ZoomIconState { | |
| 24 NONE = 0, | |
| 25 ZOOM_PLUS_ICON, | |
| 26 ZOOM_MINUS_ICON, | |
| 27 }; | |
| 28 | |
| 29 explicit ZoomController(TabContentsWrapper* tab_contents); | |
| 30 virtual ~ZoomController(); | |
| 31 | |
| 32 ZoomIconState zoom_icon_state() const { return zoom_icon_state_; } | |
| 33 int zoom_percent() const { return zoom_percent_; } | |
| 34 | |
| 35 ZoomObserver* observer() const { return observer_; } | |
|
tfarina
2012/06/01 00:47:53
do you need to expose the observer?
Kyle Horimoto
2012/06/01 18:04:50
Nope - deleted that. Thanks.
| |
| 36 void set_observer(ZoomObserver* observer) { observer_ = observer; } | |
| 37 | |
| 38 private: | |
| 39 // content::WebContentsObserver overrides: | |
| 40 virtual void DidNavigateMainFrame( | |
| 41 const content::LoadCommittedDetails& details, | |
| 42 const content::FrameNavigateParams& params) OVERRIDE; | |
| 43 | |
| 44 // content::NotificationObserver overrides: | |
| 45 virtual void Observe(int type, | |
| 46 const content::NotificationSource& source, | |
| 47 const content::NotificationDetails& details) OVERRIDE; | |
| 48 | |
| 49 // Updates the zoom icon and zoom percentage based on current values and | |
| 50 // notifies the observer if changes have occurred. | |
| 51 void UpdateState(); | |
| 52 | |
| 53 // The current zoom icon state. | |
| 54 ZoomIconState zoom_icon_state_; | |
|
tfarina
2012/06/01 00:52:37
nit: initialize this in the constructor initialize
Kyle Horimoto
2012/06/01 18:04:50
Done. Although it really doesn't matter since Upda
| |
| 55 | |
| 56 // The current zoom percentage. | |
| 57 int zoom_percent_; | |
|
tfarina
2012/06/01 00:52:37
nit: initialize this in the constructor initialize
Kyle Horimoto
2012/06/01 18:04:50
Done. Although it really doesn't matter since Upda
| |
| 58 | |
| 59 content::NotificationRegistrar registrar_; | |
| 60 | |
| 61 // Used to access the default zoom level preference. | |
| 62 DoublePrefMember default_zoom_level_; | |
| 63 | |
| 64 // TabContentsWrapper that owns this instance. | |
| 65 TabContentsWrapper* tab_contents_wrapper_; | |
| 66 | |
| 67 // Observer receiving notifications on state changes. | |
| 68 ZoomObserver* observer_; | |
| 69 | |
| 70 DISALLOW_COPY_AND_ASSIGN(ZoomController); | |
| 71 }; | |
| 72 | |
| 73 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | |
| OLD | NEW |