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_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ 7 #pragma once 8 9 #include <string> 10 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" 12 13 #import "base/memory/scoped_nsobject.h" 14 #include "base/string16.h" 15 16 // Draws the keyword hint, "Press [tab] to search <site>". 17 18 class KeywordHintDecoration : public LocationBarDecoration { 19 public: 20 KeywordHintDecoration(NSFont* font); 21 virtual ~KeywordHintDecoration(); 22 23 // Calculates the message to display and where to place the [tab] 24 // image. 25 void SetKeyword(const string16& keyword, bool is_extension_keyword); 26 27 // Implement |LocationBarDecoration|. 28 virtual void DrawInFrame(NSRect frame, NSView* control_view); 29 virtual CGFloat GetWidthForSpace(CGFloat width); 30 31 private: 32 // Fetch and cache the [tab] image. 33 NSImage* GetHintImage(); 34 35 // Attributes for drawing the hint string, such as font and color. 36 scoped_nsobject<NSDictionary> attributes_; 37 38 // Cache for the [tab] image. 39 scoped_nsobject<NSImage> hint_image_; 40 41 // The text to display to the left and right of the hint image. 42 scoped_nsobject<NSString> hint_prefix_; 43 scoped_nsobject<NSString> hint_suffix_; 44 45 DISALLOW_COPY_AND_ASSIGN(KeywordHintDecoration); 46 }; 47 48 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ 49