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