Disable view source for Developer Tools.
[chromium-blink-merge.git] / chrome / browser / ui / zoom / zoom_controller.h
blob3c427a716d6956b4603ee54f1d1fe67dd4780985
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.
5 #ifndef CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_
6 #define CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_
8 #include "base/basictypes.h"
9 #include "base/compiler_specific.h"
10 #include "base/prefs/pref_member.h"
11 #include "content/public/browser/host_zoom_map.h"
12 #include "content/public/browser/web_contents_observer.h"
13 #include "content/public/browser/web_contents_user_data.h"
15 class ZoomObserver;
17 namespace content {
18 class WebContents;
21 // Per-tab class to manage the Omnibox zoom icon.
22 class ZoomController : public content::WebContentsObserver,
23 public content::WebContentsUserData<ZoomController> {
24 public:
25 virtual ~ZoomController();
27 int zoom_percent() const { return zoom_percent_; }
29 // Convenience method to quickly check if the tab's at default zoom.
30 bool IsAtDefaultZoom() const;
32 // Returns which image should be loaded for the current zoom level.
33 int GetResourceForZoomLevel() const;
35 void set_observer(ZoomObserver* observer) { observer_ = observer; }
37 // content::WebContentsObserver overrides:
38 virtual void DidNavigateMainFrame(
39 const content::LoadCommittedDetails& details,
40 const content::FrameNavigateParams& params) OVERRIDE;
42 private:
43 explicit ZoomController(content::WebContents* web_contents);
44 friend class content::WebContentsUserData<ZoomController>;
45 friend class ZoomControllerTest;
47 void OnZoomLevelChanged(const content::HostZoomMap::ZoomLevelChange& change);
49 // Updates the zoom icon and zoom percentage based on current values and
50 // notifies the observer if changes have occurred. |host| may be empty,
51 // meaning the change should apply to ~all sites. If it is not empty, the
52 // change only affects sites with the given host.
53 void UpdateState(const std::string& host);
55 // The current zoom percentage.
56 int zoom_percent_;
58 // Used to access the default zoom level preference.
59 DoublePrefMember default_zoom_level_;
61 // Observer receiving notifications on state changes.
62 ZoomObserver* observer_;
64 content::BrowserContext* browser_context_;
66 scoped_ptr<content::HostZoomMap::Subscription> zoom_subscription_;
68 DISALLOW_COPY_AND_ASSIGN(ZoomController);
71 #endif // CHROME_BROWSER_UI_ZOOM_ZOOM_CONTROLLER_H_