| 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 void set_observer(ZoomObserver* observer) { observer_ = observer; } |
| 36 |
| 37 private: |
| 38 // content::WebContentsObserver overrides: |
| 39 virtual void DidNavigateMainFrame( |
| 40 const content::LoadCommittedDetails& details, |
| 41 const content::FrameNavigateParams& params) OVERRIDE; |
| 42 |
| 43 // content::NotificationObserver overrides: |
| 44 virtual void Observe(int type, |
| 45 const content::NotificationSource& source, |
| 46 const content::NotificationDetails& details) OVERRIDE; |
| 47 |
| 48 // Updates the zoom icon and zoom percentage based on current values and |
| 49 // notifies the observer if changes have occurred. |
| 50 void UpdateState(); |
| 51 |
| 52 // The current zoom icon state. |
| 53 ZoomIconState zoom_icon_state_; |
| 54 |
| 55 // The current zoom percentage. |
| 56 int zoom_percent_; |
| 57 |
| 58 content::NotificationRegistrar registrar_; |
| 59 |
| 60 // Used to access the default zoom level preference. |
| 61 DoublePrefMember default_zoom_level_; |
| 62 |
| 63 // TabContentsWrapper that owns this instance. |
| 64 TabContentsWrapper* tab_contents_wrapper_; |
| 65 |
| 66 // Observer receiving notifications on state changes. |
| 67 ZoomObserver* observer_; |
| 68 |
| 69 DISALLOW_COPY_AND_ASSIGN(ZoomController); |
| 70 }; |
| 71 |
| 72 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| OLD | NEW |