selected_keyword_view.h revision 90dce4d38c5ff5333bea97d859d4e484e27edf0c
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_SELECTED_KEYWORD_VIEW_H_ 6#define CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SELECTED_KEYWORD_VIEW_H_ 7 8#include <string> 9 10#include "base/compiler_specific.h" 11#include "chrome/browser/ui/views/location_bar/icon_label_bubble_view.h" 12#include "ui/views/controls/label.h" 13 14class Profile; 15namespace gfx { 16class Font; 17class Size; 18} 19 20// SelectedKeywordView displays the tab-to-search UI in the location bar view. 21class SelectedKeywordView : public IconLabelBubbleView { 22 public: 23 SelectedKeywordView(const int background_images[], 24 int contained_image, 25 const gfx::Font& font, 26 int font_y_offset, 27 SkColor color, 28 Profile* profile); 29 virtual ~SelectedKeywordView(); 30 31 virtual gfx::Size GetPreferredSize() OVERRIDE; 32 virtual gfx::Size GetMinimumSize() OVERRIDE; 33 virtual void Layout() OVERRIDE; 34 35 // The current keyword, or an empty string if no keyword is displayed. 36 void SetKeyword(const string16& keyword); 37 string16 keyword() const { return keyword_; } 38 39 private: 40 // The keyword we're showing. If empty, no keyword is selected. 41 // NOTE: we don't cache the TemplateURL as it is possible for it to get 42 // deleted out from under us. 43 string16 keyword_; 44 45 // These labels are never visible. They are used to size the view. One 46 // label contains the complete description of the keyword, the second 47 // contains a truncated version of the description, for if there is not 48 // enough room to display the complete description. 49 views::Label full_label_; 50 views::Label partial_label_; 51 52 Profile* profile_; 53 54 DISALLOW_COPY_AND_ASSIGN(SelectedKeywordView); 55}; 56 57#endif // CHROME_BROWSER_UI_VIEWS_LOCATION_BAR_SELECTED_KEYWORD_VIEW_H_ 58