| 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());
|
| +}
|
|
|