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

Unified Diff: chrome/browser/ui/cocoa/location_bar/search_token_decoration.mm

Issue 12042002: Alternate NTP: Add search token to omnibox (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: address review comments Created 7 years, 11 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/ui/cocoa/location_bar/search_token_decoration.mm
diff --git a/chrome/browser/ui/cocoa/location_bar/search_token_decoration.mm b/chrome/browser/ui/cocoa/location_bar/search_token_decoration.mm
new file mode 100644
index 0000000000000000000000000000000000000000..381ebcfbd228c8f80ec87b810b92a5908daed55e
--- /dev/null
+++ b/chrome/browser/ui/cocoa/location_bar/search_token_decoration.mm
@@ -0,0 +1,42 @@
+// Copyright (c) 2013 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.
+
+#import "chrome/browser/ui/cocoa/location_bar/search_token_decoration.h"
+
+#import "chrome/browser/ui/cocoa/omnibox/omnibox_view_mac.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util_mac.h"
+
+SearchTokenDecoration::SearchTokenDecoration() {
+}
+
+SearchTokenDecoration::~SearchTokenDecoration() {
+}
+
+void SearchTokenDecoration::DrawInFrame(NSRect frame, NSView* control_view) {
+ NSRect text_rect = NSInsetRect(frame, 0, kTextYInset);
+ [GetAttributedString() drawInRect:text_rect];
+}
+
+CGFloat SearchTokenDecoration::GetWidthForSpace(CGFloat width) {
+ CGFloat desired_width = [GetAttributedString() size].width;
+ if (desired_width > width)
+ return kOmittedWidth;
+ return desired_width;
+}
+
+bool SearchTokenDecoration::ShouldAutoCollapse() const {
+ return true;
+}
+
+NSAttributedString* SearchTokenDecoration::GetAttributedString() const {
+ NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
+ OmniboxViewMac::GetFieldFont(), NSFontAttributeName,
+ [NSColor lightGrayColor], NSForegroundColorAttributeName,
+ nil];
+ NSString* string = l10n_util::GetNSStringF(IDS_OMNIBOX_SEARCH_TOKEN_TEXT,
+ search_provider_name_);
+ return [[[NSAttributedString alloc] initWithString:string
+ attributes:attributes] autorelease];
+}

Powered by Google App Engine
This is Rietveld 408576698