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

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

Issue 11414018: [zoom bubble] Add tests for ZoomController::UpdateState() handling empty hosts. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: refactor Created 8 years, 1 month 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 "base/prefs/public/pref_observer.h" 10 #include "base/prefs/public/pref_observer.h"
(...skipping 20 matching lines...) Expand all
31 int zoom_percent() const { return zoom_percent_; } 31 int zoom_percent() const { return zoom_percent_; }
32 32
33 // Convenience method to quickly check if the tab's at default zoom. 33 // Convenience method to quickly check if the tab's at default zoom.
34 bool IsAtDefaultZoom() const; 34 bool IsAtDefaultZoom() const;
35 35
36 // Returns which image should be loaded for the current zoom level. 36 // Returns which image should be loaded for the current zoom level.
37 int GetResourceForZoomLevel() const; 37 int GetResourceForZoomLevel() const;
38 38
39 void set_observer(ZoomObserver* observer) { observer_ = observer; } 39 void set_observer(ZoomObserver* observer) { observer_ = observer; }
40 40
41 private:
42 explicit ZoomController(content::WebContents* web_contents);
43 friend class content::WebContentsUserData<ZoomController>;
44
45 // content::WebContentsObserver overrides: 41 // content::WebContentsObserver overrides:
46 virtual void DidNavigateMainFrame( 42 virtual void DidNavigateMainFrame(
47 const content::LoadCommittedDetails& details, 43 const content::LoadCommittedDetails& details,
48 const content::FrameNavigateParams& params) OVERRIDE; 44 const content::FrameNavigateParams& params) OVERRIDE;
49 45
50 // content::NotificationObserver overrides: 46 // content::NotificationObserver overrides:
51 virtual void Observe(int type, 47 virtual void Observe(int type,
52 const content::NotificationSource& source, 48 const content::NotificationSource& source,
53 const content::NotificationDetails& details) OVERRIDE; 49 const content::NotificationDetails& details) OVERRIDE;
54 50
55 // PrefObserver overrides: 51 // PrefObserver overrides:
56 virtual void OnPreferenceChanged(PrefServiceBase* service, 52 virtual void OnPreferenceChanged(PrefServiceBase* service,
57 const std::string& pref_name) OVERRIDE; 53 const std::string& pref_name) OVERRIDE;
58 54
55 private:
56 explicit ZoomController(content::WebContents* web_contents);
57 friend class content::WebContentsUserData<ZoomController>;
58 friend class ZoomControllerTest;
59
59 // Updates the zoom icon and zoom percentage based on current values and 60 // Updates the zoom icon and zoom percentage based on current values and
60 // notifies the observer if changes have occurred. |host| may be empty, 61 // notifies the observer if changes have occurred. |host| may be empty,
61 // meaning the change should apply to ~all sites. If it is not empty, the 62 // meaning the change should apply to ~all sites. If it is not empty, the
62 // change only affects sites with the given host. 63 // change only affects sites with the given host.
63 void UpdateState(const std::string& host); 64 void UpdateState(const std::string& host);
64 65
65 // The current zoom percentage. 66 // The current zoom percentage.
66 int zoom_percent_; 67 int zoom_percent_;
67 68
68 content::NotificationRegistrar registrar_; 69 content::NotificationRegistrar registrar_;
69 70
70 // Used to access the default zoom level preference. 71 // Used to access the default zoom level preference.
71 DoublePrefMember default_zoom_level_; 72 DoublePrefMember default_zoom_level_;
72 73
73 // Observer receiving notifications on state changes. 74 // Observer receiving notifications on state changes.
74 ZoomObserver* observer_; 75 ZoomObserver* observer_;
75 76
76 DISALLOW_COPY_AND_ASSIGN(ZoomController); 77 DISALLOW_COPY_AND_ASSIGN(ZoomController);
77 }; 78 };
78 79
79 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_ 80 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698