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_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ | 5 #ifndef CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ |
6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ | 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ |
7 | 7 |
8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
9 #include "chrome/browser/ui/toolbar/toolbar_model.h" | 9 #include "chrome/browser/ui/toolbar/toolbar_model.h" |
10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" | 10 #include "chrome/browser/ui/views/location_bar/location_bar_view.h" |
11 #include "chrome/browser/ui/zoom/zoom_controller.h" | |
12 #include "ui/views/controls/image_view.h" | 11 #include "ui/views/controls/image_view.h" |
13 | 12 |
14 namespace views { | 13 namespace views { |
15 class KeyEvent; | 14 class KeyEvent; |
16 class MouseEvent; | 15 class MouseEvent; |
17 } | 16 } |
18 | 17 |
| 18 class ZoomController; |
| 19 |
19 // View for the zoom icon in the Omnibox. | 20 // View for the zoom icon in the Omnibox. |
20 class ZoomView : public views::ImageView { | 21 class ZoomView : public views::ImageView { |
21 public: | 22 public: |
22 // Constructor for ZoomView. Clicking on the ZoomView shows a ZoomBubbleView, | 23 // Constructor for ZoomView. Clicking on the ZoomView shows a ZoomBubbleView, |
23 // which requires the current TabContents. Because the current TabContents | 24 // which requires the current TabContents. Because the current TabContents |
24 // changes as the user switches tabs, it cannot be provided in the | 25 // changes as the user switches tabs, it cannot be provided in the |
25 // constructor. Instead, a LocationBarView::Delegate is passed here so that | 26 // constructor. Instead, a LocationBarView::Delegate is passed here so that |
26 // it can be queried for the current TabContents as needed. | 27 // it can be queried for the current TabContents as needed. |
27 ZoomView(ToolbarModel* toolbar_model, | 28 ZoomView(ToolbarModel* toolbar_model, |
28 LocationBarView::Delegate* location_bar_delegate); | 29 LocationBarView::Delegate* location_bar_delegate); |
29 virtual ~ZoomView(); | 30 virtual ~ZoomView(); |
30 | 31 |
31 void SetZoomIconState(ZoomController::ZoomIconState zoom_icon_state); | |
32 void SetZoomIconTooltipPercent(int zoom_percent); | |
33 | |
34 // Updates the image and its tooltip appropriately, hiding or showing the icon | 32 // Updates the image and its tooltip appropriately, hiding or showing the icon |
35 // as needed. | 33 // as needed. |
36 void Update(); | 34 void Update(ZoomController* zoom_controller); |
37 | 35 |
38 private: | 36 private: |
39 // views::ImageView: | 37 // views::ImageView: |
40 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; | 38 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; |
41 virtual bool GetTooltipText(const gfx::Point& p, | 39 virtual bool GetTooltipText(const gfx::Point& p, |
42 string16* tooltip) const OVERRIDE; | 40 string16* tooltip) const OVERRIDE; |
43 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; | 41 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; |
44 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; | 42 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; |
45 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; | 43 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; |
46 | 44 |
47 // Toolbar model used to test whether location bar input is in progress. | 45 // Toolbar model used to test whether location bar input is in progress. |
48 ToolbarModel* toolbar_model_; | 46 ToolbarModel* toolbar_model_; |
49 | 47 |
50 // The delegate used to get the currently visible TabContents. | 48 // The delegate used to get the currently visible TabContents. |
51 LocationBarView::Delegate* location_bar_delegate_; | 49 LocationBarView::Delegate* location_bar_delegate_; |
52 | 50 |
53 // The current icon state. | |
54 ZoomController::ZoomIconState zoom_icon_state_; | |
55 | |
56 // The current zoom percentage. | |
57 int zoom_percent_; | |
58 | |
59 DISALLOW_COPY_AND_ASSIGN(ZoomView); | 51 DISALLOW_COPY_AND_ASSIGN(ZoomView); |
60 }; | 52 }; |
61 | 53 |
62 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ | 54 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_ZOOM_VIEW_H_ |
OLD | NEW |