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