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