OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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_SELECTED_KEYWORD_DECORATION_H_ | 5 #ifndef CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SELECTED_KEYWORD_DECORATION_H_ |
6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SELECTED_KEYWORD_DECORATION_H_ | 6 #define CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SELECTED_KEYWORD_DECORATION_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #import <Cocoa/Cocoa.h> | 10 #import <Cocoa/Cocoa.h> |
11 | 11 |
12 #include "base/strings/string16.h" | 12 #include "base/strings/string16.h" |
13 #include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" | 13 #include "chrome/browser/ui/cocoa/location_bar/bubble_decoration.h" |
14 | 14 |
15 class SelectedKeywordDecoration : public BubbleDecoration { | 15 class SelectedKeywordDecoration : public BubbleDecoration { |
16 public: | 16 public: |
17 SelectedKeywordDecoration(); | 17 SelectedKeywordDecoration(); |
18 virtual ~SelectedKeywordDecoration(); | 18 ~SelectedKeywordDecoration() override; |
19 | 19 |
20 // Calculates appropriate full and partial label strings based on | 20 // Calculates appropriate full and partial label strings based on |
21 // inputs. | 21 // inputs. |
22 void SetKeyword(const base::string16& keyword, bool is_extension_keyword); | 22 void SetKeyword(const base::string16& keyword, bool is_extension_keyword); |
23 | 23 |
24 // Determines what combination of labels and image will best fit | 24 // Determines what combination of labels and image will best fit |
25 // within |width|, makes those current for |BubbleDecoration|, and | 25 // within |width|, makes those current for |BubbleDecoration|, and |
26 // return the resulting width. | 26 // return the resulting width. |
27 virtual CGFloat GetWidthForSpace(CGFloat width) override; | 27 CGFloat GetWidthForSpace(CGFloat width) override; |
28 | 28 |
29 // Implements |BubbleDecoration|. | 29 // Implements |BubbleDecoration|. |
30 virtual ui::NinePartImageIds GetBubbleImageIds() override; | 30 ui::NinePartImageIds GetBubbleImageIds() override; |
31 | 31 |
32 void SetImage(NSImage* image); | 32 void SetImage(NSImage* image); |
33 | 33 |
34 private: | 34 private: |
35 friend class SelectedKeywordDecorationTest; | 35 friend class SelectedKeywordDecorationTest; |
36 FRIEND_TEST_ALL_PREFIXES(SelectedKeywordDecorationTest, | 36 FRIEND_TEST_ALL_PREFIXES(SelectedKeywordDecorationTest, |
37 UsesPartialKeywordIfNarrow); | 37 UsesPartialKeywordIfNarrow); |
38 | 38 |
39 base::scoped_nsobject<NSImage> search_image_; | 39 base::scoped_nsobject<NSImage> search_image_; |
40 base::scoped_nsobject<NSString> full_string_; | 40 base::scoped_nsobject<NSString> full_string_; |
41 base::scoped_nsobject<NSString> partial_string_; | 41 base::scoped_nsobject<NSString> partial_string_; |
42 | 42 |
43 DISALLOW_COPY_AND_ASSIGN(SelectedKeywordDecoration); | 43 DISALLOW_COPY_AND_ASSIGN(SelectedKeywordDecoration); |
44 }; | 44 }; |
45 | 45 |
46 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SELECTED_KEYWORD_DECORATION_H_ | 46 #endif // CHROME_BROWSER_UI_COCOA_LOCATION_BAR_SELECTED_KEYWORD_DECORATION_H_ |
OLD | NEW |