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

Unified Diff: chrome/browser/ui/views/location_bar/search_token_view.cc

Issue 11418229: alternate ntp: implement right-aligned search token (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: impl new design to handle separator in layout system 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/views/location_bar/search_token_view.cc
diff --git a/chrome/browser/ui/views/location_bar/search_token_view.cc b/chrome/browser/ui/views/location_bar/search_token_view.cc
new file mode 100644
index 0000000000000000000000000000000000000000..e84350a4258a9da4c9ab650bb8b06420861fe5e8
--- /dev/null
+++ b/chrome/browser/ui/views/location_bar/search_token_view.cc
@@ -0,0 +1,55 @@
+// 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.
+
+#include "chrome/browser/ui/views/location_bar/search_token_view.h"
+
+#include "base/logging.h"
+#include "grit/generated_resources.h"
+#include "ui/base/l10n/l10n_util.h"
+#include "ui/gfx/canvas.h"
+#include "ui/views/controls/label.h"
+
+SearchTokenView::SearchTokenView()
+ : label_(new views::Label()) {
+ label_->SetAutoColorReadabilityEnabled(false);
+ AddChildView(label_);
+}
+
+SearchTokenView::~SearchTokenView() {
+}
+
+void SearchTokenView::SetFont(const gfx::Font& font) {
+ label_->SetFont(font);
+}
+
+void SearchTokenView::SetBackgroundColor(SkColor color) {
+ label_->SetBackgroundColor(color);
+}
+
+void SearchTokenView::SetForegroundColor(SkColor color) {
+ label_->SetEnabledColor(color);
+}
+
+void SearchTokenView::SetSearchProvider(const string16& search_provider) {
+ if (search_provider_ == search_provider)
+ return;
+ search_provider_ = search_provider;
+ if (!search_provider_.empty()) {
+ label_->SetText(l10n_util::GetStringFUTF16(IDS_OMNIBOX_SEARCH_TOKEN_TEXT,
+ search_provider_));
+ }
+}
+
+gfx::Size SearchTokenView::GetPreferredSize() {
+ return label_->GetPreferredSize();
+}
+
+void SearchTokenView::Layout() {
+ label_->SetBounds(0, 0, label_->GetPreferredSize().width(), height());
+}
+
+void SearchTokenView::OnPaint(gfx::Canvas* canvas) {
+ // Paint the background color.
+ canvas->DrawColor(label_->background_color());
+}

Powered by Google App Engine
This is Rietveld 408576698