keyword_hint_view.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
1// Copyright (c) 2011 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_KEYWORD_HINT_VIEW_H_ 6#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_KEYWORD_HINT_VIEW_H_ 7 8#include <string> 9 10#include "base/compiler_specific.h" 11#include "ui/gfx/size.h" 12#include "ui/views/view.h" 13 14class LocationBarView; 15class Profile; 16 17namespace gfx { 18class Font; 19} 20 21namespace views { 22class ImageView; 23class Label; 24} 25 26// KeywordHintView is used by the location bar view to display a hint to the 27// user when the selected url has a corresponding keyword. 28// 29// Internally KeywordHintView uses two labels to render the text, and draws 30// the tab image itself. 31// 32// NOTE: This should really be called LocationBarKeywordHintView, but I 33// couldn't bring myself to use such a long name. 34class KeywordHintView : public views::View { 35 public: 36 KeywordHintView(Profile* profile, 37 const gfx::Font& font, 38 int font_y_offset, 39 const LocationBarView* location_bar_view); 40 virtual ~KeywordHintView(); 41 42 void SetKeyword(const string16& keyword); 43 string16 keyword() const { return keyword_; } 44 45 virtual gfx::Size GetPreferredSize() OVERRIDE; 46 // The minimum size is just big enough to show the tab. 47 virtual gfx::Size GetMinimumSize() OVERRIDE; 48 virtual void Layout() OVERRIDE; 49 50 private: 51 views::Label* CreateLabel(const gfx::Font& font, 52 int font_y_offset, 53 const LocationBarView* location_bar_view); 54 55 Profile* profile_; 56 views::Label* leading_label_; 57 views::ImageView* tab_image_; 58 views::Label* trailing_label_; 59 string16 keyword_; 60 61 DISALLOW_COPY_AND_ASSIGN(KeywordHintView); 62}; 63 64#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_KEYWORD_HINT_VIEW_H_ 65