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