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