Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2163)

Unified Diff: chrome/browser/cocoa/location_bar/keyword_hint_decoration.h

Issue 2854051: [Mac] Convert omnibox keyword hint to decoration. (Closed) Base URL: git://codf21.jail/chromium.git
Patch Set: Created 10 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/cocoa/location_bar/keyword_hint_decoration.h
diff --git a/chrome/browser/cocoa/location_bar/keyword_hint_decoration.h b/chrome/browser/cocoa/location_bar/keyword_hint_decoration.h
new file mode 100644
index 0000000000000000000000000000000000000000..a7e021ef3b656168854bb4fdd778bd8abfc3a2f0
--- /dev/null
+++ b/chrome/browser/cocoa/location_bar/keyword_hint_decoration.h
@@ -0,0 +1,46 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_
+#define CHROME_BROWSER_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_
+
+#include <string>
+
+#import "chrome/browser/cocoa/location_bar/location_bar_decoration.h"
+
+#import "base/scoped_nsobject.h"
+
+// Draws the keyword hint, "Press [tab] to search <site>".
+
+class KeywordHintDecoration : public LocationBarDecoration {
+ public:
+ KeywordHintDecoration(NSFont* font);
+ virtual ~KeywordHintDecoration();
+
+ // Calculates the message to display and where to place the [tab]
+ // image.
+ void SetKeyword(const std::wstring& keyword, bool is_extension_keyword);
+
+ // Implement |LocationBarDecoration|.
+ virtual void DrawInFrame(NSRect frame, NSView* control_view);
+ virtual CGFloat GetWidthForSpace(CGFloat width);
+
+ private:
+ // Fetch and cache the [tab] image.
+ NSImage* GetHintImage();
+
+ // Attributes for drawing the hint string, such as font and color.
+ scoped_nsobject<NSDictionary> attributes_;
+
+ // Cache for the [tab] image.
+ scoped_nsobject<NSImage> hint_image_;
+
+ // The text to display to the left and right of the hint image.
+ scoped_nsobject<NSString> hint_prefix_;
+ scoped_nsobject<NSString> hint_suffix_;
+
+ DISALLOW_COPY_AND_ASSIGN(KeywordHintDecoration);
+};
+
+#endif // CHROME_BROWSER_COCOA_LOCATION_BAR_KEYWORD_HINT_DECORATION_H_

Powered by Google App Engine
This is Rietveld 408576698