| OLD | NEW |
| 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/api/prefs/pref_member.h" | 10 #include "chrome/browser/api/prefs/pref_member.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 int zoom_percent() const { return zoom_percent_; } | 29 int zoom_percent() const { return zoom_percent_; } |
| 30 | 30 |
| 31 // Convenience method to quickly check if the tab's at default zoom. | 31 // Convenience method to quickly check if the tab's at default zoom. |
| 32 bool IsAtDefaultZoom() const; | 32 bool IsAtDefaultZoom() const; |
| 33 | 33 |
| 34 // Returns which image should be loaded for the current zoom level. | 34 // Returns which image should be loaded for the current zoom level. |
| 35 int GetResourceForZoomLevel() const; | 35 int GetResourceForZoomLevel() const; |
| 36 | 36 |
| 37 void set_observer(ZoomObserver* observer) { observer_ = observer; } | 37 void set_observer(ZoomObserver* observer) { observer_ = observer; } |
| 38 | 38 |
| 39 private: | |
| 40 friend class content::WebContentsUserData<ZoomController>; | |
| 41 | |
| 42 explicit ZoomController(content::WebContents* web_contents); | |
| 43 | |
| 44 // content::WebContentsObserver overrides: | 39 // content::WebContentsObserver overrides: |
| 45 virtual void DidNavigateMainFrame( | 40 virtual void DidNavigateMainFrame( |
| 46 const content::LoadCommittedDetails& details, | 41 const content::LoadCommittedDetails& details, |
| 47 const content::FrameNavigateParams& params) OVERRIDE; | 42 const content::FrameNavigateParams& params) OVERRIDE; |
| 48 | 43 |
| 49 // content::NotificationObserver overrides: | 44 // content::NotificationObserver overrides: |
| 50 virtual void Observe(int type, | 45 virtual void Observe(int type, |
| 51 const content::NotificationSource& source, | 46 const content::NotificationSource& source, |
| 52 const content::NotificationDetails& details) OVERRIDE; | 47 const content::NotificationDetails& details) OVERRIDE; |
| 53 | 48 |
| 49 private: |
| 50 explicit ZoomController(content::WebContents* web_contents); |
| 51 friend class content::WebContentsUserData<ZoomController>; |
| 52 friend class ZoomControllerTest; |
| 53 |
| 54 // Updates the zoom icon and zoom percentage based on current values and | 54 // Updates the zoom icon and zoom percentage based on current values and |
| 55 // notifies the observer if changes have occurred. |host| may be empty, | 55 // notifies the observer if changes have occurred. |host| may be empty, |
| 56 // meaning the change should apply to ~all sites. If it is not empty, the | 56 // meaning the change should apply to ~all sites. If it is not empty, the |
| 57 // change only affects sites with the given host. | 57 // change only affects sites with the given host. |
| 58 void UpdateState(const std::string& host); | 58 void UpdateState(const std::string& host); |
| 59 | 59 |
| 60 // The current zoom percentage. | 60 // The current zoom percentage. |
| 61 int zoom_percent_; | 61 int zoom_percent_; |
| 62 | 62 |
| 63 content::NotificationRegistrar registrar_; | 63 content::NotificationRegistrar registrar_; |
| 64 | 64 |
| 65 // Used to access the default zoom level preference. | 65 // Used to access the default zoom level preference. |
| 66 DoublePrefMember default_zoom_level_; | 66 DoublePrefMember default_zoom_level_; |
| 67 | 67 |
| 68 // Observer receiving notifications on state changes. | 68 // Observer receiving notifications on state changes. |
| 69 ZoomObserver* observer_; | 69 ZoomObserver* observer_; |
| 70 | 70 |
| 71 DISALLOW_COPY_AND_ASSIGN(ZoomController); | 71 DISALLOW_COPY_AND_ASSIGN(ZoomController); |
| 72 }; | 72 }; |
| 73 | 73 |
| 74 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ | 74 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ |
| OLD | NEW |