OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ |
6 #define 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 | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" | 11 #import "chrome/browser/ui/cocoa/location_bar/location_bar_decoration.h" |
12 | 12 |
13 #import "base/scoped_nsobject.h" | 13 #import "base/scoped_nsobject.h" |
| 14 #include "base/string16.h" |
14 | 15 |
15 // Draws the keyword hint, "Press [tab] to search <site>". | 16 // Draws the keyword hint, "Press [tab] to search <site>". |
16 | 17 |
17 class KeywordHintDecoration : public LocationBarDecoration { | 18 class KeywordHintDecoration : public LocationBarDecoration { |
18 public: | 19 public: |
19 KeywordHintDecoration(NSFont* font); | 20 KeywordHintDecoration(NSFont* font); |
20 virtual ~KeywordHintDecoration(); | 21 virtual ~KeywordHintDecoration(); |
21 | 22 |
22 // Calculates the message to display and where to place the [tab] | 23 // Calculates the message to display and where to place the [tab] |
23 // image. | 24 // image. |
24 void SetKeyword(const std::wstring& keyword, bool is_extension_keyword); | 25 void SetKeyword(const string16& keyword, bool is_extension_keyword); |
25 | 26 |
26 // Implement |LocationBarDecoration|. | 27 // Implement |LocationBarDecoration|. |
27 virtual void DrawInFrame(NSRect frame, NSView* control_view); | 28 virtual void DrawInFrame(NSRect frame, NSView* control_view); |
28 virtual CGFloat GetWidthForSpace(CGFloat width); | 29 virtual CGFloat GetWidthForSpace(CGFloat width); |
29 | 30 |
30 private: | 31 private: |
31 // Fetch and cache the [tab] image. | 32 // Fetch and cache the [tab] image. |
32 NSImage* GetHintImage(); | 33 NSImage* GetHintImage(); |
33 | 34 |
34 // Attributes for drawing the hint string, such as font and color. | 35 // Attributes for drawing the hint string, such as font and color. |
35 scoped_nsobject<NSDictionary> attributes_; | 36 scoped_nsobject<NSDictionary> attributes_; |
36 | 37 |
37 // Cache for the [tab] image. | 38 // Cache for the [tab] image. |
38 scoped_nsobject<NSImage> hint_image_; | 39 scoped_nsobject<NSImage> hint_image_; |
39 | 40 |
40 // The text to display to the left and right of the hint image. | 41 // The text to display to the left and right of the hint image. |
41 scoped_nsobject<NSString> hint_prefix_; | 42 scoped_nsobject<NSString> hint_prefix_; |
42 scoped_nsobject<NSString> hint_suffix_; | 43 scoped_nsobject<NSString> hint_suffix_; |
43 | 44 |
44 DISALLOW_COPY_AND_ASSIGN(KeywordHintDecoration); | 45 DISALLOW_COPY_AND_ASSIGN(KeywordHintDecoration); |
45 }; | 46 }; |
46 | 47 |
47 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ | 48 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_ |
OLD | NEW |