1 // Copyright 2013 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_LOCATION_BAR_DECORATION_VIEW_H_ 6 #define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_DECORATION_VIEW_H_ 7 8 #include "base/basictypes.h" 9 #include "base/compiler_specific.h" 10 #include "ui/views/controls/image_view.h" 11 12 //////////////////////////////////////////////////////////////////////////////// 13 // 14 // LocationBarDecorationView 15 // 16 // An abstract class to provide common functionality to all icons that show up 17 // in the omnibox (like the bookmarks star or SSL lock). 18 // 19 //////////////////////////////////////////////////////////////////////////////// 20 class LocationBarDecorationView : public views::ImageView { 21 public: 22 LocationBarDecorationView(); 23 virtual ~LocationBarDecorationView(); 24 25 // views::ImageView: 26 virtual bool OnMousePressed(const ui::MouseEvent& event) OVERRIDE; 27 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE; 28 virtual bool OnKeyPressed(const ui::KeyEvent& event) OVERRIDE; 29 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE; 30 31 protected: 32 // Whether this icon should currently be able to process a mouse click. Called 33 // both on mouse up and mouse down; must return true both times to for 34 // |OnClick()| to be called. 35 virtual bool CanHandleClick() const; 36 37 // Called when a user mouses up, taps, or presses a key on this icon. 38 virtual void OnClick() = 0; 39 40 private: 41 // Set when the user's mouse goes down to determine whether |CanHandleClick()| 42 // was true at that point. 43 bool could_handle_click_; 44 45 DISALLOW_COPY_AND_ASSIGN(LocationBarDecorationView); 46 }; 47 48 #endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_LOCATION_BAR_DECORATION_VIEW_H_ 49